Advertisement
MagicAndre1981

RPMB support in Windows 10 SDK (Build 10563)

Oct 13th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. new storage type Replay Protected Memory Block is now defined in Windows 10 SDK (10563):
  2.  
  3. //
  4. // IOCTL to send commands to the RPMB for a storage device.
  5. //
  6. #define IOCTL_STORAGE_RPMB_COMMAND CTL_CODE(IOCTL_STORAGE_BASE, 0x0726, METHOD_BUFFERED, FILE_ANY_ACCESS)
  7.  
  8. typedef enum _STORAGE_PROPERTY_ID {
  9. StorageDeviceRpmbProperty,
  10. StorageDeviceAttributesProperty
  11. } STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
  12.  
  13. //
  14. // Output buffer for StorageDeviceRpmbProperty & PropertyStandardQuery
  15. //
  16.  
  17. #define DEVICE_RPMB_DESCRIPTOR_VERSION_1 1
  18.  
  19. typedef struct _DEVICE_RPMB_DESCRIPTOR {
  20.  
  21. //
  22. // Keep compatible with STORAGE_DESCRIPTOR_HEADER
  23. // Shall be set to DEVICE_RPMB_DESCRIPTOR_VERSION_1
  24. //
  25.  
  26. ULONG Version;
  27.  
  28. //
  29. // Keep compatible with STORAGE_DESCRIPTOR_HEADER
  30. // Shall be set to sizeof(DEVICE_RPMB_DESCRIPTOR)
  31. //
  32.  
  33. ULONG Size;
  34.  
  35. //
  36. // 0 if not supported, RPMB size in bytes otherwise
  37. //
  38.  
  39. ULONG SizeInBytes;
  40.  
  41. //
  42. // 0 if not supported, minimum 512 bytes
  43. // For UFS, this is (bRPMB_ReadWriteSize * 256)
  44. //
  45.  
  46. ULONG MaxReliableWriteSizeInBytes;
  47.  
  48. } DEVICE_RPMB_DESCRIPTOR, *PDEVICE_RPMB_DESCRIPTOR;
  49.  
  50.  
  51. //
  52. // IOCTL_STORAGE_RPMB_COMMAND
  53. //
  54. // This IOCTL sends an RPMB command to the underlying storage device.
  55. //
  56. // Input buffer:
  57. // An array of STORAGE_DEVICE_RPMB_DATA_FRAME structures
  58. // * The number of frames included can be calculated by InputBufferLength / sizeof(STORAGE_DEVICE_RPMB_DATA_FRAME)
  59. //
  60. // Output buffer:
  61. // An array of STORAGE_DEVICE_RPMB_DATA_FRAME structures
  62. // * The number of frames included can be calculated by OutputBufferLength / sizeof(STORAGE_DEVICE_RPMB_DATA_FRAME)
  63. //
  64.  
  65. // Ensure we are byte aligned
  66. #pragma pack(push)
  67. #pragma pack(1)
  68.  
  69. //
  70. // This is the RPMB data frame used to compose all RPMB requests and responses.
  71. //
  72.  
  73. typedef struct _STORAGE_DEVICE_RPMB_DATA_FRAME {
  74.  
  75. //
  76. // Reserved
  77. //
  78. UCHAR Stuff[196];
  79.  
  80. //
  81. // Either the key to be programmed or the MAC authenticating this frame or series of frames
  82. //
  83. UCHAR KeyOrMAC[32];
  84.  
  85. //
  86. // The data input or output
  87. //
  88. UCHAR Data[256];
  89.  
  90. //
  91. // Random 128-bit number generated by host
  92. //
  93. UCHAR Nonce[16];
  94.  
  95. //
  96. // 32-bit counter
  97. //
  98. UCHAR WriteCounter[4];
  99.  
  100. //
  101. // The half-sector address to operate on
  102. //
  103. UCHAR Address[2];
  104.  
  105. //
  106. // The count of half-sector blocks to read/write
  107. //
  108. UCHAR BlockCount[2];
  109.  
  110. //
  111. // The result of the operation
  112. //
  113. UCHAR OperationResult[2];
  114.  
  115. //
  116. // The type of request or response
  117. //
  118. UCHAR RequestOrResponseType[2];
  119.  
  120. } STORAGE_DEVICE_RPMB_DATA_FRAME, *PSTORAGE_DEVICE_RPMB_DATA_FRAME;
  121.  
  122. //
  123. // RPMB RequestOrResponseType Values
  124. //
  125.  
  126. typedef enum _STORAGE_DEVICE_RPMB_COMMAND {
  127. StorRpmbProgramAuthKey = 0x00000001,
  128. StorRpmbQueryWriteCounter = 0x00000002,
  129. StorRpmbAuthenticatedWrite = 0x00000003,
  130. StorRpmbAuthenticatedRead = 0x00000004,
  131. StorRpmbAuthenticatedDeviceConfigWrite = 0x00000006,
  132. StorRpmbAuthenticatedDeviceConfigRead = 0x00000007,
  133. } STORAGE_DEVICE_RPMB_COMMAND, *PSTORAGE_DEVICE_RPMB_COMMAND;
  134.  
  135. #pragma pack(pop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement