Leaked source code of windows server 2003
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.

83 lines
2.0 KiB

  1. #pragma once
  2. #include "fusionarray.h"
  3. #include "wincrypt.h"
  4. #include "fusionhandle.h"
  5. #define A_SHA_DIGEST_LEN 20
  6. #ifndef INVALID_CRYPT_HASH
  7. #define INVALID_CRYPT_HASH (static_cast<HCRYPTHASH>(NULL))
  8. #endif
  9. #define PRIVATIZE_COPY_CONSTRUCTORS( obj ) obj( const obj& ); obj& operator=(const obj&);
  10. class CSha1Context
  11. {
  12. PRIVATIZE_COPY_CONSTRUCTORS(CSha1Context);
  13. unsigned char m_workspace[64];
  14. unsigned long state[5];
  15. SIZE_T count[2];
  16. unsigned char buffer[64];
  17. BOOL Transform( const unsigned char* buffer );
  18. public:
  19. CSha1Context() { }
  20. BOOL Update( const unsigned char* data, SIZE_T len );
  21. BOOL GetDigest( unsigned char* digest, PSIZE_T len );
  22. BOOL Initialize();
  23. };
  24. /*
  25. void A_SHATransform(CSha1Context* context, const unsigned char buffer);
  26. void A_SHAInit(CSha1Context* context);
  27. void A_SHAUpdate(CSha1Context* context, const unsigned char* data, const ULONG len);
  28. BOOL A_SHAFinal(CSha1Context* context, unsigned char* digest, ULONG *len);
  29. */
  30. class CFusionHash
  31. {
  32. private:
  33. PRIVATIZE_COPY_CONSTRUCTORS(CFusionHash);
  34. protected:
  35. CSha1Context m_Sha1Context;
  36. CCryptHash m_hCryptHash;
  37. ALG_ID m_aid;
  38. BOOL m_fInitialized;
  39. BOOL GetIsValid();
  40. public:
  41. CFusionHash()
  42. : m_fInitialized(FALSE), m_aid(0), m_hCryptHash(INVALID_CRYPT_HASH)
  43. { }
  44. BOOL Win32Initialize( ALG_ID aid );
  45. BOOL Win32HashData(const BYTE *pbBuffer, SIZE_T cbSize);
  46. BOOL Win32GetValue(OUT CFusionArray<BYTE> &out);
  47. };
  48. //
  49. // There's no "real" invalid value defined anywhere, but by inspecting the
  50. // codebase, NULL is the accepted "invalid" value - check the logon service
  51. // code, they do the same thing.
  52. //
  53. #define INVALID_CRYPT_HANDLE (static_cast<HCRYPTPROV>(NULL))
  54. //
  55. // Global crypto context stuff
  56. //
  57. BOOL SxspAcquireGlobalCryptContext( HCRYPTPROV *pContext );
  58. BOOL
  59. WINAPI
  60. FusionpCryptoContext_DllMain(
  61. HINSTANCE hInstance,
  62. DWORD dwReason,
  63. PVOID pvReserved
  64. );