aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-08 15:36:18 +0000
committerlloyd <[email protected]>2010-03-08 15:36:18 +0000
commit8a47f6f2bbf169a2ea0853234f81b49070c770df (patch)
tree2633ed0d927faf23a067aa88d6cceb9de29f0be4 /src/cert
parent05f6d6c8edec9907778f362c927f368140fee6a2 (diff)
Modify pubkey classes to take names instead of object pointers.
Remove use of look_pk from the source and examples, instead instantiate classes directly.
Diffstat (limited to 'src/cert')
-rw-r--r--src/cert/cvc/cvc_self.cpp26
-rw-r--r--src/cert/cvc/signed_obj.cpp6
-rw-r--r--src/cert/x509/x509_ca.cpp4
-rw-r--r--src/cert/x509/x509_obj.cpp7
-rw-r--r--src/cert/x509/x509self.cpp1
-rw-r--r--src/cert/x509/x509stor.cpp8
6 files changed, 23 insertions, 29 deletions
diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp
index b54b8b4bb..fbd042676 100644
--- a/src/cert/cvc/cvc_self.cpp
+++ b/src/cert/cvc/cvc_self.cpp
@@ -10,7 +10,6 @@
#include <botan/point_gfp.h>
#include <botan/time.h>
#include <botan/oids.h>
-#include <botan/look_pk.h>
#include <sstream>
namespace Botan {
@@ -105,12 +104,11 @@ EAC1_1_CVC create_self_signed_cert(Private_Key const& key,
sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
- std::auto_ptr<Botan::PK_Signer> signer(
- get_pk_signer(*priv_key, padding_and_hash));
+ PK_Signer signer(*priv_key, padding_and_hash);
MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid);
- return make_cvc_cert(*signer,
+ return make_cvc_cert(signer,
enc_public_key,
opt.car, chr,
opt.holder_auth_templ,
@@ -133,7 +131,7 @@ EAC1_1_Req create_cvc_req(Private_Key const& key,
sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
- std::auto_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
+ PK_Signer signer(*priv_key, padding_and_hash);
MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid);
@@ -146,7 +144,7 @@ EAC1_1_Req create_cvc_req(Private_Key const& key,
.get_contents();
MemoryVector<byte> signed_cert =
- EAC1_1_gen_CVC<EAC1_1_Req>::make_signed(*signer,
+ EAC1_1_gen_CVC<EAC1_1_Req>::make_signed(signer,
EAC1_1_gen_CVC<EAC1_1_Req>::build_cert_body(tbs),
rng);
@@ -166,10 +164,10 @@ EAC1_1_ADO create_ado_req(Private_Key const& key,
throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
}
std::string padding_and_hash = padding_and_hash_from_oid(req.signature_algorithm().oid);
- std::auto_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
+ PK_Signer signer(*priv_key, padding_and_hash);
SecureVector<byte> tbs_bits = req.BER_encode();
tbs_bits.append(DER_Encoder().encode(car).get_contents());
- MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(*signer, tbs_bits, rng);
+ MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(signer, tbs_bits, rng);
DataSource_Memory source(signed_cert);
return EAC1_1_ADO(source);
@@ -199,7 +197,7 @@ EAC1_1_CVC create_cvca(Private_Key const& key,
opts.cex.add_months(cvca_validity_months);
opts.holder_auth_templ = (CVCA | (iris * IRIS) | (fingerpr * FINGERPRINT));
opts.hash_alg = hash;
- return Botan::CVC_EAC::create_self_signed_cert(*priv_key, opts, rng);
+ return CVC_EAC::create_self_signed_cert(*priv_key, opts, rng);
}
@@ -230,14 +228,14 @@ EAC1_1_CVC link_cvca(EAC1_1_CVC const& signer,
}
AlgorithmIdentifier sig_algo = signer.signature_algorithm();
std::string padding_and_hash = padding_and_hash_from_oid(sig_algo.oid);
- std::auto_ptr<Botan::PK_Signer> pk_signer(get_pk_signer(*priv_key, padding_and_hash));
+ PK_Signer pk_signer(*priv_key, padding_and_hash);
std::auto_ptr<Public_Key> pk = signee.subject_public_key();
ECDSA_PublicKey* subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get());
subj_pk->set_parameter_encoding(EC_DOMPAR_ENC_EXPLICIT);
MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid);
- return make_cvc_cert(*pk_signer, enc_public_key,
+ return make_cvc_cert(pk_signer, enc_public_key,
signer.get_car(),
signee.get_chr(),
signer.get_chat_value(),
@@ -264,7 +262,7 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
chr_str += to_string(seqnr, seqnr_len);
ASN1_Chr chr(chr_str);
std::string padding_and_hash = padding_and_hash_from_oid(signee.signature_algorithm().oid);
- std::auto_ptr<Botan::PK_Signer> pk_signer(get_pk_signer(*priv_key, padding_and_hash));
+ PK_Signer pk_signer(*priv_key, padding_and_hash);
std::auto_ptr<Public_Key> pk = signee.subject_public_key();
ECDSA_PublicKey* subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get());
std::auto_ptr<Public_Key> signer_pk = signer_cert.subject_public_key();
@@ -304,7 +302,7 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid);
- return make_cvc_cert(*pk_signer, enc_public_key,
+ return make_cvc_cert(pk_signer, enc_public_key,
ASN1_Car(signer_cert.get_chr().iso_8859()),
chr,
chat_val,
@@ -325,7 +323,7 @@ EAC1_1_Req create_cvc_req(Private_Key const& prkey,
}
ECDSA_PrivateKey key(*priv_key);
key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
- return Botan::CVC_EAC::create_cvc_req(key, chr, hash_alg, rng);
+ return CVC_EAC::create_cvc_req(key, chr, hash_alg, rng);
}
} // namespace DE_EAC
diff --git a/src/cert/cvc/signed_obj.cpp b/src/cert/cvc/signed_obj.cpp
index ddb714621..d6aa2f02b 100644
--- a/src/cert/cvc/signed_obj.cpp
+++ b/src/cert/cvc/signed_obj.cpp
@@ -7,7 +7,7 @@
*/
#include <botan/signed_obj.h>
-#include <botan/look_pk.h>
+#include <botan/pubkey.h>
#include <botan/oids.h>
#include <memory>
@@ -64,8 +64,8 @@ bool EAC_Signed_Object::check_signature(Public_Key& pub_key,
SecureVector<byte> to_sign = tbs_data();
- std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(pub_key, padding, format));
- return verifier->verify_message(to_sign, sig);
+ PK_Verifier verifier(pub_key, padding, format);
+ return verifier.verify_message(to_sign, sig);
}
catch(...)
{
diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp
index 00a105d1d..1f3e643e9 100644
--- a/src/cert/x509/x509_ca.cpp
+++ b/src/cert/x509/x509_ca.cpp
@@ -7,12 +7,12 @@
#include <botan/x509_ca.h>
#include <botan/x509stor.h>
+#include <botan/pubkey.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/bigint.h>
#include <botan/parsing.h>
#include <botan/lookup.h>
-#include <botan/look_pk.h>
#include <botan/oids.h>
#include <botan/time.h>
#include <algorithm>
@@ -272,7 +272,7 @@ PK_Signer* choose_sig_format(const Private_Key& key,
sig_algo.oid = OIDS::lookup(algo_name + "/" + padding);
sig_algo.parameters = key.algorithm_identifier().parameters;
- return get_pk_signer(key, padding, format);
+ return new PK_Signer(key, padding, format);
}
}
diff --git a/src/cert/x509/x509_obj.cpp b/src/cert/x509/x509_obj.cpp
index fb92a9cb0..820972614 100644
--- a/src/cert/x509/x509_obj.cpp
+++ b/src/cert/x509/x509_obj.cpp
@@ -7,7 +7,7 @@
#include <botan/x509_obj.h>
#include <botan/x509_key.h>
-#include <botan/look_pk.h>
+#include <botan/pubkey.h>
#include <botan/oids.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
@@ -168,10 +168,9 @@ bool X509_Object::check_signature(Public_Key& pub_key) const
Signature_Format format =
(pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
- std::auto_ptr<PK_Verifier> verifier(
- get_pk_verifier(pub_key, padding, format));
+ PK_Verifier verifier(pub_key, padding, format);
- return verifier->verify_message(tbs_data(), signature());
+ return verifier.verify_message(tbs_data(), signature());
}
catch(...)
{
diff --git a/src/cert/x509/x509self.cpp b/src/cert/x509/x509self.cpp
index e85317462..89b63c8b2 100644
--- a/src/cert/x509/x509self.cpp
+++ b/src/cert/x509/x509self.cpp
@@ -9,7 +9,6 @@
#include <botan/x509_ext.h>
#include <botan/x509_ca.h>
#include <botan/der_enc.h>
-#include <botan/look_pk.h>
#include <botan/oids.h>
#include <botan/pipe.h>
#include <memory>
diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp
index b134817e4..a24d4a070 100644
--- a/src/cert/x509/x509stor.cpp
+++ b/src/cert/x509/x509stor.cpp
@@ -8,7 +8,6 @@
#include <botan/x509stor.h>
#include <botan/parsing.h>
#include <botan/pubkey.h>
-#include <botan/look_pk.h>
#include <botan/oids.h>
#include <botan/time.h>
#include <algorithm>
@@ -394,11 +393,10 @@ X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key)
if(key->message_parts() >= 2) format = DER_SEQUENCE;
else format = IEEE_1363;
- std::auto_ptr<PK_Verifier> verifier(
- get_pk_verifier(*pub_key.get(), padding, format));
+ PK_Verifier verifier(*pub_key.get(), padding, format);
- bool valid = verifier->verify_message(object.tbs_data(),
- object.signature());
+ bool valid = verifier.verify_message(object.tbs_data(),
+ object.signature());
if(valid)
return VERIFIED;