aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-09-17 14:00:06 +0000
committerlloyd <[email protected]>2009-09-17 14:00:06 +0000
commit9a13eb0a34fad9dc78e88970233020a5c0bdb4ed (patch)
tree5f3e9116672453fae2939501e8ab0fc90f01c322 /src/pubkey
parent69e8cc40848b95a644fb952c73788e825c1683ba (diff)
parente1d81327dde6c6837ed81c61c58876bd261fb47d (diff)
propagate from branch 'net.randombit.botan' (head 92e05ab242e4b6998d685961c53700534a673bce)
to branch 'net.randombit.botan.c++0x' (head 27ce37b971ec5cb1f80a9a95b13d5a951b96653b)
Diffstat (limited to 'src/pubkey')
-rw-r--r--src/pubkey/dh/dh.cpp2
-rw-r--r--src/pubkey/dl_group/dl_group.cpp2
-rw-r--r--src/pubkey/ecc_key/ecc_key.cpp1
-rw-r--r--src/pubkey/ecdsa/ecdsa.cpp1
-rw-r--r--src/pubkey/eckaeg/eckaeg.cpp1
-rw-r--r--src/pubkey/elgamal/elgamal.cpp2
-rw-r--r--src/pubkey/info.txt2
-rw-r--r--src/pubkey/workfactor.cpp51
-rw-r--r--src/pubkey/workfactor.h22
9 files changed, 78 insertions, 6 deletions
diff --git a/src/pubkey/dh/dh.cpp b/src/pubkey/dh/dh.cpp
index 0c9d02f0e..149bc5882 100644
--- a/src/pubkey/dh/dh.cpp
+++ b/src/pubkey/dh/dh.cpp
@@ -7,7 +7,7 @@
#include <botan/dh.h>
#include <botan/numthry.h>
-#include <botan/util.h>
+#include <botan/workfactor.h>
namespace Botan {
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp
index 81c5d5e1d..13ea03016 100644
--- a/src/pubkey/dl_group/dl_group.cpp
+++ b/src/pubkey/dl_group/dl_group.cpp
@@ -12,7 +12,7 @@
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/pipe.h>
-#include <botan/util.h>
+#include <botan/workfactor.h>
#include <botan/pem.h>
namespace Botan {
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp
index 6c7d02c74..8d9e89f1e 100644
--- a/src/pubkey/ecc_key/ecc_key.cpp
+++ b/src/pubkey/ecc_key/ecc_key.cpp
@@ -10,7 +10,6 @@
#include <botan/ecc_key.h>
#include <botan/x509_key.h>
#include <botan/numthry.h>
-#include <botan/util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/secmem.h>
diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp
index 3e3bbf38a..4cabf5e5b 100644
--- a/src/pubkey/ecdsa/ecdsa.cpp
+++ b/src/pubkey/ecdsa/ecdsa.cpp
@@ -9,7 +9,6 @@
#include <botan/ecdsa.h>
#include <botan/numthry.h>
-#include <botan/util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/secmem.h>
diff --git a/src/pubkey/eckaeg/eckaeg.cpp b/src/pubkey/eckaeg/eckaeg.cpp
index 5787f062d..a2dec5279 100644
--- a/src/pubkey/eckaeg/eckaeg.cpp
+++ b/src/pubkey/eckaeg/eckaeg.cpp
@@ -9,7 +9,6 @@
#include <botan/eckaeg.h>
#include <botan/numthry.h>
-#include <botan/util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/secmem.h>
diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp
index 1f79df57a..8c07c5735 100644
--- a/src/pubkey/elgamal/elgamal.cpp
+++ b/src/pubkey/elgamal/elgamal.cpp
@@ -9,7 +9,7 @@
#include <botan/numthry.h>
#include <botan/keypair.h>
#include <botan/look_pk.h>
-#include <botan/util.h>
+#include <botan/workfactor.h>
namespace Botan {
diff --git a/src/pubkey/info.txt b/src/pubkey/info.txt
index ee8da5b9d..63af86c47 100644
--- a/src/pubkey/info.txt
+++ b/src/pubkey/info.txt
@@ -15,6 +15,8 @@ pubkey.cpp
pubkey.h
pubkey_enums.cpp
pubkey_enums.h
+workfactor.cpp
+workfactor.h
</add>
<requires>
diff --git a/src/pubkey/workfactor.cpp b/src/pubkey/workfactor.cpp
new file mode 100644
index 000000000..e40b7919c
--- /dev/null
+++ b/src/pubkey/workfactor.cpp
@@ -0,0 +1,51 @@
+/*
+* Public Key Work Factor Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/workfactor.h>
+#include <algorithm>
+#include <cmath>
+
+namespace Botan {
+
+/*
+* Choose the exponent size for a DL group
+*/
+u32bit dl_work_factor(u32bit bits)
+ {
+#if 0
+ /*
+ These values were taken from RFC 3526
+ */
+ if(bits <= 1536)
+ return 90;
+ else if(bits <= 2048)
+ return 110;
+ else if(bits <= 3072)
+ return 130;
+ else if(bits <= 4096)
+ return 150;
+ else if(bits <= 6144)
+ return 170;
+ else if(bits <= 8192)
+ return 190;
+ return 256;
+#else
+ const u32bit MIN_ESTIMATE = 64;
+
+ const double log_x = bits / 1.44;
+
+ const double strength =
+ 2.76 * std::pow(log_x, 1.0/3.0) * std::pow(std::log(log_x), 2.0/3.0);
+
+ if(strength > MIN_ESTIMATE)
+ return static_cast<u32bit>(strength);
+ return MIN_ESTIMATE;
+#endif
+ }
+
+
+}
diff --git a/src/pubkey/workfactor.h b/src/pubkey/workfactor.h
new file mode 100644
index 000000000..653f697e3
--- /dev/null
+++ b/src/pubkey/workfactor.h
@@ -0,0 +1,22 @@
+/*
+* Public Key Work Factor Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_WORKFACTOR_H__
+#define BOTAN_WORKFACTOR_H__
+
+#include <botan/types.h>
+
+namespace Botan {
+
+/*
+* Work Factor Estimates
+*/
+BOTAN_DLL u32bit dl_work_factor(u32bit prime_group_size);
+
+}
+
+#endif