OPTIGA Trust M  1.1.0
C++ library for Optiga Trust M Chip Security Controller
ifx_i2c_presentation_layer.c File Reference

This file implements the IFX I2C Presentation Layer of the Infineon I2C Protocol Stack library. More...

Include dependency graph for ifx_i2c_presentation_layer.c:

Functions

optiga_lib_status_t ifx_i2c_prl_init (ifx_i2c_context_t *p_ctx, ifx_i2c_event_handler_t handler)
 Function for initializing the module. More...
 
optiga_lib_status_t ifx_i2c_prl_close (ifx_i2c_context_t *p_ctx, ifx_i2c_event_handler_t handler)
 Function for closing the module. More...
 
optiga_lib_status_t ifx_i2c_prl_transceive (ifx_i2c_context_t *p_ctx, uint8_t *p_tx_data, uint16_t tx_data_len, uint8_t *p_rx_data, uint16_t *p_rx_data_len)
 Function to transmit and receive a packet. More...
 
_STATIC_H optiga_lib_status_t ifx_i2c_prl_prf (ifx_i2c_context_t *p_ctx)
 
_STATIC_H void ifx_i2c_prl_form_associated_data (ifx_i2c_context_t *p_ctx, uint16_t data_len, uint32_t seq_number, uint8_t sctr)
 
_STATIC_H optiga_lib_status_t ifx_i2c_prl_encrypt_msg (ifx_i2c_context_t *p_ctx, uint8_t *p_data, uint16_t data_len, uint32_t seq_number, uint8_t sctr)
 
_STATIC_H optiga_lib_status_t ifx_i2c_prl_decrypt_msg (ifx_i2c_context_t *p_ctx, const uint8_t *p_data, uint16_t data_len, uint32_t seq_number, uint8_t *out_data, uint8_t decrypt_key_offset, uint8_t decrypt_nonce_offset, uint8_t sctr)
 
_STATIC_H optiga_lib_status_t ifx_i2c_prl_send_alert (ifx_i2c_context_t *p_ctx)
 
_STATIC_H optiga_lib_status_t ifx_i2c_prl_do_handshake (ifx_i2c_context_t *p_ctx, const uint8_t *p_data)
 
_STATIC_H optiga_lib_status_t ifx_i2c_prl_do_manage_context (ifx_i2c_context_t *p_ctx, const uint8_t *p_data, uint16_t data_len, uint8_t *exit_machine)
 
_STATIC_H void ifx_i2c_prl_event_handler (ifx_i2c_context_t *p_ctx, optiga_lib_status_t event, const uint8_t *p_data, uint16_t data_len)
 

Detailed Description

This file implements the IFX I2C Presentation Layer of the Infineon I2C Protocol Stack library.

Copyright (c) 2019 Infineon Technologies AG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

\endcopyright

Author
Infineon Technologies AG

Function Documentation

◆ ifx_i2c_prl_close()

optiga_lib_status_t ifx_i2c_prl_close ( ifx_i2c_context_t p_ctx,
ifx_i2c_event_handler_t  handler 
)

Function for closing the module.

Function closes the module and registers an event handler to receive events from this module.

Precondition
  • This function must be called before using the module.
Note
  • None
Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]handlerFunction pointer to the event handler of the upper layer.
Return values
IFX_I2C_STACK_SUCCESSIf initialization was successful.
IFX_I2C_STACK_ERRORIf the module is already initialized.
Here is the call graph for this function:

◆ ifx_i2c_prl_decrypt_msg()

_STATIC_H optiga_lib_status_t ifx_i2c_prl_decrypt_msg ( ifx_i2c_context_t p_ctx,
const uint8_t *  p_data,
uint16_t  data_len,
uint32_t  seq_number,
uint8_t *  out_data,
uint8_t  decrypt_key_offset,
uint8_t  decrypt_nonce_offset,
uint8_t  sctr 
)
Here is the call graph for this function:

◆ ifx_i2c_prl_do_handshake()

