From 07c250e5b1acf64ac08096e7f4c883702040c2f0 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 3 Mar 2010 17:54:25 +0000 Subject: Reorganize where some CVC code goes to avoid template bloat + VC problems --- src/cert/cvc/eac_obj.h | 90 +++++++++++--------------------------------------- 1 file changed, 19 insertions(+), 71 deletions(-) (limited to 'src/cert/cvc/eac_obj.h') diff --git a/src/cert/cvc/eac_obj.h b/src/cert/cvc/eac_obj.h index d4f02c530..60da7126e 100644 --- a/src/cert/cvc/eac_obj.h +++ b/src/cert/cvc/eac_obj.h @@ -8,12 +8,8 @@ #ifndef BOTAN_EAC_OBJ_H__ #define BOTAN_EAC_OBJ_H__ -#include #include -#include -#include -#include -#include +#include namespace Botan { @@ -23,84 +19,36 @@ namespace Botan { template // CRTP is used enable the call sequence: class BOTAN_DLL EAC1_1_obj : public EAC_Signed_Object { - // data members first: - protected: - - ECDSA_Signature m_sig; - - // member functions here: public: /** * Return the signature as a concatenation of the encoded parts. * @result the concatenated signature */ - SecureVector get_concat_sig() const; + SecureVector get_concat_sig() const + { return m_sig.get_concatenation(); } - /** - * Verify the signature of this objects. - * @param pub_key the public key to verify the signature with - * @result true if the verification succeeded - */ - virtual bool check_signature(Public_Key& pub_key) const; + bool check_signature(class Public_Key& key) const + { + return EAC_Signed_Object::check_signature(key, m_sig.DER_encode()); + } protected: - void init(DataSource& in); - - virtual ~EAC1_1_obj(){} - - }; - -template -SecureVector EAC1_1_obj::get_concat_sig() const - { - return m_sig.get_concatenation(); - } - -template -void EAC1_1_obj::init(DataSource& in) - { - try - { - Derived::decode_info(in, tbs_bits, m_sig); - } - catch(Decoding_Error) - { - throw Decoding_Error(PEM_label_pref + " decoding failed"); - } - } - -template -bool EAC1_1_obj::check_signature(Public_Key& pub_key) const - { - try - { - std::vector sig_info = - split_on(OIDS::lookup(sig_algo.oid), '/'); + ECDSA_Signature m_sig; - if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name()) + void init(DataSource& in) { - return false; + try + { + Derived::decode_info(in, tbs_bits, m_sig); + } + catch(Decoding_Error) + { + throw Decoding_Error(PEM_label_pref + " decoding failed"); + } } - std::string padding = sig_info[1]; - Signature_Format format = - (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363; - - if(!dynamic_cast(&pub_key)) - return false; - - SecureVector seq_sig = m_sig.DER_encode(); - SecureVector to_sign = tbs_data(); - - PK_Verifying_wo_MR_Key& sig_key = dynamic_cast(pub_key); - std::auto_ptr verifier(get_pk_verifier(sig_key, padding, format)); - return verifier->verify_message(to_sign, seq_sig); - } - catch(...) - { - return false; - } - } + virtual ~EAC1_1_obj(){} + }; } -- cgit v1.2.3