HAL_CCM_ALT

MBEDTLS IMPLEMENTATION HAL CCM ALT FUNCTIONS

group MBEDTLS_IMPLEMENTATION_HAL_CCM_ALT_FUNCTIONS

Public API functions for HAL CCM alternate implementation.

Defines

CCM_STATE__CLEAR
CCM_STATE__STARTED
CCM_STATE__LENGTHS_SET
CCM_STATE__AUTH_DATA_STARTED
CCM_STATE__AUTH_DATA_FINISHED
CCM_STATE__ERROR

Functions

void mbedtls_ccm_init ( mbedtls_ccm_context * ctx )

initializes the specified CCM context

int mbedtls_ccm_setkey ( mbedtls_ccm_context * ctx , mbedtls_cipher_id_t cipher , const unsigned char * key , unsigned int keybits )
void mbedtls_ccm_free ( mbedtls_ccm_context * ctx )

Free context.

int mbedtls_ccm_starts ( mbedtls_ccm_context * ctx , int mode , const unsigned char * iv , size_t iv_len )

This function starts a CCM encryption or decryption operation.

int mbedtls_ccm_set_lengths ( mbedtls_ccm_context * ctx , size_t total_ad_len , size_t plaintext_len , size_t tag_len )
int mbedtls_ccm_update_ad ( mbedtls_ccm_context * ctx , const unsigned char * add , size_t add_len )

feeds an input buffer as associated data in a CCM encryption or decryption operation.

int mbedtls_ccm_update ( mbedtls_ccm_context * ctx , const unsigned char * input , size_t input_len , unsigned char * output , size_t output_size , size_t * output_len )

feeds an input buffer into an ongoing CCM encryption or decryption operation.

int mbedtls_ccm_finish ( mbedtls_ccm_context * ctx , unsigned char * output , size_t output_size , size_t * ciphertext_length , unsigned char * tag , size_t tag_len )

This function finishes the CCM operation and generates the authentication tag.

int mbedtls_ccm_star_encrypt_and_tag ( mbedtls_ccm_context * ctx , size_t length , const unsigned char * iv , size_t iv_len , const unsigned char * add , size_t add_len , const unsigned char * input , unsigned char * output , unsigned char * tag , size_t tag_len )

Authenticated encryption.

int mbedtls_ccm_encrypt_and_tag ( mbedtls_ccm_context * ctx , size_t length , const unsigned char * iv , size_t iv_len , const unsigned char * add , size_t add_len , const unsigned char * input , unsigned char * output , unsigned char * tag , size_t tag_len )
int mbedtls_ccm_star_auth_decrypt ( mbedtls_ccm_context * ctx , size_t length , const unsigned char * iv , size_t iv_len , const unsigned char * add , size_t add_len , const unsigned char * input , unsigned char * output , const unsigned char * tag , size_t tag_len )
int mbedtls_ccm_auth_decrypt ( mbedtls_ccm_context * ctx , size_t length , const unsigned char * iv , size_t iv_len , const unsigned char * add , size_t add_len , const unsigned char * input , unsigned char * output , const unsigned char * tag , size_t tag_len )

MBEDTLS IMPLEMENTATION HAL CCM TYPES

group MBEDTLS_IMPLEMENTATION_HAL_CCM_TYPES

This file provides an API for the CCM authenticated encryption mode for block ciphers based on STM32 AES hardware crypto accelerator.

CCM combines Counter mode encryption with CBC-MAC authentication for 128-bit block ciphers.

Input to CCM includes the following elements:

  • Payload - data that is both authenticated and encrypted.

  • Associated data (Adata) - data that is authenticated but not encrypted, For example, a header.

  • Nonce - A unique value that is assigned to the payload and the associated data.

Definition of CCM: http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf RFC 3610 “Counter with CBC-MAC (CCM)”

Related: RFC 5116 “An Interface and Algorithms for Authenticated Encryption”

Definition of CCM*: IEEE 802.15.4 - IEEE Standard for Local and metropolitan area networks Integer representation is fixed most-significant-octet-first order and the representation of octets is most-significant-bit-first order. This is consistent with RFC 3610.

The CCM context-type definition. The CCM context is passed to the APIs called.

struct mbedtls_ccm_context
#include <hal_ccm_alt.h>

AES context structure.

Public Members

hal_aes_ccm_config_t p_ccm_config

AES CCM configuration structure

hal_cryp_ccm_config_t p_ccm_config

CRYP CCM configuration structure

uint32_t Keysize

Key size

uint32_t ccm_key [ 8 ]

Encryption/Decryption key

uint32_t ctx_save_cr

Save context for multi-instance

unsigned char y [ 16 ]

The Y working buffer

size_t plaintext_len

Total plaintext length

size_t add_len

Total authentication data length

size_t tag_len

Total tag length

unsigned int q

The Q working value

int mode

The operation to perform: #MBEDTLS_CCM_ENCRYPT or #MBEDTLS_CCM_DECRYPT or #MBEDTLS_CCM_STAR_ENCRYPT or #MBEDTLS_CCM_STAR_DECRYPT.

Mode : encrypt or decrypt

unsigned int state

Working value holding context’s state. Used for chunked data input

uint8_t aes_key [ 32 ]

Encryption/Decryption key

size_t aes_key_size

Aes Key size

cmox_cipher_handle_t * cipher_ctx

Cipher ctx

cmox_ccm_handle_t ccm_ctx

ccm ctx

uint32_t iv_len_copy

IV length copy