_STATIC_H optiga_lib_status_t ifx_i2c_prl_do_handshake ( ifx_i2c_context_t p_ctx,
const uint8_t *  p_data 
)

Validating decrpt data

Validating sequence number

Here is the call graph for this function:

◆ ifx_i2c_prl_do_manage_context()

_STATIC_H optiga_lib_status_t ifx_i2c_prl_do_manage_context ( ifx_i2c_context_t p_ctx,
const uint8_t *  p_data,
uint16_t  data_len,
uint8_t *  exit_machine 
)

Restoring saved context from data store

Prepare restore message

Clearing the saved context in data store

Message type invalid

Restore the saved context to active context structure

Store active session to data store

Clearing the active session

Here is the call graph for this function:

◆ ifx_i2c_prl_encrypt_msg()

_STATIC_H optiga_lib_status_t ifx_i2c_prl_encrypt_msg ( ifx_i2c_context_t p_ctx,
uint8_t *  p_data,
uint16_t  data_len,
uint32_t  seq_number,
uint8_t  sctr 
)
Here is the call graph for this function:

◆ ifx_i2c_prl_event_handler()

_STATIC_H void ifx_i2c_prl_event_handler ( ifx_i2c_context_t p_ctx,
optiga_lib_status_t  event,
const uint8_t *  p_data,
uint16_t  data_len 
)

Clearing the saved context in data store

Preparing receive length based on the protection level

Decrypt messag to use for retansmit

Sending plan data

Sctr value mismatch

For slave encrypted message

Here is the call graph for this function:

◆ ifx_i2c_prl_form_associated_data()

_STATIC_H void ifx_i2c_prl_form_associated_data ( ifx_i2c_context_t p_ctx,
uint16_t  data_len,
uint32_t  seq_number,
uint8_t  sctr 
)
Here is the call graph for this function:

◆ ifx_i2c_prl_init()

optiga_lib_status_t ifx_i2c_prl_init ( ifx_i2c_context_t p_ctx,
ifx_i2c_event_handler_t  handler 
)

Function for initializing the module.

Function initializes and enables the module

  • It registers an event handler to receive events from this module.
Precondition
  • This function must be called before using the module.
Note
  • None
Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]handlerFunction pointer to the event handler of the upper layer.
Return values
IFX_I2C_STACK_SUCCESSIf initialization was successful.
IFX_I2C_STACK_ERRORIf the module is already initialized.
Here is the call graph for this function:

◆ ifx_i2c_prl_prf()

_STATIC_H optiga_lib_status_t ifx_i2c_prl_prf ( ifx_i2c_context_t p_ctx)
Here is the call graph for this function:

◆ ifx_i2c_prl_send_alert()

_STATIC_H optiga_lib_status_t ifx_i2c_prl_send_alert ( ifx_i2c_context_t p_ctx)
Here is the call graph for this function:

◆ ifx_i2c_prl_transceive()

optiga_lib_status_t ifx_i2c_prl_transceive ( ifx_i2c_context_t p_ctx,
uint8_t *  p_tx_data,
uint16_t  tx_data_len,
uint8_t *  p_rx_data,
uint16_t *  p_rx_data_len 
)

Function to transmit and receive a packet.

Asynchronous function to send and receive protected/unprotected packet

  • The function returns immediately.
  • One of the following events is propagated to the event handler registered with ifx_i2c_prl_init
Precondition
  • None
Note
  • None
Parameters
[in,out]p_ctxPointer to ifx i2c context.
[in]p_tx_dataPointer to the buffer containing the data to be transmitted.
[in]tx_data_lenTransmit data length.
[in]p_rx_dataPointer to the buffer to store the data received.
[in]p_rx_data_lenPointer to a variable to store the received data length
Return values
IFX_I2C_STACK_SUCCESSIf function was successful.
IFX_I2C_HANDSHAKE_ERRORIf establishing a secure channel fails.
IFX_I2C_SESSION_ERRORIf an established secure channel is closed.
IFX_I2C_STACK_ERRORIf the module is busy.
Here is the call graph for this function: