From 7ccb7f05bf8d0f7771d1aa6f75b4b9828f7f7cca Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 10 Dec 2014 15:48:07 -0500 Subject: [PATCH] added RSA verifier --- Identity.h | 3 +++ Signature.h | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Identity.h b/Identity.h index 1a245421..e4f8bd59 100644 --- a/Identity.h +++ b/Identity.h @@ -113,6 +113,9 @@ namespace data const uint16_t SIGNING_KEY_TYPE_ECDSA_SHA256_P256 = 1; const uint16_t SIGNING_KEY_TYPE_ECDSA_SHA384_P384 = 2; const uint16_t SIGNING_KEY_TYPE_ECDSA_SHA512_P521 = 3; + const uint16_t SIGNING_KEY_TYPE_RSA_SHA256_2048 = 4; + const uint16_t SIGNING_KEY_TYPE_RSA_SHA384_3072 = 5; + const uint16_t SIGNING_KEY_TYPE_RSA_SHA512_4096 = 6; typedef uint16_t SigningKeyType; typedef uint16_t CryptoKeyType; diff --git a/Signature.h b/Signature.h index 1ea386f9..f998eb86 100644 --- a/Signature.h +++ b/Signature.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -230,7 +231,39 @@ namespace crypto { CreateECDSARandomKeys (rnd, CryptoPP::ASN1::secp521r1(), ECDSAP521_KEY_LENGTH, signingPrivateKey, signingPublicKey); } - + +// RSA + template + class RSAVerifier: public Verifier + { + public: + + RSAVerifier (const uint8_t * signingKey) + { + // TODO + } + + bool Verify (const uint8_t * buf, size_t len, const uint8_t * signature) const + { + typename CryptoPP::RSASS::Verifier verifier (m_PublicKey); + return verifier.VerifyMessage (buf, len, signature, keyLength); // signature length + } + size_t GetPublicKeyLen () const { return keyLength; } + size_t GetSignatureLen () const { return keyLength; } + + private: + + CryptoPP::RSA::PublicKey m_PublicKey; + }; + +// RSA_SHA256_2048 + const size_t RSASHA2562048_KEY_LENGTH =256; + class RSASHA2562048Verifier: public RSAVerifier + { + public: + + RSASHA2562048Verifier (const uint8_t * signingKey): RSAVerifier (signingKey) {}; + }; } }