37 #ifndef CRYPTOPP_XED25519_H 38 #define CRYPTOPP_XED25519_H 132 return m_oid.Empty() ? ASN1::X25519() : m_oid;
143 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
236 bool Agree(byte *agreedValue,
const byte *privateKey,
const byte *otherPublicKey,
bool validateOtherPublicKey=
true)
const;
273 CRYPTOPP_CONSTANT(RESERVE_SIZE=2048+64)
274 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH=64)
285 CRYPTOPP_UNUSED(rng);
Restart();
291 void Update(
const byte* msg,
size_t len) {
293 m_msg.insert(m_msg.end(), msg, msg+len);
298 m_msg.reserve(RESERVE_SIZE);
299 m_msg.resize(SIGNATURE_LENGTH);
317 return &m_msg[0]+SIGNATURE_LENGTH;
323 return m_msg.size()-SIGNATURE_LENGTH;
328 std::vector<byte, AllocatorWithCleanup<byte> > m_msg;
364 bool GetVoidValue(const
char *name, const
std::type_info &valueType,
void *pValue) const;
369 return m_oid.Empty() ? ASN1::Ed25519() : m_oid;
455 void SetPrivateExponent(
const Integer &x);
456 const Integer& GetPrivateExponent()
const;
562 CRYPTOPP_UNUSED(signatureLength);
return 0;
574 CRYPTOPP_UNUSED(messageAccumulator); CRYPTOPP_UNUSED(recoverableMessage);
575 CRYPTOPP_UNUSED(recoverableMessageLength);
576 throw NotImplemented(
"ed25519Signer: this object does not support recoverable messages");
626 return m_oid.Empty() ? ASN1::Ed25519() : m_oid;
671 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
676 void SetPublicElement(
const Element &y);
677 const Element& GetPublicElement()
const;
696 CRYPTOPP_CONSTANT(PUBLIC_KEYLENGTH = 32)
697 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH = 64)
746 CRYPTOPP_UNUSED(signatureLength);
return 0;
761 if (signature && signatureLength)
762 std::memcpy(accum.
signature(), signature,
STDMIN((
size_t)SIGNATURE_LENGTH, signatureLength));
776 bool VerifyStream(std::istream& stream,
const byte *signature,
size_t signatureLen)
const;
779 CRYPTOPP_UNUSED(recoveredMessage); CRYPTOPP_UNUSED(messageAccumulator);
780 throw NotImplemented(
"ed25519Verifier: this object does not support recoverable messages");
800 #endif // CRYPTOPP_XED25519_H x25519 with key validation
static const int SECRET_KEYLENGTH
Size of the private key.
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.
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.
bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const
Check whether messageAccumulator contains a valid signature and message, and restart messageAccumulat...
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.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
size_t MaxRecoverableLength() const
Provides the length of longest message that can be recovered.
const byte * GetPublicKeyBytePtr() const
Retrieve public key byte array.
static const int SIGNATURE_LENGTH
Size of the siganture.
Encodes and Decodes privateKeyInfo.
Ed25519 signature verification algorithm.
PublicKey & AccessKey()
Retrieves a reference to a Public Key.
Interface for public-key signers.
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
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.
void MakePublicKey(PublicKey &pub) const
Initializes a public key from this key.
ed25519Verifier()
Create a ed25519Verifier object.
static const int SECRET_KEYLENGTH
Size of the private key.
ed25519Signer Signer
ed25519 Signer
void DEREncodePublicKey(BufferedTransformation &bt) const
encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
Interface for private keys.
OID GetAlgorithmID() const
Retrieves the OID of the algorithm.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
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.
size_t SignStream(RandomNumberGenerator &rng, std::istream &stream, byte *signature) const
Sign a stream.
static const int PUBLIC_KEYLENGTH
Size of the public key.
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 BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
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 BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
void SetAlgorithmID(const OID &oid)
Set the Object Identifier.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
static const int PUBLIC_KEYLENGTH
Size of the public key.
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.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
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, without the OCTET STRING header
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.
static const int SECRET_KEYLENGTH
Size of the private key.
ed25519 message accumulator
iterator begin()
Provides an iterator pointing to the first element in the memory block.
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.
size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart) const
Sign and restart messageAccumulator.
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.
x25519(const byte y[PUBLIC_KEYLENGTH], const byte x[SECRET_KEYLENGTH])
Create a x25519 object.
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...
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
void BERDecodeAndCheckAlgorithmID(BufferedTransformation &bt)
Determine if OID is valid for this object.
bool IsSmallOrder(const byte y[PUBLIC_KEYLENGTH]) const
Test if a key has small order.
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.
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
decode privateKey part of privateKeyInfo, without the OCTET STRING header
const byte * GetPrivateKeyBytePtr() const
Retrieve private key byte array.
virtual void BEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms)
Generate a random key or crypto parameters.
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
OID GetAlgorithmID() const
Retrieves the OID of the algorithm.
static const int SIGNATURE_LENGTH
Size of the siganture.
Ed25519 signature scheme.
bool VerifyStream(std::istream &stream, const byte *signature, size_t signatureLen) const
Check whether input signature is a valid signature for input message.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
void DEREncodePrivateKey(BufferedTransformation &bt) const
encode privateKey part of privateKeyInfo, without the OCTET STRING header
static const int PUBLIC_KEYLENGTH
Size of the public key.
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, without the OCTET STRING header
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.
void BERDecodeAndCheckAlgorithmID(BufferedTransformation &bt)
Determine if OID is valid for this object.