mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 07:44:13 +00:00
ECDSA P-256 signature
This commit is contained in:
parent
90fe263124
commit
b77325c689
27
Signature.h
27
Signature.h
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <cryptopp/dsa.h>
|
#include <cryptopp/dsa.h>
|
||||||
|
#include <cryptopp/asn.h>
|
||||||
|
#include <cryptopp/oids.h>
|
||||||
|
#include <cryptopp/eccrypto.h>
|
||||||
#include "CryptoConst.h"
|
#include "CryptoConst.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
@ -35,7 +38,29 @@ namespace crypto
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
CryptoPP::DSA::PublicKey m_PublicKey;
|
CryptoPP::DSA::PublicKey m_PublicKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ECDSAP256Verifier: public Verifier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
ECDSAP256Verifier (const uint8_t * signingKey)
|
||||||
|
{
|
||||||
|
m_PublicKey.Initialize (CryptoPP::ASN1::secp256r1(),
|
||||||
|
CryptoPP::ECP::Point (CryptoPP::Integer (signingKey, 32),
|
||||||
|
CryptoPP::Integer (signingKey + 32, 32)));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Verify (const uint8_t * buf, size_t len, const uint8_t * signature)
|
||||||
|
{
|
||||||
|
CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::Verifier verifier (m_PublicKey);
|
||||||
|
return verifier.VerifyMessage (buf, len, signature, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::PublicKey m_PublicKey;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user