Wirepas SDK
aessw.h File Reference

Go to the source code of this file.

Functions

void aes_setupStream (aes_data_stream_t *stream_ptr, const uint8_t *key128_ptr, const uint8_t *iv_ctr_ptr)
 Setup generic AES128 CTR mode stream. More...
 
void aes_initOmac1 (aes_omac1_state_t *state_ptr, const uint8_t *mic_key_ptr)
 Initializes an OMAC1 state. More...
 
void aes_omac1 (aes_omac1_state_t *state, uint8_t *mic_out_ptr, uint_fast8_t mic_out_bytes, const uint8_t *intext_ptr, size_t intext_bytes)
 Calculate and write out OMAC1 (CMAC) MIC for input text. More...
 
void aes_crypto128Ctr (aes_data_stream_t *stream_ptr, const uint8_t *intext_ptr, uint8_t *outtext_ptr, size_t bytecount)
 Run the AES128 cryptography in CTR mode. More...
 

Data Structures

union  aes_128_t
 For storing 128bit keys, IVs, MACs etc. Allows both byte and faster 32-bit word-aligned access. More...
 
struct  aes_data_stream_t
 AES-128 key, input data and output data. More...
 
struct  aes_omac1_state_t
 AES-128 OMAC1 state. More...
 
union  aes_data_stream_t.__unnamed__
 

Macros

#define AES_128_KEY_BLOCK_SIZE   16
 AES 128 block size in bytes. More...
 

Function Documentation

◆ aes_crypto128Ctr()

void aes_crypto128Ctr ( aes_data_stream_t stream_ptr,
const uint8_t *  intext_ptr,
uint8_t *  outtext_ptr,
size_t  bytecount 
)

Run the AES128 cryptography in CTR mode.

Note
This is a software implementation based on tiny AES. The same algorithm handles both encryption and decryption. The receiver must know the initial iv_ctr for decryption. The stream.iv_ctr is autoincremented after every AES block exec. Supports partial operation: data can be split to consecutive parts, provided that the splits are done at 16-byte boundaries.
Parameters
stream_ptrPointer to aes_data_stream_t to be used
intext_ptrPointer to input text
outtext_ptrPointer to output text. Supports intext overwrite
bytecountNumber of bytes to handle
Examples
aes/app.c.

◆ aes_initOmac1()

void aes_initOmac1 ( aes_omac1_state_t state_ptr,
const uint8_t *  mic_key_ptr 
)

Initializes an OMAC1 state.

Parameters
state_ptrPointer to aes_omac1_state_t to be set up
mic_key_ptrPointer to the secret 16-byte MIC key, which is no longer needed after this function returns
Examples
aes/app.c.

◆ aes_omac1()

void aes_omac1 ( aes_omac1_state_t state,
uint8_t *  mic_out_ptr,
uint_fast8_t  mic_out_bytes,
const uint8_t *  intext_ptr,
size_t  intext_bytes 
)

Calculate and write out OMAC1 (CMAC) MIC for input text.

Note
This is a software implementation based on tiny AES. NIST recommends using at least 8 byte MICs. See "NIST Special Publication 800-38B" appendix A and B.
Parameters
statePointer to OMAC1 AES-128 state
mic_out_ptrPointer for writing MIC
mic_out_bytesAmount of MIC bytes wanted (1...16)
intext_ptrPointer to input text
intext_bytesLength of input text
Examples
aes/app.c.

◆ aes_setupStream()

void aes_setupStream ( aes_data_stream_t stream_ptr,
const uint8_t *  key128_ptr,
const uint8_t *  iv_ctr_ptr 
)

Setup generic AES128 CTR mode stream.

Parameters
stream_ptrPointer to aes_data_stream_t to be set up
key128_ptrPointer to key, copied to the stream struct
iv_ctr_ptrPointer to iv_ctr, copied to the stream struct
Examples
aes/app.c.

Data Structure Documentation

◆ aes_128_t

union aes_128_t

For storing 128bit keys, IVs, MACs etc. Allows both byte and faster 32-bit word-aligned access.

Definition at line 19 of file aessw.h.

Data Fields
uint8_t bytes[16]
uint32_t words[4]

◆ aes_data_stream_t

struct aes_data_stream_t

AES-128 key, input data and output data.

Every independent stream cipher flow should have one of these. This structure layout was created specifically for the Nordic nRF51822 AES ECB peripheral. However, this software implementations also use the same structure, for symmetry.

Examples
aes/app.c.

Definition at line 33 of file aessw.h.

Data Fields
union aes_data_stream_t __unnamed__
uint32_t aes_out[4]
uint32_t key[4]

◆ aes_omac1_state_t

struct aes_omac1_state_t

AES-128 OMAC1 state.

This state contains the HL1 and HL2 subkeys, so that they don't need to be recalculated when switching between authentication keys.

Examples
aes/app.c.

Definition at line 50 of file aessw.h.

Data Fields
aes_data_stream_t data
aes_128_t hl1
aes_128_t hl2

◆ aes_data_stream_t.__unnamed__

union aes_data_stream_t.__unnamed__

Definition at line 36 of file aessw.h.

Data Fields
uint32_t aes_in[4]
uint32_t iv_ctr[4]

Macro Definition Documentation

◆ AES_128_KEY_BLOCK_SIZE

#define AES_128_KEY_BLOCK_SIZE   16

AES 128 block size in bytes.

Examples
aes/app.c.

Definition at line 13 of file aessw.h.