2017-01-27 12:05:45 +00:00
|
|
|
// dsa.h - originally written and placed in the public domain by Wei Dai
|
2015-11-18 20:32:28 +00:00
|
|
|
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \file dsa.h
|
|
|
|
/// \brief Classes for the DSA signature algorithm
|
2015-11-18 20:32:28 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
#ifndef CRYPTOPP_DSA_H
|
|
|
|
#define CRYPTOPP_DSA_H
|
|
|
|
|
|
|
|
#include "cryptlib.h"
|
2015-11-19 18:09:33 +00:00
|
|
|
#include "gfpcrypt.h"
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
NAMESPACE_BEGIN(CryptoPP)
|
|
|
|
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \brief DSA Signature Format
|
|
|
|
/// \details The DSA signature format used by Crypto++ is as defined by IEEE P1363.
|
2019-09-26 15:57:08 +00:00
|
|
|
/// OpenSSL, Java and .Net use the DER format, and OpenPGP uses the OpenPGP format.
|
|
|
|
/// \sa <A HREF="http://www.cryptopp.com/wiki/DSAConvertSignatureFormat">DSAConvertSignatureFormat</A>
|
|
|
|
/// on the Crypto++ wiki.
|
|
|
|
/// \since Crypto++ 1.0
|
2015-11-19 18:09:33 +00:00
|
|
|
enum DSASignatureFormat {
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \brief Crypto++ native signature encoding format
|
2015-11-19 18:09:33 +00:00
|
|
|
DSA_P1363,
|
2019-09-26 15:57:08 +00:00
|
|
|
/// \brief signature encoding format used by OpenSSL, Java and .Net
|
2015-11-19 18:09:33 +00:00
|
|
|
DSA_DER,
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \brief OpenPGP signature encoding format
|
2015-11-19 18:09:33 +00:00
|
|
|
DSA_OPENPGP
|
|
|
|
};
|
|
|
|
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \brief Converts between signature encoding formats
|
|
|
|
/// \param buffer byte buffer for the converted signature encoding
|
|
|
|
/// \param bufferSize the length of the converted signature encoding buffer
|
|
|
|
/// \param toFormat the source signature format
|
|
|
|
/// \param signature byte buffer for the existing signature encoding
|
|
|
|
/// \param signatureLen the length of the existing signature encoding buffer
|
|
|
|
/// \param fromFormat the source signature format
|
2020-12-08 05:15:19 +00:00
|
|
|
/// \return the number of bytes written during encoding
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \details This function converts between these formats, and returns length
|
2019-09-26 15:57:08 +00:00
|
|
|
/// of signature in the target format. If <tt>toFormat == DSA_P1363</tt>, then
|
2019-10-08 00:07:32 +00:00
|
|
|
/// <tt>bufferSize</tt> must equal <tt>publicKey.SignatureLength()</tt> or
|
|
|
|
/// <tt>verifier.SignatureLength()</tt>.
|
2020-12-08 05:15:19 +00:00
|
|
|
/// \details If the destination buffer is too small then the output of the
|
|
|
|
/// encoded <tt>r</tt> and <tt>s</tt> will be truncated. Be sure to provide
|
|
|
|
/// an adequately sized buffer and check the return value for the number of
|
|
|
|
/// bytes written.
|
2019-09-26 15:57:08 +00:00
|
|
|
/// \sa <A HREF="http://www.cryptopp.com/wiki/DSAConvertSignatureFormat">DSAConvertSignatureFormat</A>
|
|
|
|
/// on the Crypto++ wiki.
|
2017-11-29 15:54:33 +00:00
|
|
|
/// \since Crypto++ 1.0
|
2016-09-10 08:57:48 +00:00
|
|
|
size_t DSAConvertSignatureFormat(byte *buffer, size_t bufferSize, DSASignatureFormat toFormat,
|
2015-11-05 06:59:46 +00:00
|
|
|
const byte *signature, size_t signatureLen, DSASignatureFormat fromFormat);
|
|
|
|
|
|
|
|
NAMESPACE_END
|
|
|
|
|
2019-09-26 15:57:08 +00:00
|
|
|
#endif // CRYPTOPP_DSA_H
|