Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:01

0001 // dsa.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file dsa.h

0004 /// \brief Classes for the DSA signature algorithm

0005 
0006 #ifndef CRYPTOPP_DSA_H
0007 #define CRYPTOPP_DSA_H
0008 
0009 #include "cryptlib.h"
0010 #include "gfpcrypt.h"
0011 
0012 NAMESPACE_BEGIN(CryptoPP)
0013 
0014 /// \brief DSA Signature Format

0015 /// \details The DSA signature format used by Crypto++ is as defined by IEEE P1363.

0016 ///  OpenSSL, Java and .Net use the DER format, and OpenPGP uses the OpenPGP format.

0017 /// \sa <A HREF="http://www.cryptopp.com/wiki/DSAConvertSignatureFormat">DSAConvertSignatureFormat</A>

0018 ///  on the Crypto++ wiki.

0019 /// \since Crypto++ 1.0

0020 enum DSASignatureFormat {
0021     /// \brief Crypto++ native signature encoding format

0022     DSA_P1363,
0023     /// \brief signature encoding format used by OpenSSL, Java and .Net

0024     DSA_DER,
0025     /// \brief OpenPGP signature encoding format

0026     DSA_OPENPGP
0027 };
0028 
0029 /// \brief Converts between signature encoding formats

0030 /// \param buffer byte buffer for the converted signature encoding

0031 /// \param bufferSize the length of the converted signature encoding buffer

0032 /// \param toFormat the source signature format

0033 /// \param signature byte buffer for the existing signature encoding

0034 /// \param signatureLen the length of the existing signature encoding buffer

0035 /// \param fromFormat the source signature format

0036 /// \return the number of bytes written during encoding

0037 /// \details This function converts between these formats, and returns length

0038 ///  of signature in the target format. If <tt>toFormat == DSA_P1363</tt>, then

0039 ///  <tt>bufferSize</tt> must equal <tt>publicKey.SignatureLength()</tt> or

0040 ///  <tt>verifier.SignatureLength()</tt>.

0041 /// \details If the destination buffer is too small then the output of the

0042 ///  encoded <tt>r</tt> and <tt>s</tt> will be truncated. Be sure to provide

0043 ///  an adequately sized buffer and check the return value for the number of

0044 ///  bytes written.

0045 /// \sa <A HREF="http://www.cryptopp.com/wiki/DSAConvertSignatureFormat">DSAConvertSignatureFormat</A>

0046 ///  on the Crypto++ wiki.

0047 /// \since Crypto++ 1.0

0048 size_t DSAConvertSignatureFormat(byte *buffer, size_t bufferSize, DSASignatureFormat toFormat,
0049     const byte *signature, size_t signatureLen, DSASignatureFormat fromFormat);
0050 
0051 NAMESPACE_END
0052 
0053 #endif  // CRYPTOPP_DSA_H