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.

100 lines
3.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: cryptfnc.h
  4. //
  5. // Contents: Defines the Class CCryptFunctions
  6. //
  7. //
  8. // History: AshishS Created 11/28/96
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef _CRYPT_FNC_H
  12. #define _CRYPT_FNC_H
  13. #define CRYPT_FNC_ID 2983
  14. #include <windows.h>
  15. #include <wincrypt.h>
  16. #define CRYPT_FNC_NO_ERROR 0
  17. #define CRYPT_FNC_BAD_PASSWORD 1
  18. #define CRYPT_FNC_INSUFFICIENT_BUFFER 2
  19. #define CRYPT_FNC_INIT_NOT_CALLED 3
  20. #define CRYPT_FNC_INTERNAL_ERROR 4
  21. #define CRYPTFNC_SEMAPHORE_NAME TEXT("SS_Cryptfnc_Semaphore_For_CAPI")
  22. class CCryptFunctions
  23. {
  24. HCRYPTPROV m_hProv;
  25. HANDLE m_hSemaphore;
  26. BOOL GenerateSessionKeyFromPassword(
  27. HCRYPTKEY * phKey, // location to store the key
  28. TCHAR * pszPassword); // password to generate the key from
  29. public:
  30. CCryptFunctions();
  31. ~CCryptFunctions();
  32. BOOL InitCrypt();
  33. BOOL GenerateSecretKey(
  34. BYTE * pbData,// Buffer to store secret key
  35. //buffer must be long enough for dwLength bytes
  36. DWORD dwLength ); // length of secret key in bytes
  37. BOOL EncryptDataWithPassword(
  38. TCHAR * pszPassword, // password
  39. BYTE * pbData, // Data to be encrypted
  40. DWORD dwDataLength, // Length of data in bytes
  41. BYTE * pbEncyrptedData, // Encrypted secret key will be stored here
  42. DWORD * pdwEncrytedBufferLen // Length of this buffer
  43. );
  44. BOOL CCryptFunctions::GenerateHash(
  45. BYTE * pbData, // data to hash
  46. DWORD dwDataLength, // length of data to hash
  47. BYTE * pbData1, // another data to hash
  48. DWORD dwData1Length, // length of above data
  49. BYTE * pbData2, // another data to hash
  50. DWORD dwData2Length, // length of above data
  51. BYTE * pbData3, // another data to hash
  52. DWORD dwData3Length, // length of above data
  53. BYTE * pbHashBuffer, // buffer to store hash
  54. DWORD * pdwHashBufLen);//length of buffer to store Hash
  55. DWORD DecryptDataWithPassword(
  56. TCHAR * pszPassword, // password
  57. BYTE * pbData, // Decrypted Data will be stored here
  58. DWORD *pdwDataBufferLength, // Length of the above buffer in bytes
  59. BYTE * pbEncryptedData, // Encrypted data
  60. DWORD dwEncrytedDataLen // Length of encrypted data
  61. );
  62. DWORD EncryptDataAndExportSessionKey(
  63. BYTE * pbData, // Secret Data
  64. DWORD dwDataLen, // Secret Data Length
  65. BYTE * pbEncryptedData, // Buffer to store Encrypted Data
  66. DWORD * pdwEncrytedBufferLen, // Length of above buffer
  67. BYTE * pbEncryptedSessionKey, // Buffer to store encrypted session key
  68. DWORD * pdwEncrytedSessionKeyLength); // Length of above buffer
  69. DWORD ImportSessionKeyAndDecryptData(
  70. BYTE * pbData, // Buffer to store secret Data
  71. DWORD * pdwDataLen, // Length of Above buffer
  72. BYTE * pbEncryptedData, // Buffer that stores Encrypted Data
  73. DWORD dwEncrytedBufferLen, // Length of above data
  74. BYTE * pbEncryptedSessionKey,// Buffer that stores encrypted sessionkey
  75. DWORD dwEncrytedSessionKeyLength); // Length of above data
  76. };
  77. typedef CCryptFunctions CCRYPT_FUNCTIONS;
  78. typedef CCryptFunctions *PCCRYPT_FUNCTIONS;
  79. #endif