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.

122 lines
3.3 KiB

  1. /*++
  2. Copyright (C) 1996, 1997 Microsoft Corporation
  3. Module Name:
  4. keyback.h
  5. Abstract:
  6. This module defines the Key Backup interface and associated data structures.
  7. Author:
  8. Scott Field (sfield) 16-Aug-97
  9. --*/
  10. #ifndef __KEYBACK_H__
  11. #define __KEYBACK_H__
  12. //
  13. // Back up a key
  14. //
  15. #define BACKUPKEY_BACKUP_GUID { 0x7f752b10, 0x178e, 0x11d1, { 0xab, 0x8f, 0x00, 0x80, 0x5f, 0x14, 0xdb, 0x40 } }
  16. //
  17. // Restore a key, wraping it in the pbBK format,
  18. // for downlevel compatability
  19. //
  20. #define BACKUPKEY_RESTORE_GUID_W2K { 0x7fe94d50, 0x178e, 0x11d1, { 0xab, 0x8f, 0x00, 0x80, 0x5f, 0x14, 0xdb, 0x40 } }
  21. #define BACKUPKEY_RESTORE_GUID { 0x47270c64, 0x2fc7, 0x499b, {0xac, 0x5b, 0x0e, 0x37, 0xcd, 0xce, 0x89, 0x9a} }
  22. // Retrieve the public backup certificate
  23. #define BACKUPKEY_RETRIEVE_BACKUP_KEY_GUID { 0x018ff48a, 0xeaba, 0x40c6, { 0x8f, 0x6d, 0x72, 0x37, 0x02, 0x40, 0xe9, 0x67 } }
  24. #define BACKUPKEY_RECOVERY_BLOB_VERSION_W2K 1 //
  25. #define BACKUPKEY_RECOVERY_BLOB_VERSION 2 // version of recovery blob containing
  26. // MK and LK directly.
  27. //
  28. // Header for the backupkey blob version
  29. // Folowed by the master key and payload key encrypted
  30. // by the key indicated by guidKey. The encrypted data is
  31. // represented in a PKCS#1v2 formmated (CRYPT_OAEP) blob
  32. // That data is followed by the encrypted payload
  33. //
  34. typedef struct {
  35. DWORD dwVersion; // version of structure (BACKUPKEY_RECOVERY_BLOB_VERSION)
  36. DWORD cbEncryptedMasterKey; // quantity of encrypted master key data following structure
  37. DWORD cbEncryptedPayload; // quantity of encrypted payload
  38. GUID guidKey; // guid identifying backup key used
  39. } BACKUPKEY_RECOVERY_BLOB,
  40. *PBACKUPKEY_RECOVERY_BLOB,
  41. *LPBACKUPKEY_RECOVERY_BLOB;
  42. typedef struct {
  43. DWORD cbMasterKey;
  44. DWORD cbPayloadKey;
  45. } BACKUPKEY_KEY_BLOB,
  46. *PBACKUPKEY_KEY_BLOB,
  47. *LPBACKUPKEY_KEY_BLOB;
  48. //
  49. // Header for the inner blob of the master key recovery blob
  50. // Following the header is LocalKey, then the SID, and finally
  51. // a SHA_1 MAC of the contained data
  52. typedef struct {
  53. DWORD dwPayloadVersion;
  54. DWORD cbLocalKey;
  55. } BACKUPKEY_INNER_BLOB,
  56. *PBACKUPKEY_INNER_BLOB,
  57. *LPBACKUPKEY_INNER_BLOB;
  58. #define BACKUPKEY_PAYLOAD_VERSION 1
  59. #define MASTERKEY_BLOB_RAW_VERSION 0
  60. #define MASTERKEY_BLOB_VERSION_W2K 1
  61. #define MASTERKEY_BLOB_VERSION 2
  62. #define MASTERKEY_BLOB_LOCALKEY_BACKUP 3
  63. #define MASTERKEY_R2_LEN_W2K (16)
  64. #define MASTERKEY_R3_LEN_W2K (16)
  65. typedef struct {
  66. DWORD dwVersion; // version of structure (MASTERKEY_BLOB_VERSION_W2K)
  67. BYTE R2[MASTERKEY_R2_LEN_W2K]; // random data used during HMAC to derive symetric key
  68. } MASTERKEY_BLOB_W2K, *PMASTERKEY_BLOB_W2K, *LPMASTERKEY_BLOB_W2K;
  69. typedef struct {
  70. BYTE R3[MASTERKEY_R3_LEN_W2K]; // random data used to derive MAC key
  71. BYTE MAC[A_SHA_DIGEST_LEN]; // HMAC(R3, pbMasterKey)
  72. } MASTERKEY_INNER_BLOB_W2K, *PMASTERKEY_INNER_BLOB_W2K, *LPMASTERKEY_INNER_BLOB_W2K;
  73. DWORD
  74. WINAPI
  75. BackupKey(
  76. IN LPCWSTR szComputerName,
  77. IN const GUID *pguidActionAgent,
  78. IN BYTE *pDataIn,
  79. IN DWORD cbDataIn,
  80. IN OUT BYTE **ppDataOut,
  81. IN OUT DWORD *pcbDataOut,
  82. IN DWORD dwParam
  83. );
  84. #endif // __KEYBACK_H__