Crypto++
8.6
Free C++ class library of cryptographic schemes
|
Go to the documentation of this file.
37 #ifndef CRYPTOPP_XED25519_H
38 #define CRYPTOPP_XED25519_H
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;
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;
373 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
378 return m_oid.
Empty() ? ASN1::Ed25519() : m_oid;
464 void SetPrivateExponent(
const Integer &x);
465 const Integer& GetPrivateExponent()
const;
578 CRYPTOPP_UNUSED(signatureLength);
return 0;
590 CRYPTOPP_UNUSED(messageAccumulator); CRYPTOPP_UNUSED(recoverableMessage);
591 CRYPTOPP_UNUSED(recoverableMessageLength);
592 throw NotImplemented(
"ed25519Signer: this object does not support recoverable messages");
644 return m_oid.
Empty() ? ASN1::Ed25519() : m_oid;
689 bool GetVoidValue(
const char *name,
const std::type_info &valueType,
void *pValue)
const;
694 void SetPublicElement(
const Element &y);
695 const Element& GetPublicElement()
const;
714 CRYPTOPP_CONSTANT(PUBLIC_KEYLENGTH = 32);
715 CRYPTOPP_CONSTANT(SIGNATURE_LENGTH = 64);
771 CRYPTOPP_UNUSED(signatureLength);
return 0;
786 if (signature && signatureLength)
787 std::memcpy(accum.
signature(), signature,
STDMIN((
size_t)SIGNATURE_LENGTH, signatureLength));
801 bool VerifyStream(std::istream& stream,
const byte *signature,
size_t signatureLen)
const;
804 CRYPTOPP_UNUSED(recoveredMessage); CRYPTOPP_UNUSED(messageAccumulator);
805 throw NotImplemented(
"ed25519Verifier: this object does not support recoverable messages");
825 #endif // CRYPTOPP_XED25519_H
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
iterator begin()
Provides an iterator pointing to the first element in the memory block.
Interface for private keys.
DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const
Recover a message from its signature.
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
Decode privateKey part of privateKeyInfo.
ed25519Signer Signer
ed25519 Signer
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
const byte * signature() const
Retrieve pointer to signature buffer.
A method was called which was not implemented.
PublicKey & AccessKey()
Retrieves a reference to a Public Key.
Interface for crypto parameters.
Interface for domains of simple key agreement protocols.
static const int SECRET_KEYLENGTH
Size of the private key.
void Save(BufferedTransformation &bt, bool v1) const
DER encode ASN.1 object.
size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart) const
Sign and restart messageAccumulator.
bool IsSmallOrder(const byte y[PUBLIC_KEYLENGTH]) const
Test if a key has small order.
ed25519 message accumulator
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
ed25519Signer()
Create an ed25519Signer object.
void ClampKey(byte x[SECRET_KEYLENGTH]) const
Clamp a private key.
static const int PUBLIC_KEYLENGTH
Size of the public key.
void Restart()
Reset the accumulator.
ed25519Verifier()
Create an ed25519Verifier object.
bool IsClamped(const byte x[SECRET_KEYLENGTH]) const
Determine if private key is clamped.
void BERDecodeAndCheckAlgorithmID(BufferedTransformation &bt)
Determine if OID is valid for this object.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
void Save(BufferedTransformation &bt, bool v1) const
DER encode ASN.1 object.
bool IsProbabilistic() const
Determines whether a signature scheme requires a random number generator.
OID GetAlgorithmID() const
Get the Object Identifier.
bool RecoverablePartFirst() const
Determines whether the recoverable part must be input before the non-recoverable part.
void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const
Input signature into a message accumulator.
This file contains helper classes/functions for implementing public key algorithms.
Ed25519 signature scheme.
bool AllowNonrecoverablePart() const
Determines whether the non-recoverable message part can be signed.
const PrivateKey & GetPrivateKey() const
Retrieves a reference to a Private Key.
bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const
Derive agreed value.
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
CryptoParameters & AccessCryptoParameters()
Retrieves a reference to Crypto Parameters.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
OID GetAlgorithmID() const
Retrieves the OID of the algorithm.
ed25519_MessageAccumulator(RandomNumberGenerator &rng)
Create a message accumulator.
size_t SignatureLength() const
Provides the signature length if it only depends on the key.
void BERDecodeAndCheckAlgorithmID(BufferedTransformation &bt)
Determine if OID is valid for this object.
Interface for random number generators.
Encodes and Decodes privateKeyInfo.
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
Decode privateKey part of privateKeyInfo.
const PublicKey & GetPublicKey() const
Retrieves a reference to a Public Key.
PrivateKey & AccessKey()
Retrieves a reference to a Private Key.
static const int PUBLIC_KEYLENGTH
Size of the public key.
Interface for public-key signers.
static const int SIGNATURE_LENGTH
Size of the signature.
PrivateKey & AccessPrivateKey()
Retrieves a reference to a Private Key.
Encodes and decodes subjectPublicKeyInfo.
const byte * GetPublicKeyBytePtr() const
Retrieve public key byte array.
static const int SHARED_KEYLENGTH
Size of the shared key.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
bool AllowNonrecoverablePart() const
Determines whether the non-recoverable message part can be signed.
PublicKey & AccessPublicKey()
Retrieves a reference to a Public Key.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
Interface for public keys.
Interface for accumulating messages to be signed or verified.
Returns a decoding results.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
void DEREncodePrivateKey(BufferedTransformation &bt) const
Encode privateKey part of privateKeyInfo.
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
Decode subjectPublicKey part of subjectPublicKeyInfo.
ASN.1 object identifiers for algorithms and schemes.
static const int SIGNATURE_LENGTH
Size of the signature.
void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const
Input a recoverable message to an accumulator.
unsigned int PublicKeyLength() const
Provides the size of the public key.
Ed25519 signature verification algorithm.
size_t SignatureLength() const
Provides the signature length if it only depends on the key.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms)
Generate a random key or crypto parameters.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
size_t MaxRecoverableLength() const
Provides the length of longest message that can be recovered.
bool RecoverablePartFirst() const
Determines whether the recoverable part must be input before the non-recoverable part.
const PublicKey & GetKey() const
Retrieves a reference to a Public Key.
void Update(const byte *msg, size_t len)
Add data to the accumulator.
static const int PUBLIC_KEYLENGTH
Size of the public key.
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.
static const int SECRET_KEYLENGTH
Size of the private key.
const byte * GetPublicKeyBytePtr() const
Retrieve public key byte array.
const byte * GetPrivateKeyBytePtr() const
Retrieve private key byte array.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms)
Generate a random key or crypto parameters.
void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate a public key from a private key in this domain.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Interface for public-key signature verifiers.
PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const
Create a new HashTransformation to accumulate the message to be signed.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
void BERDecodeAndCheckAlgorithmID(BufferedTransformation &bt)
Determine if OID is valid for this object.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
bool VerifyStream(std::istream &stream, const byte *signature, size_t signatureLen) const
Check whether input signature is a valid signature for input message.
static const int SECRET_KEYLENGTH
Size of the private key.
bool IsProbabilistic() const
Determines whether a signature scheme requires a random number generator.
Crypto++ library namespace.
size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const
Provides the length of longest message that can be recovered from a signature of given length.
void DEREncodePrivateKey(BufferedTransformation &bt) const
Encode privateKey part of privateKeyInfo.
Ed25519 signature algorithm.
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
void MakePublicKey(PublicKey &pub) const
Initializes a public key from this key.
const byte * data() const
Retrieve pointer to data buffer.
size_t MaxRecoverableLength() const
Provides the length of longest message that can be recovered.
size_t SignStream(RandomNumberGenerator &rng, std::istream &stream, byte *signature) const
Sign a stream.
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.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
void DEREncodePublicKey(BufferedTransformation &bt) const
Encode subjectPublicKey part of subjectPublicKeyInfo.
void SetAlgorithmID(const OID &oid)
Set the Object Identifier.
const PrivateKey & GetKey() const
Retrieves a reference to a Private Key.
ed25519Verifier Verifier
ed25519 Verifier
ed25519_MessageAccumulator()
Create a message accumulator.
x25519()
Create a x25519 object.
ed25519_MessageAccumulator * NewVerificationAccumulator() const
Create a new HashTransformation to accumulate the message to be verified.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate private key in this domain.
Interface for retrieving values given their names.
Abstract base classes that provide a uniform interface to this library.
bool Empty() const
Determine if OID is empty.
bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const
Check whether messageAccumulator contains a valid signature and message, and restart messageAccumulat...
unsigned int PrivateKeyLength() const
Provides the size of the private key.
OID GetAlgorithmID() const
Retrieves the OID of the algorithm.
size_t size() const
Retrieve size of data buffer.
Multiple precision integer with arithmetic operations.
size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const
Provides the length of longest message that can be recovered from a signature of given length.
byte * signature()
Retrieve pointer to signature buffer.
x25519 with key validation