aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert/cvc/signed_obj.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-03 17:54:25 +0000
committerlloyd <[email protected]>2010-03-03 17:54:25 +0000
commit07c250e5b1acf64ac08096e7f4c883702040c2f0 (patch)
tree01f54c03280eb8c09807913d529c7cec4707c416 /src/cert/cvc/signed_obj.cpp
parent24cef321a2f79907c209f9894c1f486c839c3a7a (diff)
Reorganize where some CVC code goes to avoid template bloat + VC problems
Diffstat (limited to 'src/cert/cvc/signed_obj.cpp')
-rw-r--r--src/cert/cvc/signed_obj.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/cert/cvc/signed_obj.cpp b/src/cert/cvc/signed_obj.cpp
index 022d0fa5f..31a158dd4 100644
--- a/src/cert/cvc/signed_obj.cpp
+++ b/src/cert/cvc/signed_obj.cpp
@@ -1,12 +1,15 @@
/*
* EAC SIGNED Object
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2010 Jack Lloyd
* 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#include <botan/signed_obj.h>
+#include <botan/look_pk.h>
+#include <botan/oids.h>
+#include <memory>
namespace Botan {
@@ -42,6 +45,38 @@ AlgorithmIdentifier EAC_Signed_Object::signature_algorithm() const
return sig_algo;
}
+bool EAC_Signed_Object::check_signature(Public_Key& pub_key,
+ const MemoryRegion<byte>& sig) const
+ {
+ try
+ {
+ std::vector<std::string> sig_info =
+ split_on(OIDS::lookup(sig_algo.oid), '/');
+
+ if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
+ {
+ return false;
+ }
+
+ std::string padding = sig_info[1];
+ Signature_Format format =
+ (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
+
+ if(!dynamic_cast<PK_Verifying_wo_MR_Key*>(&pub_key))
+ return false;
+
+ SecureVector<byte> to_sign = tbs_data();
+
+ PK_Verifying_wo_MR_Key& sig_key = dynamic_cast<PK_Verifying_wo_MR_Key&>(pub_key);
+ std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(sig_key, padding, format));
+ return verifier->verify_message(to_sign, sig);
+ }
+ catch(...)
+ {
+ return false;
+ }
+ }
+
/*
* Try to decode the actual information
*/