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.

78 lines
2.1 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 "nt\des.h"
  20. #include "nt\tripldes.h"
  21. #include "nt\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, UINT dataSize, BSTR *pUnencrypted);
  31. void Encrypt(int keyVersion, LPSTR rawData, UINT dataSize, BSTR *pEncrypted);
  32. void CryptMemberID(BOOL encrypt, long &memberId, long &domainId, long puidScope);
  33. void EncryptKey(int nKeyVer, BSTR bstrIn, BYTE *pEncrypted, UINT &cbOut);
  34. BOOL DecryptKey(BYTE *rawData, UINT dataSize, BSTR *pDecrypted);
  35. void setKeyMaterial(BSTR newVal);
  36. unsigned char *getKeyMaterial(DWORD *pdwLen);
  37. void setWideMaterial(BSTR kvalue);
  38. BSTR getWideMaterial();
  39. protected:
  40. void encryptDynamic(char ivec[9], int sz, int keyVersion, LPSTR rawData,
  41. UINT dataSize, BSTR *pEncrypted);
  42. void encrypt2048(char ivec[9], int sz, int keyVersion, LPSTR rawData,
  43. UINT dataSize, BSTR *pEncrypted, BOOL bEncode = TRUE);
  44. BOOL decryptDynamic(LPWSTR rawData, UINT dataSize, BSTR *pUnencrypted);
  45. BOOL decrypt2048(LPWSTR rawData, UINT dataSize, BSTR *pUnencrypted, BOOL bEncoded = TRUE);
  46. static CBinHex m_binhex;
  47. BOOL m_ok;
  48. unsigned char m_nextIvec[8];
  49. short m_ivecCtr;
  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_)