Read or write an RPMB frame
#include <hw/dcmd_sim_mmcsd.h> #define DCMD_MMCSD_RPMB_RW_FRAME __DIOTF(_DCMD_CAM, _SIM_MMCSD + 50, struct _mmcsd_rpmb_req)
Argument | Value |
---|---|
filedes | A file descriptor that you obtained by opening the device |
dcmd | DCMD_MMCSD_RPMB_RW_FRAME |
dev_data_ptr | A pointer to a MMCSD_RPMB_REQ structure |
n_bytes | sizeof(MMCSD_RPMB_REQ) |
dev_info_ptr | NULL |
This command reads or writes an RPMB frame. The MMCSD_RPMB_REQ structure is defined as follows:
#define RPMB_KEY_MAC_FIELD_LEN 32 #define RPMB_DATA_FIELD_LEN 256 #define RPMB_HASH_DATA_LEN 32 #define RPMB_USABLE_DATA_LEN (RPMB_DATA_FIELD_LEN - RPMB_HASH_DATA_LEN) #define RPMB_NONCE_FIELD_LEN 16 #define RPMB_ONE_BLK_MAC_LEN (RPMB_DATA_FIELD_LEN + RPMB_NONCE_FIELD_LEN + 4 + 2 + 2 + 2 + 2) /*(write_cntr + address + block_cnt + result + req_resp) */ typedef struct _mmcsd_rpmb_frame { uint8_t stuff[196]; uint8_t key_mac[RPMB_KEY_MAC_FIELD_LEN]; uint8_t data[RPMB_DATA_FIELD_LEN]; uint8_t nonce[RPMB_NONCE_FIELD_LEN]; uint32_t write_cntr; uint16_t address; uint16_t block_cnt; uint16_t result; uint16_t req_resp; } MMCSD_RPMB_FRAME; typedef struct _mmcsd_rpmb_req { uint16_t req_type; paddr64_t rpmb_frame_paddr; /* Pointer to an MMCSD_RPMB_FRAME */ } MMCSD_RPMB_REQ;
Set the req_type and req_resp members to one of the following:
Get a one-time key from the device before calling devctl(), and then store the key in the nonce member.
The stuff member is used for additional data, such as an initialization vector.
The result member is 0 for success; any other value indicates an error. The rest of the output depends on the type of request.
devctl() in the QNX Neutrino C Library Reference