3.1.7.7 ECC Service
The ECC service provides APIs to execute the following functionality:
- Reading the Serial number from the ECC-608 device.
- Reading the certificate from
device/signer/root
. - Switching between TrustNGo and TrustFlex ECC-608 devices on the RNWF11 Add-On-Board.
- Writing into a slot in the ECC-608 device.
- Reading from a slot.
The ECC-608 service API prototype is as follows:
RNWF_RESULT_t RNWF_ECC_SrvCtrl(RNWF_ECC_SERVICE_t request, void *input);
It handles the following services and reports the results to the application over the return code.
Option/ Command | Input | Description |
---|---|---|
RNWF_ECC_RD_SER | None | Reads the Serial Number from the ECC device |
RNWF_ECC_WR_DEV_TYPE | Device type | Switches to TrustNGo or TrustFlex |
RNWF_ECC_RD_CERT | Certificate type, number of bytes to read | Reads the n bytes from the certificate in device/ signer/
root and lets the user know about the remaining
bytes |
RNWF_ECC_WR_SLOT | Slot, offset, length, Data | Writes the data into the ‘Data’ Zone of the slot number provided by the user |
RNWF_ECC_WR_ZONE_SLOT | Zone, slot, offset, length, data | Writes the ‘Data’ into the zone and the slot number provided by the user |
RNWF_ECC_RD_SLOT | Slot, offset, length | Reads the data into the buffer from the ‘Data’ zone of the slot number provided by the user |
RNWF_ECC_RD_ZONE_SLOT | Zone, slot, offset, length | Reads the data into the buffer from the zone and the slot number provided by the user |
Following is an example of reading a certificate from the ECC device:
RNWF_ECC_CERT_CFG_t cert_cfg;
int main(void)
{
memset(&cert_cfg, 0, sizeof(cert_cfg));
cert_cfg.cert_type = 1; //Device certificate
cert_cfg.length = 1000; //Number of bytes to be read
RNWF_ECC_SrvCtrl(RNWF_ECC_RD_CERT, &cert_cfg);
printf("Bytes Read %d ; Bytes Remaning = %d\r\n", cert_cfg.bytes_read, cert_cfg.remaining_bytes);
printf("Cert:%s\r\n", cert_cfg.cert);
}
Following is an example of reading data from the ECC device slot:
int main(void)
{
RNWF_ECC_SLOT_CFG_t slot_cfg;
memset(&slot_cfg, 0, sizeof(slot_cfg));
slot_cfg.length = 16;
slot_cfg.offset = 0;
slot_cfg.slot_num = 8;
slot_cfg.zone_type = 2;
RNWF_ECC_SrvCtrl(RNWF_ECC_RD_ZONE_SLOT, &slot_cfg);
printf("Slot Data:%s\r\n", slot_cfg.data);
}