This file implements the IFX I2C Presentation Layer of the Infineon I2C Protocol Stack library. More...
#include "ifx_i2c_presentation_layer.h"
#include "ifx_i2c_transport_layer.h"
#include "pal_crypt.h"
#include "optiga_lib_common.h"
#include "pal_ifx_i2c_config.h"
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) |
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
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.
[in,out] | p_ctx | Pointer to ifx i2c context. |
[in] | handler | Function pointer to the event handler of the upper layer. |
IFX_I2C_STACK_SUCCESS | If initialization was successful. |
IFX_I2C_STACK_ERROR | If the module is already initialized. |
_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_do_handshake | ( | ifx_i2c_context_t * | p_ctx, |
const uint8_t * | p_data | ||
) |
Validating decrpt data
Validating sequence number
_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
_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 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
_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 | ||
) |
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
[in,out] | p_ctx | Pointer to ifx i2c context. |
[in] | handler | Function pointer to the event handler of the upper layer. |
IFX_I2C_STACK_SUCCESS | If initialization was successful. |
IFX_I2C_STACK_ERROR | If the module is already initialized. |
_STATIC_H optiga_lib_status_t ifx_i2c_prl_prf | ( | ifx_i2c_context_t * | p_ctx | ) |
_STATIC_H optiga_lib_status_t ifx_i2c_prl_send_alert | ( | ifx_i2c_context_t * | p_ctx | ) |
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
[in,out] | p_ctx | Pointer to ifx i2c context. |
[in] | p_tx_data | Pointer to the buffer containing the data to be transmitted. |
[in] | tx_data_len | Transmit data length. |
[in] | p_rx_data | Pointer to the buffer to store the data received. |
[in] | p_rx_data_len | Pointer to a variable to store the received data length |
IFX_I2C_STACK_SUCCESS | If function was successful. |
IFX_I2C_HANDSHAKE_ERROR | If establishing a secure channel fails. |
IFX_I2C_SESSION_ERROR | If an established secure channel is closed. |
IFX_I2C_STACK_ERROR | If the module is busy. |