aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ber_dec.h1
-rw-r--r--include/config.h4
-rw-r--r--include/der_enc.h3
-rw-r--r--include/enums.h2
-rw-r--r--include/pbe_pkcs.h1
-rw-r--r--include/pkcs8.h1
-rw-r--r--include/pubkey.h2
-rw-r--r--include/x509_key.h1
-rw-r--r--include/x509_obj.h1
-rw-r--r--src/config.cpp29
-rw-r--r--src/x509_ca.cpp29
11 files changed, 34 insertions, 40 deletions
diff --git a/include/ber_dec.h b/include/ber_dec.h
index 890af67a2..1ea880595 100644
--- a/include/ber_dec.h
+++ b/include/ber_dec.h
@@ -8,6 +8,7 @@
#include <botan/asn1_oid.h>
#include <botan/data_src.h>
+#include <botan/enums.h>
namespace Botan {
diff --git a/include/config.h b/include/config.h
index 7ef873e8f..e0ceeb737 100644
--- a/include/config.h
+++ b/include/config.h
@@ -7,7 +7,6 @@
#define BOTAN_POLICY_CONF_H__
#include <botan/mutex.h>
-#include <botan/enums.h>
#include <string>
#include <vector>
#include <map>
@@ -39,9 +38,6 @@ class BOTAN_DLL Config
std::string deref_alias(const std::string&) const;
void load_inifile(const std::string&);
-
- static void choose_sig_format(const std::string&, std::string&,
- Signature_Format&);
private:
Config(const Config&) {}
Config& operator=(const Config&) { return (*this); }
diff --git a/include/der_enc.h b/include/der_enc.h
index 86f33abe2..5b3c11489 100644
--- a/include/der_enc.h
+++ b/include/der_enc.h
@@ -6,8 +6,7 @@
#ifndef BOTAN_DER_ENCODER_H__
#define BOTAN_DER_ENCODER_H__
-#include <botan/secmem.h>
-#include <botan/enums.h>
+#include <botan/asn1_int.h>
#include <vector>
namespace Botan {
diff --git a/include/enums.h b/include/enums.h
index d12b5a1e3..dc404b728 100644
--- a/include/enums.h
+++ b/include/enums.h
@@ -53,8 +53,6 @@ enum X509_Encoding { RAW_BER, PEM };
enum Cipher_Dir { ENCRYPTION, DECRYPTION };
-enum Signature_Format { IEEE_1363, DER_SEQUENCE };
-
enum Character_Set {
LOCAL_CHARSET,
UCS2_CHARSET,
diff --git a/include/pbe_pkcs.h b/include/pbe_pkcs.h
index cd2f27ce4..a01f70e66 100644
--- a/include/pbe_pkcs.h
+++ b/include/pbe_pkcs.h
@@ -8,6 +8,7 @@
#include <botan/pbe.h>
#include <botan/pipe.h>
+#include <botan/enums.h>
namespace Botan {
diff --git a/include/pkcs8.h b/include/pkcs8.h
index 0c7c97e6c..aa36af30f 100644
--- a/include/pkcs8.h
+++ b/include/pkcs8.h
@@ -8,6 +8,7 @@
#include <botan/x509_key.h>
#include <botan/ui.h>
+#include <botan/enums.h>
namespace Botan {
diff --git a/include/pubkey.h b/include/pubkey.h
index 798d97661..e4ea4e848 100644
--- a/include/pubkey.h
+++ b/include/pubkey.h
@@ -12,6 +12,8 @@
namespace Botan {
+enum Signature_Format { IEEE_1363, DER_SEQUENCE };
+
/*************************************************
* Public Key Encryptor *
*************************************************/
diff --git a/include/x509_key.h b/include/x509_key.h
index 6f45887ca..abaeaaced 100644
--- a/include/x509_key.h
+++ b/include/x509_key.h
@@ -9,6 +9,7 @@
#include <botan/pipe.h>
#include <botan/pk_keys.h>
#include <botan/alg_id.h>
+#include <botan/enums.h>
namespace Botan {
diff --git a/include/x509_obj.h b/include/x509_obj.h
index 88110d9ad..55065f6f5 100644
--- a/include/x509_obj.h
+++ b/include/x509_obj.h
@@ -8,6 +8,7 @@
#include <botan/asn1_obj.h>
#include <botan/pipe.h>
+#include <botan/enums.h>
#include <vector>
namespace Botan {
diff --git a/src/config.cpp b/src/config.cpp
index bcca49bdf..d131b2f59 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -155,33 +155,4 @@ u32bit Config::option_as_time(const std::string& key) const
return scale * to_u32bit(value);
}
-/*************************************************
-* Choose the signature format for a PK algorithm *
-*************************************************/
-void Config::choose_sig_format(const std::string& algo_name,
- std::string& padding,
- Signature_Format& format)
- {
- if(algo_name == "RSA")
- {
- std::string hash = global_state().config().option("x509/ca/rsa_hash");
-
- if(hash == "")
- throw Invalid_State("No value set for x509/ca/rsa_hash");
-
- hash = global_state().config().deref_alias(hash);
-
- padding = "EMSA3(" + hash + ")";
- format = IEEE_1363;
- }
- else if(algo_name == "DSA")
- {
- std::string hash = global_state().config().deref_alias("SHA-1");
- padding = "EMSA1(" + hash + ")";
- format = DER_SEQUENCE;
- }
- else
- throw Invalid_Argument("Unknown X.509 signing key type: " + algo_name);
- }
-
}
diff --git a/src/x509_ca.cpp b/src/x509_ca.cpp
index 30983d89f..4e873c31f 100644
--- a/src/x509_ca.cpp
+++ b/src/x509_ca.cpp
@@ -11,6 +11,7 @@
#include <botan/lookup.h>
#include <botan/look_pk.h>
#include <botan/numthry.h>
+#include <botan/libstate.h>
#include <botan/oids.h>
#include <botan/util.h>
#include <algorithm>
@@ -236,13 +237,35 @@ PK_Signer* choose_sig_format(const Private_Key& key,
{
std::string padding;
Signature_Format format;
- Config::choose_sig_format(key.algo_name(), padding, format);
- sig_algo.oid = OIDS::lookup(key.algo_name() + "/" + padding);
+ const std::string algo_name = key.algo_name();
+
+ if(algo_name == "RSA")
+ {
+ std::string hash = global_config().option("x509/ca/rsa_hash");
+
+ if(hash == "")
+ throw Invalid_State("No value set for x509/ca/rsa_hash");
+
+ hash = global_config().deref_alias(hash);
+
+ padding = "EMSA3(" + hash + ")";
+ format = IEEE_1363;
+ }
+ else if(algo_name == "DSA")
+ {
+ std::string hash = global_config().deref_alias("SHA-1");
+ padding = "EMSA1(" + hash + ")";
+ format = DER_SEQUENCE;
+ }
+ else
+ throw Invalid_Argument("Unknown X.509 signing key type: " + algo_name);
+
+ sig_algo.oid = OIDS::lookup(algo_name + "/" + padding);
std::auto_ptr<X509_Encoder> encoding(key.x509_encoder());
if(!encoding.get())
- throw Encoding_Error("Key " + key.algo_name() + " does not support "
+ throw Encoding_Error("Key " + algo_name + " does not support "
"X.509 encoding");
sig_algo.parameters = encoding->alg_id().parameters;