aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-06 06:15:20 +0000
committerlloyd <[email protected]>2006-09-06 06:15:20 +0000
commit219aa8f6b449f7dc81ddae48c4b01328ffe69cd3 (patch)
tree5758eb3c0439d63ed0fa6f1405527bb361045d10
parente5e05aef45ab376c605ecd585aa48efe3b14ddc1 (diff)
Merge a formerly duplicate function (one in an anonymous namespace in
x509self.cpp, the other a block of code in X509_CA's constructor).
-rw-r--r--include/x509_ca.h6
-rw-r--r--src/x509_ca.cpp29
-rw-r--r--src/x509self.cpp18
3 files changed, 25 insertions, 28 deletions
diff --git a/include/x509_ca.h b/include/x509_ca.h
index e1c31b09a..4442601bb 100644
--- a/include/x509_ca.h
+++ b/include/x509_ca.h
@@ -48,6 +48,12 @@ class X509_CA
PK_Signer* signer;
};
+/*************************************************
+* Choose a signing format for the key *
+*************************************************/
+PK_Signer* choose_sig_format(const PKCS8_PrivateKey&, AlgorithmIdentifier&);
+
+
}
#endif
diff --git a/src/x509_ca.cpp b/src/x509_ca.cpp
index 7e556f164..e7a463e18 100644
--- a/src/x509_ca.cpp
+++ b/src/x509_ca.cpp
@@ -33,16 +33,7 @@ X509_CA::X509_CA(const X509_Certificate& c,
if(!cert.is_CA_cert())
throw Invalid_Argument("X509_CA: This certificate is not for a CA");
- std::string padding;
- Signature_Format format;
-
- Config::choose_sig_format(key.algo_name(), padding, format);
-
- ca_sig_algo.oid = OIDS::lookup(key.algo_name() + "/" + padding);
- ca_sig_algo.parameters = key.DER_encode_params();
-
- const PK_Signing_Key& sig_key = dynamic_cast<const PK_Signing_Key&>(key);
- signer = get_pk_signer(sig_key, padding, format);
+ signer = choose_sig_format(key, ca_sig_algo);
}
/*************************************************
@@ -249,4 +240,22 @@ X509_CA::~X509_CA()
delete signer;
}
+/*************************************************
+* Choose a signing format for the key *
+*************************************************/
+PK_Signer* choose_sig_format(const PKCS8_PrivateKey& key,
+ AlgorithmIdentifier& sig_algo)
+ {
+ std::string padding;
+ Signature_Format format;
+ Config::choose_sig_format(key.algo_name(), padding, format);
+
+ sig_algo.oid = OIDS::lookup(key.algo_name() + "/" + padding);
+ sig_algo.parameters = key.DER_encode_params();
+
+ const PK_Signing_Key& sig_key = dynamic_cast<const PK_Signing_Key&>(key);
+
+ return get_pk_signer(sig_key, padding, format);
+ }
+
}
diff --git a/src/x509self.cpp b/src/x509self.cpp
index fadcf0c39..5707c1a58 100644
--- a/src/x509self.cpp
+++ b/src/x509self.cpp
@@ -55,24 +55,6 @@ void load_info(const X509_Cert_Options& opts, X509_DN& subject_dn,
opts.xmpp, UTF8_STRING);
}
-/*************************************************
-* Choose a signing format for the key *
-*************************************************/
-PK_Signer* choose_sig_format(const PKCS8_PrivateKey& key,
- AlgorithmIdentifier& sig_algo)
- {
- std::string padding;
- Signature_Format format;
- Config::choose_sig_format(key.algo_name(), padding, format);
-
- sig_algo.oid = OIDS::lookup(key.algo_name() + "/" + padding);
- sig_algo.parameters = key.DER_encode_params();
-
- const PK_Signing_Key& sig_key = dynamic_cast<const PK_Signing_Key&>(key);
-
- return get_pk_signer(sig_key, padding, format);
- }
-
}
namespace X509 {