3.1.7.7 ECC Service

The ECC service provides APIs to execute the following functionality:

  1. Reading the Serial number from the ECC-608 device.
  2. Reading the certificate from device/signer/root.
  3. Switching between TrustNGo and TrustFlex ECC-608 devices on the RNWF11 Add-On-Board.
  4. Writing into a slot in the ECC-608 device.
  5. 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.

Table 3-13. ECC Service Options
Option/ CommandInputDescription
RNWF_ECC_RD_SERNoneReads the Serial Number from the ECC device
RNWF_ECC_WR_DEV_TYPEDevice typeSwitches to TrustNGo or TrustFlex
RNWF_ECC_RD_CERTCertificate type, number of bytes to readReads the n bytes from the certificate in device/ signer/ root and lets the user know about the remaining bytes
RNWF_ECC_WR_SLOTSlot, offset, length, DataWrites the data into the ‘Data’ Zone of the slot number provided by the user
RNWF_ECC_WR_ZONE_SLOTZone, slot, offset, length, dataWrites the ‘Data’ into the zone and the slot number provided by the user
RNWF_ECC_RD_SLOTSlot, offset, lengthReads the data into the buffer from the ‘Data’ zone of the slot number provided by the user
RNWF_ECC_RD_ZONE_SLOTZone, slot, offset, lengthReads 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);                        
}