Fix merge conflicts

pull/806/head
Jeffrey Walton 2019-02-12 19:34:20 -05:00
commit a1b3d31c11
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 33 additions and 17 deletions

View File

@ -50,6 +50,7 @@ public:
unsigned int DigestSize() const {return DIGESTSIZE;} unsigned int DigestSize() const {return DIGESTSIZE;}
void TruncatedFinal(byte *hash, size_t size); void TruncatedFinal(byte *hash, size_t size);
CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";} CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";}
std::string AlgorithmProvider() const {return Panama<B>::AlgorithmProvider();} // Fix https://github.com/weidai11/cryptopp/issues/801
protected: protected:
void Init() {Panama<B>::Reset();} void Init() {Panama<B>::Reset();}

View File

@ -1,8 +1,8 @@
// xed25519.h - written and placed in public domain by Jeffrey Walton // xed25519.h - written and placed in public domain by Jeffrey Walton
// Crypto++ specific implementation wrapped around Andrew // Crypto++ specific implementation wrapped around Andrew
// Moon's public domain curve25519-donna and ed25519-donna, // Moon's public domain curve25519-donna and ed25519-donna,
// https://github.com/floodyberry/curve25519-donna and // http://github.com/floodyberry/curve25519-donna and
// https://github.com/floodyberry/ed25519-donna. // http://github.com/floodyberry/ed25519-donna.
// Typically the key agreement classes encapsulate their data more // Typically the key agreement classes encapsulate their data more
// than x25519 does below. They are a little more accessible // than x25519 does below. They are a little more accessible
@ -23,15 +23,15 @@
/// clamed with 248. That is my_arr[0] &= 248 to mask the lower 3 bits. /// clamed with 248. That is my_arr[0] &= 248 to mask the lower 3 bits.
/// \details PKCS8 and X509 keys encoded using ASN.1 follow little endian /// \details PKCS8 and X509 keys encoded using ASN.1 follow little endian
/// arrays. The format is specified in <A HREF= /// arrays. The format is specified in <A HREF=
/// "https:///tools.ietf.org/html/draft-ietf-curdle-pkix">draft-ietf-curdle-pkix</A>. /// "http:///tools.ietf.org/html/draft-ietf-curdle-pkix">draft-ietf-curdle-pkix</A>.
/// \details If you have a little endian array and you want to wrap it in /// \details If you have a little endian array and you want to wrap it in
/// an Integer using big endian then you can perform the following: /// an Integer using big endian then you can perform the following:
/// <pre>Integer x(my_arr, SECRET_KEYLENGTH, UNSIGNED, LITTLE_ENDIAN_ORDER);</pre> /// <pre>Integer x(my_arr, SECRET_KEYLENGTH, UNSIGNED, LITTLE_ENDIAN_ORDER);</pre>
/// \sa Andrew Moon's x22519 GitHub <A /// \sa Andrew Moon's x22519 GitHub <A
/// HREF="https://github.com/floodyberry/curve25519-donna">curve25519-donna</A>, /// HREF="http://github.com/floodyberry/curve25519-donna">curve25519-donna</A>,
/// ed22519 GitHub <A /// ed22519 GitHub <A
/// HREF="https://github.com/floodyberry/ed25519-donna">ed25519-donna</A>, and /// HREF="http://github.com/floodyberry/ed25519-donna">ed25519-donna</A>, and
/// <A HREF="https:///tools.ietf.org/html/draft-ietf-curdle-pkix">draft-ietf-curdle-pkix</A> /// <A HREF="http:///tools.ietf.org/html/draft-ietf-curdle-pkix">draft-ietf-curdle-pkix</A>
/// \since Crypto++ 8.0 /// \since Crypto++ 8.0
#ifndef CRYPTOPP_XED25519_H #ifndef CRYPTOPP_XED25519_H
@ -155,7 +155,7 @@ public:
/// The default private key format is RFC 5208, which is the old format. /// The default private key format is RFC 5208, which is the old format.
/// The old format provides the best interop, and keys will work /// The old format provides the best interop, and keys will work
/// with OpenSSL. /// with OpenSSL.
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Save(BufferedTransformation &bt) const { void Save(BufferedTransformation &bt) const {
DEREncode(bt, 0); DEREncode(bt, 0);
@ -174,7 +174,7 @@ public:
/// the best interop, and keys will work with OpenSSL. The other /// the best interop, and keys will work with OpenSSL. The other
/// option uses INTEGER 1. INTEGER 1 means RFC 5958 format, /// option uses INTEGER 1. INTEGER 1 means RFC 5958 format,
/// which is the new format. /// which is the new format.
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Save(BufferedTransformation &bt, bool v1) const { void Save(BufferedTransformation &bt, bool v1) const {
DEREncode(bt, v1 ? 0 : 1); DEREncode(bt, v1 ? 0 : 1);
@ -182,7 +182,7 @@ public:
/// \brief BER decode ASN.1 object /// \brief BER decode ASN.1 object
/// \param bt BufferedTransformation object /// \param bt BufferedTransformation object
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Load(BufferedTransformation &bt) { void Load(BufferedTransformation &bt) {
BERDecode(bt); BERDecode(bt);
@ -378,7 +378,7 @@ struct ed25519PrivateKey : public PKCS8PrivateKey
/// The default private key format is RFC 5208, which is the old format. /// The default private key format is RFC 5208, which is the old format.
/// The old format provides the best interop, and keys will work /// The old format provides the best interop, and keys will work
/// with OpenSSL. /// with OpenSSL.
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Save(BufferedTransformation &bt) const { void Save(BufferedTransformation &bt) const {
DEREncode(bt, 0); DEREncode(bt, 0);
@ -397,7 +397,7 @@ struct ed25519PrivateKey : public PKCS8PrivateKey
/// the best interop, and keys will work with OpenSSL. The other /// the best interop, and keys will work with OpenSSL. The other
/// option uses INTEGER 1. INTEGER 1 means RFC 5958 format, /// option uses INTEGER 1. INTEGER 1 means RFC 5958 format,
/// which is the new format. /// which is the new format.
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Save(BufferedTransformation &bt, bool v1) const { void Save(BufferedTransformation &bt, bool v1) const {
DEREncode(bt, v1 ? 0 : 1); DEREncode(bt, v1 ? 0 : 1);
@ -405,7 +405,7 @@ struct ed25519PrivateKey : public PKCS8PrivateKey
/// \brief BER decode ASN.1 object /// \brief BER decode ASN.1 object
/// \param bt BufferedTransformation object /// \param bt BufferedTransformation object
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Load(BufferedTransformation &bt) { void Load(BufferedTransformation &bt) {
BERDecode(bt); BERDecode(bt);
@ -545,9 +545,13 @@ struct ed25519Signer : public PK_Signer
ed25519Signer(BufferedTransformation &params); ed25519Signer(BufferedTransformation &params);
// DL_ObjectImplBase // DL_ObjectImplBase
/// \brief Retrieves a reference to a Private Key
/// \details AccessKey() retrieves a non-const reference to a private key.
PrivateKey& AccessKey() { return m_key; } PrivateKey& AccessKey() { return m_key; }
PrivateKey& AccessPrivateKey() { return m_key; } PrivateKey& AccessPrivateKey() { return m_key; }
/// \brief Retrieves a reference to a Private Key
/// \details AccessKey() retrieves a const reference to a private key.
const PrivateKey& GetKey() const { return m_key; } const PrivateKey& GetKey() const { return m_key; }
const PrivateKey& GetPrivateKey() const { return m_key; } const PrivateKey& GetPrivateKey() const { return m_key; }
@ -579,11 +583,13 @@ struct ed25519Signer : public PK_Signer
/// \param stream an std::istream derived class /// \param stream an std::istream derived class
/// \param signature a block of bytes for the signature /// \param signature a block of bytes for the signature
/// \return actual signature length /// \return actual signature length
/// \details SignStream() handles large streams. It was added for signing and verifying /// \details SignStream() handles large streams. The Stream functions were added to
/// files that are too large for a memory allocation. /// ed25519 for signing and verifying files that are too large for a memory allocation.
/// The functions are not present in other library signers and verifiers.
/// \details ed25519 is a determinsitic signature scheme. <tt>IsProbabilistic()</tt> /// \details ed25519 is a determinsitic signature scheme. <tt>IsProbabilistic()</tt>
/// returns false and the random number generator can be <tt>NullRNG()</tt>. /// returns false and the random number generator can be <tt>NullRNG()</tt>.
/// \pre <tt>COUNTOF(signature) == MaxSignatureLength()</tt> /// \pre <tt>COUNTOF(signature) == MaxSignatureLength()</tt>
/// \since Crypto++ 8.1
size_t SignStream (RandomNumberGenerator &rng, std::istream& stream, byte *signature) const; size_t SignStream (RandomNumberGenerator &rng, std::istream& stream, byte *signature) const;
protected: protected:
@ -635,7 +641,7 @@ struct ed25519PublicKey : public X509PublicKey
/// \brief BER decode ASN.1 object /// \brief BER decode ASN.1 object
/// \param bt BufferedTransformation object /// \param bt BufferedTransformation object
/// \sa <A HREF="https://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric /// \sa <A HREF="http://tools.ietf.org/rfc/rfc5958.txt">RFC 5958, Asymmetric
/// Key Packages</A> /// Key Packages</A>
void Load(BufferedTransformation &bt) { void Load(BufferedTransformation &bt) {
BERDecode(bt); BERDecode(bt);
@ -723,9 +729,13 @@ struct ed25519Verifier : public PK_Verifier
ed25519Verifier(const ed25519Signer& signer); ed25519Verifier(const ed25519Signer& signer);
// DL_ObjectImplBase // DL_ObjectImplBase
/// \brief Retrieves a reference to a Public Key
/// \details AccessKey() retrieves a non-const reference to a public key.
PublicKey& AccessKey() { return m_key; } PublicKey& AccessKey() { return m_key; }
PublicKey& AccessPublicKey() { return m_key; } PublicKey& AccessPublicKey() { return m_key; }
/// \brief Retrieves a reference to a Public Key
/// \details GetKey() retrieves a const reference to a public key.
const PublicKey& GetKey() const { return m_key; } const PublicKey& GetKey() const { return m_key; }
const PublicKey& GetPublicKey() const { return m_key; } const PublicKey& GetPublicKey() const { return m_key; }
@ -759,8 +769,10 @@ struct ed25519Verifier : public PK_Verifier
/// \param signature a pointer to the signature over the message /// \param signature a pointer to the signature over the message
/// \param signatureLen the size of the signature /// \param signatureLen the size of the signature
/// \return true if the signature is valid, false otherwise /// \return true if the signature is valid, false otherwise
/// \details VerifyStream() handles large streams. It was added for signing and verifying /// \details VerifyStream() handles large streams. The Stream functions were added to
/// files that are too large for a memory allocation. /// ed25519 for signing and verifying files that are too large for a memory allocation.
/// The functions are not present in other library signers and verifiers.
/// \since Crypto++ 8.1
bool VerifyStream(std::istream& stream, const byte *signature, size_t signatureLen) const; bool VerifyStream(std::istream& stream, const byte *signature, size_t signatureLen) const;
DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const { DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const {
@ -773,10 +785,13 @@ protected:
}; };
/// \brief Ed25519 signature scheme /// \brief Ed25519 signature scheme
/// \sa <A HREF="http://cryptopp.com/wiki/Ed25519">Ed25519</A> on the Crypto++ wiki.
/// \since Crypto++ 8.0 /// \since Crypto++ 8.0
struct ed25519 struct ed25519
{ {
/// \brief ed25519 Signer
typedef ed25519Signer Signer; typedef ed25519Signer Signer;
/// \brief ed25519 Verifier
typedef ed25519Verifier Verifier; typedef ed25519Verifier Verifier;
}; };