Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.9 KiB

  1. #ifndef CRYPTOPP_EMSA2_H
  2. #define CRYPTOPP_EMSA2_H
  3. /** \file
  4. This file contains various padding schemes for public key algorithms.
  5. */
  6. #include "cryptlib.h"
  7. #include "pubkey.h"
  8. #ifdef CRYPTOPP_IS_DLL
  9. #include "sha.h"
  10. #endif
  11. NAMESPACE_BEGIN(CryptoPP)
  12. template <class H> class EMSA2HashId
  13. {
  14. public:
  15. static const byte id;
  16. };
  17. template <class BASE>
  18. class EMSA2HashIdLookup : public BASE
  19. {
  20. public:
  21. struct HashIdentifierLookup
  22. {
  23. template <class H> struct HashIdentifierLookup2
  24. {
  25. static HashIdentifier Lookup()
  26. {
  27. return HashIdentifier(&EMSA2HashId<H>::id, 1);
  28. }
  29. };
  30. };
  31. };
  32. // EMSA2HashId can be instantiated with the following classes.
  33. class SHA1;
  34. class RIPEMD160;
  35. class RIPEMD128;
  36. class SHA256;
  37. class SHA384;
  38. class SHA512;
  39. class Whirlpool;
  40. class SHA224;
  41. // end of list
  42. #ifdef CRYPTOPP_IS_DLL
  43. CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
  44. CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
  45. CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
  46. CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
  47. CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
  48. #endif
  49. //! _
  50. class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
  51. {
  52. public:
  53. static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
  54. size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
  55. {return 8*digestLength + 31;}
  56. void ComputeMessageRepresentative(RandomNumberGenerator &rng,
  57. const byte *recoverableMessage, size_t recoverableMessageLength,
  58. HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
  59. byte *representative, size_t representativeBitLength) const;
  60. };
  61. //! EMSA2, for use with RWSS and RSA_ISO
  62. /*! Only the following hash functions are supported by this signature standard:
  63. \dontinclude emsa2.h
  64. \skip EMSA2HashId can be instantiated
  65. \until end of list
  66. */
  67. struct P1363_EMSA2 : public SignatureStandard
  68. {
  69. typedef EMSA2Pad SignatureMessageEncodingMethod;
  70. };
  71. NAMESPACE_END
  72. #endif