Cpc_security_secondary

Description

CPC Security Secondary.

Get the setup status of the security subsystem.

Returns
The setup status of the security subsystem

Functions

sl_cpc_security_state_t sl_cpc_security_get_state (void)
void sl_cpc_security_fetch_user_specified_binding_key (uint8_t **key, uint16_t *key_size_in_bytes)
User callback to provide CPC with a binding key.
void sl_cpc_security_init (void)
Security endpoint init.
sl_status_t sl_cpc_security_encrypt (const uint8_t address, const uint8_t *header, const size_t header_len, uint8_t *paylaod, const size_t payload_len, uint8_t *tag, const size_t tag_len)
Encrypt a message.
sl_status_t sl_cpc_security_decrypt (const uint8_t *header, const size_t header_len, uint8_t *payload, const size_t buffer_size, const size_t payload_len, size_t *output_len)
Decrypt a message.
void sl_cpc_security_drop_incoming_packet (void)
Abort a received encrypted message.
uint64_t sl_cpc_security_on_unbind_request (bool is_link_encrypted)
Way for the user to allow an unbind request or not.
sl_status_t sl_cpc_security_unbind_subscribe ( sl_cpc_unbind_notification_handle_t *handle, sl_cpc_unbind_notification_callback_t callback, void *data)
Register a callback that will be called when an unbind event occurs.
sl_status_t sl_cpc_security_unbind_unsubscribe ( sl_cpc_unbind_notification_handle_t *handle)
Unregister a callback that will be called when an unbind event occurs.

Function Documentation

sl_cpc_security_fetch_user_specified_binding_key()

void sl_cpc_security_fetch_user_specified_binding_key ( uint8_t ** key,
uint16_t * key_size_in_bytes
)

User callback to provide CPC with a binding key.

SL_CPC_SECURITY_BINDING_KEY_METHOD config must be set to SL_CPC_SECURITY_BINDING_KEY_CUSTOMER_SPECIFIC

Parameters
[out] key The encryption key
[out] key_size The encryption key size Note: Only 16 bytes keys are supported for the moment

sl_cpc_security_init()

void sl_cpc_security_init ( void )

Security endpoint init.

sl_cpc_security_encrypt()

sl_status_t sl_cpc_security_encrypt ( const uint8_t address,
const uint8_t * header,
const size_t header_len,
uint8_t * paylaod,
const size_t payload_len,
uint8_t * tag,
const size_t tag_len
)

Encrypt a message.

The security subsystem must be initialized for this function to work properly. Upon success, the content in the payload buffer is replaced with encrypted content.

Parameters
[in] header buffer containing authenticated and non-encrypted data
[in] header_len length of the authenticated data buffer
[in,out] payload buffer containing data to be encrypted
[in] payload_len length of cleartext data in the payload buffer
[out] tag buffer to store the security tag
[in] tag_len length of the security tag buffer.

sl_cpc_security_decrypt()

sl_status_t sl_cpc_security_decrypt ( const uint8_t * header,
const size_t header_len,
uint8_t * payload,
const size_t buffer_size,
const size_t payload_len,
size_t * output_len
)

Decrypt a message.

The security subsystem must be initialized for this function to work properly.

Parameters
[in] header buffer containing authenticated and non-encrypted data
[in] header_len length of the authenticated data buffer
[in,out] payload buffer containing encrypted data
[in] buffer_size size of payload buffer, to prevent overflow when decrypting
[in] payload_len length of encrypted data in the payload buffer
[in,out] output_len length of the plaintext data upon successful decryption.

sl_cpc_security_drop_incoming_packet()

void sl_cpc_security_drop_incoming_packet ( void )

Abort a received encrypted message.

The security subsystem uses a frame_counter to track the amount of frames sent from the remote. When rejecting a frame, we must still take it into account even if it is not decrypted.

sl_cpc_security_on_unbind_request()

uint64_t sl_cpc_security_on_unbind_request ( bool is_link_encrypted )

Way for the user to allow an unbind request or not.

Note
Declared as a weak symbol. If no strong definition is given by the user then unbind requests are always allowed. If the user gives a definition for this function, then its return value will dictate if unbind requests are accepted
Returns
Whether to allow unbind or not, use SL_CPC_SECURITY_OK_TO_UNBIND as a return value to allow. Return anything else to deny.

sl_cpc_security_unbind_subscribe()

sl_status_t sl_cpc_security_unbind_subscribe ( sl_cpc_unbind_notification_handle_t * handle,
sl_cpc_unbind_notification_callback_t callback,
void * data
)

Register a callback that will be called when an unbind event occurs.

Parameters
[in] handle pointer to the unbind notification handle.
[in] callback pointer to the unbind notification callback.
[in] data pointer to pass to the unbind notification callback.
Returns
Status code

sl_cpc_security_unbind_unsubscribe()

sl_status_t sl_cpc_security_unbind_unsubscribe ( sl_cpc_unbind_notification_handle_t * handle )

Unregister a callback that will be called when an unbind event occurs.

Parameters
[in] handle pointer to the unbind notification handle.
Returns
Status code