mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
added RSA verifier
This commit is contained in:
parent
5b53665f4f
commit
7ccb7f05bf
@ -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
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…
Reference in New Issue
Block a user