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.

94 lines
2.8 KiB

  1. #ifndef CRYPTOPP_PKCSPAD_H
  2. #define CRYPTOPP_PKCSPAD_H
  3. #include "cryptlib.h"
  4. #include "pubkey.h"
  5. #ifdef CRYPTOPP_IS_DLL
  6. #include "sha.h"
  7. #endif
  8. NAMESPACE_BEGIN(CryptoPP)
  9. //! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_PKCS1-1.5">EME-PKCS1-v1_5</a>
  10. class PKCS_EncryptionPaddingScheme : public PK_EncryptionMessageEncodingMethod
  11. {
  12. public:
  13. static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
  14. size_t MaxUnpaddedLength(size_t paddedLength) const;
  15. void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs &parameters) const;
  16. DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs &parameters) const;
  17. };
  18. template <class H> class PKCS_DigestDecoration
  19. {
  20. public:
  21. static const byte decoration[];
  22. static const unsigned int length;
  23. };
  24. // PKCS_DigestDecoration can be instantiated with the following
  25. // classes as specified in PKCS#1 v2.0 and P1363a
  26. class SHA1;
  27. class RIPEMD160;
  28. class Tiger;
  29. class SHA224;
  30. class SHA256;
  31. class SHA384;
  32. class SHA512;
  33. namespace Weak1 {
  34. class MD2;
  35. class MD5;
  36. }
  37. // end of list
  38. #ifdef CRYPTOPP_IS_DLL
  39. CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA1>;
  40. CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA224>;
  41. CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA256>;
  42. CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA384>;
  43. CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA512>;
  44. #endif
  45. //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PKCS1-1.5">EMSA-PKCS1-v1_5</a>
  46. class CRYPTOPP_DLL PKCS1v15_SignatureMessageEncodingMethod : public PK_DeterministicSignatureMessageEncodingMethod
  47. {
  48. public:
  49. static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
  50. size_t MinRepresentativeBitLength(size_t hashIdentifierSize, size_t digestSize) const
  51. {return 8 * (digestSize + hashIdentifierSize + 10);}
  52. void ComputeMessageRepresentative(RandomNumberGenerator &rng,
  53. const byte *recoverableMessage, size_t recoverableMessageLength,
  54. HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
  55. byte *representative, size_t representativeBitLength) const;
  56. struct HashIdentifierLookup
  57. {
  58. template <class H> struct HashIdentifierLookup2
  59. {
  60. static HashIdentifier Lookup()
  61. {
  62. return HashIdentifier(PKCS_DigestDecoration<H>::decoration, PKCS_DigestDecoration<H>::length);
  63. }
  64. };
  65. };
  66. };
  67. //! PKCS #1 version 1.5, for use with RSAES and RSASS
  68. /*! Only the following hash functions are supported by this signature standard:
  69. \dontinclude pkcspad.h
  70. \skip can be instantiated
  71. \until end of list
  72. */
  73. struct PKCS1v15 : public SignatureStandard, public EncryptionStandard
  74. {
  75. typedef PKCS_EncryptionPaddingScheme EncryptionMessageEncodingMethod;
  76. typedef PKCS1v15_SignatureMessageEncodingMethod SignatureMessageEncodingMethod;
  77. };
  78. NAMESPACE_END
  79. #endif