Browse Source

added RSA verifier

pull/115/head
orignal 10 years ago
parent
commit
7ccb7f05bf
  1. 3
      Identity.h
  2. 33
      Signature.h

3
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_SHA256_P256 = 1;
const uint16_t SIGNING_KEY_TYPE_ECDSA_SHA384_P384 = 2; 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_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 SigningKeyType;
typedef uint16_t CryptoKeyType; typedef uint16_t CryptoKeyType;

33
Signature.h

@ -3,6 +3,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <cryptopp/dsa.h> #include <cryptopp/dsa.h>
#include <cryptopp/rsa.h>
#include <cryptopp/asn.h> #include <cryptopp/asn.h>
#include <cryptopp/oids.h> #include <cryptopp/oids.h>
#include <cryptopp/osrng.h> #include <cryptopp/osrng.h>
@ -231,6 +232,38 @@ namespace crypto
CreateECDSARandomKeys<CryptoPP::SHA512> (rnd, CryptoPP::ASN1::secp521r1(), ECDSAP521_KEY_LENGTH, signingPrivateKey, signingPublicKey); CreateECDSARandomKeys<CryptoPP::SHA512> (rnd, CryptoPP::ASN1::secp521r1(), ECDSAP521_KEY_LENGTH, signingPrivateKey, signingPublicKey);
} }
// RSA
template<typename Hash, size_t keyLength>
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<CryptoPP::PKCS1v15, Hash>::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<CryptoPP::SHA256, RSASHA2562048_KEY_LENGTH>
{
public:
RSASHA2562048Verifier (const uint8_t * signingKey): RSAVerifier (signingKey) {};
};
} }
} }

Loading…
Cancel
Save