Tool/software:
hi, ti
I have written an encrypted demo using the tisci API interface,
but there is too little information available to determine how some parameters should be adjusted.
Can you provide a demo?
int ti_sci_read_otp_mmr(uint8_t mmr_idx, uint32_t *val) { struct ti_sci_msg_req_read_otp_mmr req = { }; struct ti_sci_msg_resp_read_otp_mmr resp = { }; struct ti_sci_xfer xfer = { }; int ret = 0; //----------------------encryption test ------------ #if 1 struct csp_aes_ctx_v0 { uint8_t mode; uint8_t key_size; uint8_t ctr_width; uint8_t resv0; uint64_t data_len; uint64_t dest_addr; //store data????? uint32_t key[8]; uint32_t iv[4]; uint32_t tag[4]; }__packed; struct csp_aes_opn_req_data { uint32_t ctx_address_lo; uint32_t ctx_address_hi; }__packed; struct csp_aes_opn_resp_data { uint8_t tag[16]; //???? }__packed; #define AES_ECB (0x1) //???? #define AES_CBC (0x2) //???? #define AES_GCM (0x3) //???? #define TISCI_MSG_SA2UL_AES_ENCRYPT 0x9040 #define TISCI_MSG_SA2UL_AES_DECRYPT 0x9041 struct csp_aes_opn_req_data req2 = {}; struct csp_aes_opn_resp_data resp2 = {}; struct ti_sci_xfer xfer2 = { }; char data[16] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; struct csp_aes_ctx_v0 ctx1 = { .mode = AES_CBC, .key_size = 128, .data_len = sizeof(data), .dest_addr = (uint64_t)data, .key[0] = 0x12, .key[1] = 0x34, .key[2] = 0x56, .key[3] = 0x78, }; ret = ti_sci_setup_xfer(TISCI_MSG_SA2UL_AES_ENCRYPT, 0, &req2, sizeof(req2), &resp2, sizeof(resp2), &xfer2); if (ret) goto exit; req2.ctx_address_lo = ( (uint64_t)(&ctx1) ) & 0xffffffff; req2.ctx_address_hi = ( ( (uint64_t)(&ctx1 ) ) >>32 ) & 0xffffffff; ret = ti_sci_do_xfer(&xfer2); if (ret) goto exit; EMSG("encrpto:%02x %02x %02x %02x\n", resp2.tag[0],resp2.tag[1],resp2.tag[2],resp2.tag[3] ); #endif ret = ti_sci_setup_xfer(TI_SCI_MSG_READ_OTP_MMR, 0, &req, sizeof(req), &resp, sizeof(resp), &xfer); if (ret) goto exit; req.mmr_idx = mmr_idx; ret = ti_sci_do_xfer(&xfer); if (ret) goto exit; *val = resp.mmr_val; exit: memzero_explicit(&resp, sizeof(resp)); return ret; }