Wirepas SDK
aessw.h
Go to the documentation of this file.
1 /* Copyright 2019 Wirepas Ltd. All Rights Reserved.
2  *
3  * See file LICENSE.txt for full license details.
4  *
5  */
6 
7 #ifndef AESSW_H_
8 #define AESSW_H_
9 
10 #include <stdint.h>
11 
13 #define AES_128_KEY_BLOCK_SIZE 16
14 
19 typedef union
20 {
21  uint32_t words[4];
22  uint8_t bytes[16];
23 } aes_128_t;
24 
33 typedef struct
34 {
35  uint32_t key[4]; // Secret AES-128 key
36  union
37  {
38  uint32_t iv_ctr[4]; // Nonce and counter combined
39  uint32_t aes_in[4]; // Alias for AES input (if not iv_ctr)
40  };
41  uint32_t aes_out[4]; // AES-128 ECB output of last block
43 
50 typedef struct
51 {
52  aes_data_stream_t data; // OMAC1 AES-128 state
53  aes_128_t hl1; // Derived subkey HL1 (for non-padded last block)
54  aes_128_t hl2; // Derived subkey HL2 (for padded last block)
56 
66 void aes_setupStream(aes_data_stream_t * stream_ptr,
67  const uint8_t * key128_ptr,
68  const uint8_t * iv_ctr_ptr);
69 
78 void aes_initOmac1(aes_omac1_state_t * state_ptr, const uint8_t * mic_key_ptr);
79 
91 void aes_omac1(aes_omac1_state_t * state,
92  uint8_t * mic_out_ptr,
93  uint_fast8_t mic_out_bytes,
94  const uint8_t * intext_ptr,
95  size_t intext_bytes);
96 
110 void aes_crypto128Ctr(aes_data_stream_t * stream_ptr,
111  const uint8_t * intext_ptr,
112  uint8_t * outtext_ptr,
113  size_t bytecount);
114 
115 #endif /* AESSW_H_ */
aes_omac1_state_t::hl1
aes_128_t hl1
Definition: aessw.h:53
aes_data_stream_t
AES-128 key, input data and output data.
Definition: aessw.h:33
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.
aes_128_t
For storing 128bit keys, IVs, MACs etc. Allows both byte and faster 32-bit word-aligned access.
Definition: aessw.h:19
aes_omac1_state_t::data
aes_data_stream_t data
Definition: aessw.h:52
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.
aes_omac1_state_t
AES-128 OMAC1 state.
Definition: aessw.h:50
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.
aes_omac1_state_t::hl2
aes_128_t hl2
Definition: aessw.h:54
aes_initOmac1
void aes_initOmac1(aes_omac1_state_t *state_ptr, const uint8_t *mic_key_ptr)
Initializes an OMAC1 state.