mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-30 12:47:48 +02:00
Add tests for EdDSA25519, fix Verifier.
This commit is contained in:
parent
99b2ca860d
commit
eabf434a48
5 changed files with 108 additions and 5 deletions
|
@ -14,7 +14,7 @@ EDDSA25519Verifier::EDDSA25519Verifier(const uint8_t* signingKey)
|
|||
|
||||
bool EDDSA25519Verifier::Verify(const uint8_t* buf, size_t len, const uint8_t* signature) const
|
||||
{
|
||||
return ed25519_ref10_open(signature, buf, len, m_PublicKey) > 0;
|
||||
return ed25519_ref10_open(signature, buf, len, m_PublicKey) >= 0;
|
||||
}
|
||||
|
||||
size_t EDDSA25519Verifier::GetPublicKeyLen() const
|
||||
|
@ -35,7 +35,7 @@ EDDSA25519Signer::EDDSA25519Signer(const uint8_t* signingPrivateKey)
|
|||
ed25519_ref10_pubkey(m_PublicKey, m_PrivateKey);
|
||||
}
|
||||
|
||||
void EDDSA25519Signer::Sign(CryptoPP::RandomNumberGenerator& rnd, const uint8_t* buf, int len, uint8_t* signature) const
|
||||
void EDDSA25519Signer::Sign(CryptoPP::RandomNumberGenerator&, const uint8_t* buf, int len, uint8_t* signature) const
|
||||
{
|
||||
ed25519_ref10_sign(signature, buf, len, m_PrivateKey, m_PublicKey);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
* @todo do not pass random number generator, EdDSA does not require a random
|
||||
* source
|
||||
*/
|
||||
void Sign(CryptoPP::RandomNumberGenerator& rnd, const uint8_t* buf, int len, uint8_t* signature) const;
|
||||
void Sign(CryptoPP::RandomNumberGenerator&, const uint8_t* buf, int len, uint8_t* signature) const;
|
||||
|
||||
uint8_t m_PrivateKey[EDDSA25519_PRIVATE_KEY_LENGTH];
|
||||
uint8_t m_PublicKey[EDDSA25519_PUBLIC_KEY_LENGTH];
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#include <cstring>
|
||||
|
||||
#define crypto_verify_32(a,b) (std::memcmp((a), (b), 32) == 0)
|
||||
#define crypto_verify_32(a,b) (!!std::memcmp((a), (b), 32))
|
||||
|
|
|
@ -33,7 +33,6 @@ int crypto_sign_open(
|
|||
ge_tobytes(rcheck,&R);
|
||||
if (crypto_verify_32(rcheck,rcopy) == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
badsig:
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue