3.6. I2CM / Secure Sensor

For an example regarding this, see Section 5.7.7 I2C Master Example

3.6.1. Normal Read/Write

The sequence to read from I2CM Sensor is as below:

../_images/i2cm-config-read-write.png

3.6.2. Attested Read

The sequence to read with attestation from I2CM Sensor is as below:

../_images/i2cm-config-attread.png

3.6.3. Transaction

A sample I2CM Transaction can be performed as below:

Code:

    FujAddr[0] = 0x03;
    FujAddr[1] = 0x00;
    TLV[0].type = kSE05x_I2CM_Configure;
    TLV[0].cmd.cfg.I2C_addr = FUJITSU_I2C_ADDR;
    TLV[0].cmd.cfg.I2C_baudRate = kSE05x_I2CM_Baud_Rate_100Khz;

    TLV[1].type = kSE05x_I2CM_Write;
    TLV[1].cmd.w.writeLength = sizeof(FujAddr);
    TLV[1].cmd.w.writebuf = FujAddr;

    TLV[2].type = kSE05x_I2CM_Read;
    TLV[2].cmd.rd.readLength = I2C_MAX_DATA;
    TLV[2].cmd.rd.rdBuf = pFujMemRead;

    status = Se05x_i2c_master_txn(&gtCtx.session, &TLV[0], 3);

3.6.4. Read with Attestation

A sample I2CM read with Attestation can be performed as below:

Code:

    TLV[0].type = kSE05x_I2CM_Configure;
    TLV[0].cmd.cfg.I2C_addr = FUJITSU_I2C_ADDR;
    TLV[0].cmd.cfg.I2C_baudRate = kSE05x_I2CM_Baud_Rate_400Khz;

    TLV[1].type = kSE05x_I2CM_Write;
    TLV[1].cmd.w.writeLength = sizeof(FujAddr);
    TLV[1].cmd.w.writebuf = FujAddr;

    TLV[2].type = kSE05x_I2CM_Read;
    TLV[2].cmd.rd.readLength = I2C_MAX_DATA;
    TLV[2].cmd.rd.rdBuf = pFujMemRead;

    attest_data.timeStampLen = sizeof(attest_data.timeStamp.ts);
    attest_data.chipIdLen = sizeof(attest_data.chipId);
#if SSS_HAVE_SE05X_VER_GTE_07_02
    attest_data.objSizeLen = sizeof(attest_data.objSize);
#endif // SSS_HAVE_SE05X_VER_GTE_07_02
    attest_data.signatureLen = sizeof(attest_data.signature);
    rspbufferLen = sizeof(rspbuffer);
    status = Se05x_i2c_master_attst_txn(&gtCtx.session,
        &gtCtx.key,
        &TLV[0],
        random,
        sizeof(random),
        attest_algo,
        &attest_data,
        rspbuffer,
        &rspbufferLen,
        3);

3.6.5. I2C Master APIs

group se050_i2cm

I2C Master APIs in SE050 for secure sensor.

Enums

enum SE05x_I2CM_Baud_Rate_t

Configuration for I2CM

Values:

kSE05x_I2CM_Baud_Rate_100Khz = 0
kSE05x_I2CM_Baud_Rate_400Khz
enum SE05x_I2CM_securityReq_t

Additional operation on data read by I2C

Values:

kSE05x_Security_None = 0
kSE05x_Sign_Request
kSE05x_Sign_Enc_Request
enum SE05x_I2CM_status_t

Status of I2CM Transaction

Values:

kSE05x_I2CM_Success = 0x5A
kSE05x_I2CM_I2C_Nack_Fail = 0x01
kSE05x_I2CM_I2C_Write_Error = 0x02
kSE05x_I2CM_I2C_Read_Error = 0x03
kSE05x_I2CM_I2C_Time_Out_Error = 0x05
kSE05x_I2CM_Invalid_Tag = 0x11
kSE05x_I2CM_Invalid_Length = 0x12
kSE05x_I2CM_Invalid_Length_Encode = 0x13
kSE05x_I2CM_I2C_Config = 0x21
enum SE05x_I2CM_TAG_t

I2C Master micro operation.

Values:

kSE05x_TAG_I2CM_Config = 0x01
kSE05x_TAG_I2CM_Write = 0x03
kSE05x_TAG_I2CM_Read = 0x04
enum SE05x_I2CM_TLV_type_t

Types of entries in an I2CM Transaction

Values:

kSE05x_I2CM_None = 0

Do nothing

kSE05x_I2CM_Configure

Configure the address, baudrate

