aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-11-29 14:16:26 +0000
committerlloyd <[email protected]>2014-11-29 14:16:26 +0000
commite89b6a365e56283a945aeda8ed2b427937fe5d91 (patch)
treee01cd34049831debff697de3f11fb54d175a8b81 /src/lib
parent71ff50357af5183995c9af59f1816f065ce9a857 (diff)
Move all PK workfactor esstimators to workfactors.*
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pubkey/ecc_key/ecc_key.cpp3
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp9
-rw-r--r--src/lib/pubkey/mce/mceliece_key.h3
-rw-r--r--src/lib/pubkey/workfactor.cpp10
-rw-r--r--src/lib/pubkey/workfactor.h13
5 files changed, 33 insertions, 5 deletions
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp
index c9d4d62fe..7f82af4f5 100644
--- a/src/lib/pubkey/ecc_key/ecc_key.cpp
+++ b/src/lib/pubkey/ecc_key/ecc_key.cpp
@@ -14,12 +14,13 @@
#include <botan/ber_dec.h>
#include <botan/secmem.h>
#include <botan/point_gfp.h>
+#include <botan/workfactor.h>
namespace Botan {
size_t EC_PublicKey::estimated_strength() const
{
- return domain().get_curve().get_p().bits() / 2;
+ return ecp_work_factor(domain().get_curve().get_p().bits());
}
EC_PublicKey::EC_PublicKey(const EC_Group& dom_par,
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index 71e0ec4e8..7da5aefed 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -14,10 +14,10 @@
#include <botan/gf2m_small_m.h>
#include <botan/mceliece.h>
#include <botan/internal/code_based_key_gen.h>
-#include <botan/alg_id.h>
+#include <botan/code_based_util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
-#include <botan/oids.h>
+#include <botan/workfactor.h>
namespace Botan {
@@ -74,6 +74,11 @@ McEliece_PublicKey::McEliece_PublicKey(const McEliece_PublicKey & other) :
{
}
+size_t McEliece_PublicKey::estimated_strength() const
+ {
+ return mceliece_work_factor(m_t, m_code_length);
+ }
+
McEliece_PublicKey::McEliece_PublicKey(const std::vector<byte>& key_bits)
{
BER_Decoder dec(key_bits);
diff --git a/src/lib/pubkey/mce/mceliece_key.h b/src/lib/pubkey/mce/mceliece_key.h
index c51745bba..1a9a699f4 100644
--- a/src/lib/pubkey/mce/mceliece_key.h
+++ b/src/lib/pubkey/mce/mceliece_key.h
@@ -15,7 +15,6 @@
#include <botan/exceptn.h>
#include <botan/pk_keys.h>
#include <botan/polyn_gf2m.h>
-#include <botan/code_based_util.h>
namespace Botan {
@@ -47,7 +46,7 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const;
- size_t estimated_strength() const { return 0; }
+ size_t estimated_strength() const;
std::vector<byte> x509_subject_public_key() const;
diff --git a/src/lib/pubkey/workfactor.cpp b/src/lib/pubkey/workfactor.cpp
index b917ce52d..972d03af9 100644
--- a/src/lib/pubkey/workfactor.cpp
+++ b/src/lib/pubkey/workfactor.cpp
@@ -11,6 +11,16 @@
namespace Botan {
+size_t mceliece_work_factor(size_t code_size, size_t t)
+ {
+ return 0;
+ }
+
+size_t ecp_work_factor(size_t bits)
+ {
+ return bits / 2;
+ }
+
size_t dl_work_factor(size_t bits)
{
/*
diff --git a/src/lib/pubkey/workfactor.h b/src/lib/pubkey/workfactor.h
index 179b580e7..37f487234 100644
--- a/src/lib/pubkey/workfactor.h
+++ b/src/lib/pubkey/workfactor.h
@@ -19,6 +19,19 @@ namespace Botan {
*/
size_t dl_work_factor(size_t prime_group_size);
+/**
+* Estimate work factor for EC discrete logarithm
+* @param prime_group_size size of the group in bits
+* @return estimated security level for this group
+*/
+size_t ecp_work_factor(size_t prime_group_size);
+
+/**
+* Estimate work factor for McEliece
+* @return estimated security level for this group
+*/
+size_t mceliece_work_factor(size_t code_size, size_t t);
+
}
#endif