37 #ifndef CRYPTOPP_XED25519_H 38 #define CRYPTOPP_XED25519_H 87 x25519(
const byte x[SECRET_KEYLENGTH]);
124 void ClampKey(byte x[SECRET_KEYLENGTH])
const;
128 bool IsClamped(
const byte x[SECRET_KEYLENGTH])
const;
132 bool IsSmallOrder(
const byte y[PUBLIC_KEYLENGTH])
const;
139 return m_oid.
Empty() ? ASN1::X25519() : m_oid;
150 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
243 bool Agree(byte *agreedValue,
const byte *privateKey,
const byte *otherPublicKey,
bool validateOtherPublicKey=
true)
const;
247 void SecretToPublicKey(byte y[PUBLIC_KEYLENGTH],
const byte x[SECRET_KEYLENGTH])
const;
280 CRYPTOPP_CONSTANT(RESERVE_SIZE=2048+64);
281 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH=64);
292 CRYPTOPP_UNUSED(rng); Restart();
298 void Update(
const byte* msg,
size_t len) {
300 m_msg.insert(m_msg.end(), msg, msg+len);
305 m_msg.reserve(RESERVE_SIZE);
306 m_msg.resize(SIGNATURE_LENGTH);
324 return &m_msg[0]+SIGNATURE_LENGTH;
330 return m_msg.size()-SIGNATURE_LENGTH;
335 std::vector<byte, AllocatorWithCleanup<byte> > m_msg;
367 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH = 64);
371 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
376 return m_oid.
Empty() ? ASN1::Ed25519() : m_oid;
423 void MakePublicKey(
PublicKey &pub)
const;
462 void SetPrivateExponent(
const Integer &x);
463 const Integer& GetPrivateExponent()
const;
485 void SecretToPublicKey(byte y[PUBLIC_KEYLENGTH],
const byte x[SECRET_KEYLENGTH])
const;
508 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH = 64);
569 CRYPTOPP_UNUSED(signatureLength);
return 0;
581 CRYPTOPP_UNUSED(messageAccumulator); CRYPTOPP_UNUSED(recoverableMessage);
582 CRYPTOPP_UNUSED(recoverableMessageLength);
583 throw NotImplemented(
"ed25519Signer: this object does not support recoverable messages");
633 return m_oid.
Empty() ? ASN1::Ed25519() : m_oid;
678 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
683 void SetPublicElement(
const Element &y);
684 const Element& GetPublicElement()
const;
704 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH = 64);
753 CRYPTOPP_UNUSED(signatureLength);
return 0;
768 if (signature && signatureLength)
769 std::memcpy(accum.
signature(), signature,
STDMIN((
size_t)SIGNATURE_LENGTH, signatureLength));
783 bool VerifyStream(std::istream& stream,
const byte *signature,
size_t signatureLen)
const;
786 CRYPTOPP_UNUSED(recoveredMessage); CRYPTOPP_UNUSED(messageAccumulator);
787 throw NotImplemented(
"ed25519Verifier: this object does not support recoverable messages");
807 #endif // CRYPTOPP_XED25519_H x25519 with key validation
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
static const int SHARED_KEYLENGTH
Size of the shared key.
unsigned int PublicKeyLength() const
Provides the size of the public key.
void Save(BufferedTransformation &bt, bool v1) const
DER encode ASN.1 object.
x25519()
Create a x25519 object.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms)
Generate a random key or crypto parameters.
bool IsProbabilistic() const
Determines whether a signature scheme requires a random number generator.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const
Recover a message from its signature.
This file contains helper classes/functions for implementing public key algorithms.
size_t MaxRecoverableLength() const
Provides the length of longest message that can be recovered.
const byte * GetPublicKeyBytePtr() const
Retrieve public key byte array.
Encodes and Decodes privateKeyInfo.
Ed25519 signature verification algorithm.
PublicKey & AccessKey()
Retrieves a reference to a Public Key.
Interface for public-key signers.
Abstract base classes that provide a uniform interface to this library.
void Update(const byte *msg, size_t len)
Add data to the accumulator.
bool AllowNonrecoverablePart() const
Determines whether the non-recoverable message part can be signed.
ASN.1 object identifiers for algorthms and schemes.
bool IsProbabilistic() const
Determines whether a signature scheme requires a random number generator.
bool AllowNonrecoverablePart() const
Determines whether the non-recoverable message part can be signed.
void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const
Input signature into a message accumulator.
void Restart()
Reset the accumulator.
size_t size() const
Retrieve size of data buffer.
void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate a public key from a private key in this domain.
PrivateKey & AccessKey()
Retrieves a reference to a Private Key.
Interface for random number generators.
ed25519Verifier()
Create a ed25519Verifier object.
static const int SECRET_KEYLENGTH
Size of the private key.
ed25519Signer Signer
ed25519 Signer
Interface for private keys.
OID GetAlgorithmID() const
Retrieves the OID of the algorithm.
size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const
Provides the length of longest message that can be recovered from a signature of given length...
PublicKey & AccessPublicKey()
Retrieves a reference to a Public Key.
const PublicKey & GetPublicKey() const
Retrieves a reference to a Public Key.
bool Empty() const
Determine if OID is empty.
Interface for domains of simple key agreement protocols.
const byte * signature() const
Retrieve pointer to signature buffer.
Returns a decoding results.
void ClampKey(byte x[SECRET_KEYLENGTH]) const
Clamp a private key.
void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate private key in this domain.
const byte * data() const
Retrieve pointer to data buffer.
A method was called which was not implemented.
void SetAlgorithmID(const OID &oid)
Set the Object Identifier.
bool RecoverablePartFirst() const
Determines whether the recoverable part must be input before the non-recoverable part.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
static const int PUBLIC_KEYLENGTH
Size of the public key.
unsigned int PrivateKeyLength() const
Provides the size of the private key.
const PublicKey & GetKey() const
Retrieves a reference to a Public Key.
Multiple precision integer with arithmetic operations.
size_t SignatureLength() const
Provides the signature length if it only depends on the key.
const PrivateKey & GetPrivateKey() const
Retrieves a reference to a Private Key.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const
Input a recoverable message to an accumulator.
bool RecoverablePartFirst() const
Determines whether the recoverable part must be input before the non-recoverable part.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const
Create a new HashTransformation to accumulate the message to be signed.
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
Decode privateKey part of privateKeyInfo.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
void Save(BufferedTransformation &bt, bool v1) const
DER encode ASN.1 object.
ed25519 message accumulator
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
Ed25519 signature algorithm.
Interface for accumulating messages to be signed or verified.
ed25519_MessageAccumulator(RandomNumberGenerator &rng)
Create a message accumulator.
ed25519Verifier Verifier
ed25519 Verifier
bool IsClamped(const byte x[SECRET_KEYLENGTH]) const
Determine if private key is clamped.
const PrivateKey & GetKey() const
Retrieves a reference to a Private Key.
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
bool IsSmallOrder(const byte y[PUBLIC_KEYLENGTH]) const
Test if a key has small order.
Interface for public-key signature verifiers.
CryptoParameters & AccessCryptoParameters()
Retrieves a reference to Crypto Parameters.
OID GetAlgorithmID() const
Get the Object Identifier.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
size_t MaxRecoverableLength() const
Provides the length of longest message that can be recovered.
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
PrivateKey & AccessPrivateKey()
Retrieves a reference to a Private Key.
Interface for crypto prameters.
size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const
Provides the length of longest message that can be recovered from a signature of given length...
Interface for public keys.
Crypto++ library namespace.
Encodes and decodes subjectPublicKeyInfo.
bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const
Derive agreed value.
ed25519Signer()
Create a ed25519Signer object.
const byte * GetPrivateKeyBytePtr() const
Retrieve private key byte array.
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
OID GetAlgorithmID() const
Retrieves the OID of the algorithm.
Ed25519 signature scheme.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
ed25519_MessageAccumulator()
Create a message accumulator.
void BERDecodeAndCheckAlgorithmID(BufferedTransformation &bt)
Determine if OID is valid for this object.
size_t SignatureLength() const
Provides the signature length if it only depends on the key.
void DEREncodePrivateKey(BufferedTransformation &bt) const
Encode privateKey part of privateKeyInfo.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
const byte * GetPublicKeyBytePtr() const
Retrieve public key byte array.
ed25519_MessageAccumulator * NewVerificationAccumulator() const
Create a new HashTransformation to accumulate the message to be verified.
byte * signature()
Retrieve pointer to signature buffer.
Interface for retrieving values given their names.