aboutsummaryrefslogtreecommitdiffstats
path: root/src/x509_ca.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-04-29 14:39:16 +0000
committerlloyd <[email protected]>2008-04-29 14:39:16 +0000
commitaacaef7d54e997834baf64308b39a102eeb3dd1f (patch)
tree776d423b6b49283c5f9c682c10c548fd6898943c /src/x509_ca.cpp
parentaf8b04c4583dfcad766eeed656650821a9de8675 (diff)
Move Signature_Format enum to pubkey.h
Including enums.h in needed places since asn1_int.h doesn't pull it in anymore. Remove Config::choose_sig_format, and move its logic into its only caller, the (global!) choose_sig_format in x509_ca.cpp
Diffstat (limited to 'src/x509_ca.cpp')
-rw-r--r--src/x509_ca.cpp29
1 files changed, 26 insertions, 3 deletions
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;