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.

77 lines
1.7 KiB

  1. // CoCrypt.h: interface for the CCoCrypt class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_COCRYPT_H__41651BFB_A5C8_11D2_95DF_00C04F8E7A70__INCLUDED_)
  5. #define AFX_COCRYPT_H__41651BFB_A5C8_11D2_95DF_00C04F8E7A70__INCLUDED_
  6. const BYTE g_kMK[] =
  7. {
  8. 0x38, 0x12, 0x87, 0x12, 0x00, 0xA1, 0xE9, 0x44,
  9. 0x45, 0x92, 0x55, 0x08, 0x23, 0x55, 0x99, 0x04,
  10. 0x14, 0x66, 0x29, 0x91, 0x06, 0xB8, 0x33, 0x0F
  11. };
  12. #include "BinHex.h" // Added by ClassView
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif // _MSC_VER > 1000
  16. #ifdef UNIX
  17. #include <des.h>
  18. #else
  19. #include <des.h>
  20. #include <tripldes.h>
  21. #include <modes.h>
  22. #endif
  23. class CCoCrypt
  24. {
  25. public:
  26. static int getKeyVersion(BSTR encrypted);
  27. static int getKeyVersion(BYTE *encrypted);
  28. CCoCrypt();
  29. virtual ~CCoCrypt();
  30. BOOL Decrypt(LPWSTR rawData,
  31. UINT dataSize,
  32. BSTR *ppUnencrypted);
  33. BOOL Encrypt(int keyVersion,
  34. LPSTR rawData,
  35. UINT dataSize,
  36. BSTR *ppEncrypted);
  37. void setKeyMaterial(BSTR newVal);
  38. unsigned char *getKeyMaterial(DWORD *pdwLen);
  39. void setWideMaterial(BSTR kvalue);
  40. BSTR getWideMaterial();
  41. protected:
  42. BOOL CCoCrypt::encrypt(char ivec[9],
  43. int cbPadding,
  44. int keyVersion,
  45. LPSTR rawData,
  46. UINT cbData,
  47. BSTR *ppEncrypted);
  48. static CBinHex m_binhex;
  49. BOOL m_ok;
  50. unsigned char m_keyMaterial[24];
  51. _bstr_t m_bstrWideMaterial;
  52. #ifdef UNIX
  53. des_key_schedule ks1, ks2, ks3;
  54. #else
  55. DES3TABLE ks;
  56. #endif
  57. };
  58. #endif // !defined(AFX_COCRYPT_H__41651BFB_A5C8_11D2_95DF_00C04F8E7A70__INCLUDED_)