dsa.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // dsa.h - originally written and placed in the public domain by Wei Dai
  2. /// \file dsa.h
  3. /// \brief Classes for the DSA signature algorithm
  4. #ifndef CRYPTOPP_DSA_H
  5. #define CRYPTOPP_DSA_H
  6. #include "cryptlib.h"
  7. #include "gfpcrypt.h"
  8. NAMESPACE_BEGIN(CryptoPP)
  9. /// \brief DSA Signature Format
  10. /// \details The DSA signature format used by Crypto++ is as defined by IEEE P1363.
  11. /// OpenSSL, Java and .Net use the DER format, and OpenPGP uses the OpenPGP format.
  12. /// \sa <A HREF="http://www.cryptopp.com/wiki/DSAConvertSignatureFormat">DSAConvertSignatureFormat</A>
  13. /// on the Crypto++ wiki.
  14. /// \since Crypto++ 1.0
  15. enum DSASignatureFormat {
  16. /// \brief Crypto++ native signature encoding format
  17. DSA_P1363,
  18. /// \brief signature encoding format used by OpenSSL, Java and .Net
  19. DSA_DER,
  20. /// \brief OpenPGP signature encoding format
  21. DSA_OPENPGP
  22. };
  23. /// \brief Converts between signature encoding formats
  24. /// \param buffer byte buffer for the converted signature encoding
  25. /// \param bufferSize the length of the converted signature encoding buffer
  26. /// \param toFormat the source signature format
  27. /// \param signature byte buffer for the existing signature encoding
  28. /// \param signatureLen the length of the existing signature encoding buffer
  29. /// \param fromFormat the source signature format
  30. /// \return the number of bytes written during encoding
  31. /// \details This function converts between these formats, and returns length
  32. /// of signature in the target format. If <tt>toFormat == DSA_P1363</tt>, then
  33. /// <tt>bufferSize</tt> must equal <tt>publicKey.SignatureLength()</tt> or
  34. /// <tt>verifier.SignatureLength()</tt>.
  35. /// \details If the destination buffer is too small then the output of the
  36. /// encoded <tt>r</tt> and <tt>s</tt> will be truncated. Be sure to provide
  37. /// an adequately sized buffer and check the return value for the number of
  38. /// bytes written.
  39. /// \sa <A HREF="http://www.cryptopp.com/wiki/DSAConvertSignatureFormat">DSAConvertSignatureFormat</A>
  40. /// on the Crypto++ wiki.
  41. /// \since Crypto++ 1.0
  42. size_t DSAConvertSignatureFormat(byte *buffer, size_t bufferSize, DSASignatureFormat toFormat,
  43. const byte *signature, size_t signatureLen, DSASignatureFormat fromFormat);
  44. NAMESPACE_END
  45. #endif // CRYPTOPP_DSA_H