kSE05x_I2CM_Write = 3

Write to I2C Slave

kSE05x_I2CM_Read

Read from I2C Slave

kSE05x_I2CM_StructuralIssue = 0xFF

Response from SE05x that there is something wrong

Functions

smStatus_t Se05x_i2c_master_attst_txn(sss_session_t *sess, sss_object_t *keyObject, SE05x_I2CM_cmd_t *p, uint8_t *random_attst, size_t random_attstLen, SE05x_AttestationAlgo_t attst_algo, sss_se05x_attst_comp_data_t *pattest_data, uint8_t *rspbuffer, size_t *rspbufferLen, uint8_t noOftags)

Se05x_i2c_master_attst_txn.

I2CM Read With Attestation

Pre

p describes I2C master commands.

Post

p contains execution state of I2C master commands, the I2C master commands can be overwritten to report on execution failure.

Parameters
  • [in] sess: session identifier

  • [in] keyObject: Keyobject which contains 4 byte attestaion KeyId

  • [inout] p: Array of structure type capturing a sequence of i2c master cmd/rsp transactions.

  • [in] random_attst: 16-byte freshness random

  • [in] random_attstLen: length of freshness random

  • [in] attst_algo: 1 byte attestationAlgo

  • [out] ptimeStamp: timestamp

  • [out] timeStampLen: Length for timestamp

  • [out] freshness: freshness (random)

  • [out] pfreshnessLen: Length for freshness

  • [out] chipId: unique chip Id

  • [out] pchipIdLen: Length for chipId

  • [out] signature: signature

  • [out] psignatureLen: Length for signature

  • [in] noOftags: Amount of structures contained in p

smStatus_t Se05x_i2c_master_txn(sss_session_t *sess, SE05x_I2CM_cmd_t *cmds, uint8_t cmdLen)

Se05x_i2c_master_txn.

I2CM Transaction

Pre

p describes I2C master commands.

Post

p contains execution state of I2C master commands, the I2C master commands can be overwritten to report on execution failure.

Parameters
  • [in] sess: session identifier

  • [inout] cmds: Array of structure type capturing a sequence of i2c master cmd/rsp transactions.

  • [in] cmdLen: Amount of structures contained in cmds

struct _SE05x_I2CM_cmd
#include <fsl_sss_se05x_types.h>

Individual entry in array of TLV commands, with type

Se05x_i2c_master_txn would expect an array of these.

Public Members

SE05x_I2CM_INS_type_t cmd

Individual entry in array of TLV commands.

SE05x_I2CM_TLV_type_t type
struct SE05x_I2CM_configData_t
#include <fsl_sss_se05x_types.h>

Data Configuration for I2CM

Public Members

uint8_t I2C_addr

7 Bit address of I2C slave

SE05x_I2CM_Baud_Rate_t I2C_baudRate

What baud rate

SE05x_I2CM_status_t status

return status of the config operation

union SE05x_I2CM_INS_type_t
#include <fsl_sss_se05x_types.h>

Individual entry in array of TLV commands.

Public Members

SE05x_I2CM_configData_t cfg

Data Configuration for I2CM

SE05x_I2CM_structuralIssue_t issue

Used to report error response, not for outgoing command

SE05x_I2CM_readData_t rd

Read to I2CM from I2C Slave

SE05x_I2CM_securityData_t sec

Security Configuration for I2CM.

SE05x_I2CM_writeData_t w

Write From I2CM to I2C Slave.

struct SE05x_I2CM_readData_t
#include <fsl_sss_se05x_types.h>

Read to I2CM from I2C Slave

Public Members

uint8_t *rdBuf

Output. rdBuf will point to Host buffer.

SE05x_I2CM_status_t rdStatus

[Out] status of the operation

uint16_t readLength

How many bytes to read

struct SE05x_I2CM_securityData_t
#include <fsl_sss_se05x_types.h>

Security Configuration for I2CM.

Public Members

uint32_t keyObject

object used for the operation

SE05x_I2CM_securityReq_t operation

Additional operation on data read by I2C

struct SE05x_I2CM_structuralIssue_t
#include <fsl_sss_se05x_types.h>

Used to report error response, not for outgoing command

Public Members

SE05x_I2CM_status_t issueStatus

[Out] In case there is any structural issue

struct SE05x_I2CM_writeData_t
#include <fsl_sss_se05x_types.h>

Write From I2CM to I2C Slave.

Public Members

uint8_t *writebuf

Buffer to be written

uint8_t writeLength

How many bytes to write

SE05x_I2CM_status_t wrStatus

[Out] status of the operation