Source code of Windows XP (NT5)
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.

136 lines
3.3 KiB

  1. // HashCtx.h -- declaration of CHashContext
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1998. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #if !defined(SLBCSP_HASHCTX_H)
  8. #define SLBCSP_HASHCTX_H
  9. #include <memory> // for auto_ptr
  10. #include <wincrypt.h>
  11. #include <handles.h>
  12. #include "Blob.h"
  13. #include "CryptCtx.h"
  14. class CHashContext
  15. : public CHandle
  16. {
  17. public:
  18. // Types
  19. typedef DWORD SizeType;
  20. typedef BYTE ValueType;
  21. // C'tors/D'tors
  22. virtual
  23. ~CHashContext() throw();
  24. // Operators
  25. // Operations
  26. virtual std::auto_ptr<CHashContext>
  27. Clone(DWORD const *pdwReserved,
  28. DWORD dwFlags) const = 0;
  29. void
  30. Close();
  31. void
  32. ExportFromAuxCSP();
  33. void
  34. Hash(BYTE const *pbData,
  35. DWORD dwLength);
  36. HCRYPTHASH
  37. HashHandleInAuxCSP();
  38. void
  39. ImportToAuxCSP();
  40. void
  41. Initialize();
  42. static std::auto_ptr<CHashContext>
  43. Make(ALG_ID algid,
  44. CryptContext const &rcryptctx);
  45. void
  46. Value(Blob const &rhs);
  47. // Access
  48. ALG_ID
  49. AlgId();
  50. Blob
  51. EncodedValue();
  52. SizeType
  53. Length() const;
  54. Blob
  55. Value();
  56. // Predicates
  57. static bool
  58. IsSupported(ALG_ID algid);
  59. protected:
  60. // Types
  61. // C'tors/D'tors
  62. CHashContext(CryptContext const &rcryptctx,
  63. ALG_ID algid);
  64. // Duplicate the hash and its state
  65. CHashContext(CHashContext const &rhs,
  66. DWORD const *pdwReserved,
  67. DWORD dwFlags);
  68. // Operators
  69. // Operations
  70. // Access
  71. virtual Blob
  72. EncodedAlgorithmOid() = 0;
  73. // Predicates
  74. // Variables
  75. private:
  76. // Types
  77. // C'tors/D'tors
  78. // not defined, copying not allowed...use Clone
  79. CHashContext(CHashContext const &rhs);
  80. // Operators
  81. // not defined, initialization not allowed
  82. CHashContext &
  83. operator==(CHashContext const &rhs);
  84. // Operations
  85. // Access
  86. // Predicates
  87. // Variables
  88. CryptContext const &m_rcryptctx;
  89. ALG_ID const m_algid;
  90. Blob m_blbValue;
  91. bool m_fDone;
  92. bool m_fJustCreated;
  93. HCRYPTHASH m_HashHandle;
  94. };
  95. #endif // SLBCSP_HASHCTX_H