12 #include "cx_errors.h"
19 #define MAX_IV_LENGTH 16
21 #define MAX_BLOCK_LENGTH 16
25 #define CMAC_MAX_BLOCK_LENGTH (16)
29 uint8_t state[CMAC_MAX_BLOCK_LENGTH];
30 uint8_t unprocessed_block[CMAC_MAX_BLOCK_LENGTH];
31 size_t unprocessed_len;
64 cx_err_t (*ctx_reset)(void);
72 #if !defined(BOLOS_OS_UPGRADER_APP)
85 void (*add_padding)(
uint8_t *output,
size_t out_len,
size_t data_len);
97 cx_cmac_context_t *cmac_ctx;
AES (Advanced Encryption Standard).
void cx_cipher_reset(cx_cipher_context_t *ctx)
void add_one_and_zeros_padding(uint8_t *output, size_t out_len, size_t data_len)
WARN_UNUSED_RESULT cx_err_t cx_cipher_update(cx_cipher_context_t *ctx, const uint8_t *input, size_t in_len, uint8_t *output, size_t *out_len)
Encrypt or decrypt with the given context.
@ CX_CIPHER_AES_192
AES with a 192-bit key.
@ CX_CIPHER_NONE
No cipher.
@ CX_CIPHER_AES_256
AES with a 256-bit key.
@ CX_CIPHER_AES_128
AES with a 128-bit key.
WARN_UNUSED_RESULT cx_err_t cx_cipher_setkey(cx_cipher_context_t *ctx, const uint8_t *key, uint32_t key_bitlen, uint32_t operation)
Set the key to use.
WARN_UNUSED_RESULT cx_err_t cx_cipher_setiv(cx_cipher_context_t *ctx, const uint8_t *iv, size_t iv_len)
Set the initialization vector.
WARN_UNUSED_RESULT cx_err_t cx_cipher_init(cx_cipher_context_t *ctx)
Initialize a cipher context as NONE.
WARN_UNUSED_RESULT cx_err_t cx_cipher_finish(cx_cipher_context_t *ctx, uint8_t *output, size_t *out_len)
Finalize the operation.
WARN_UNUSED_RESULT cx_err_t cx_cipher_setup(cx_cipher_context_t *ctx, const cx_cipher_id_t type, uint32_t mode)
Initialize and fill the context structure given the cipher info.
WARN_UNUSED_RESULT cx_err_t cx_cipher_enc_dec(cx_cipher_context_t *ctx, const uint8_t *iv, size_t iv_len, const uint8_t *input, size_t in_len, uint8_t *output, size_t *out_len)
All-in-one encryption or decryption.
WARN_UNUSED_RESULT cx_err_t cx_cipher_set_padding(cx_cipher_context_t *ctx, uint32_t padding)
Set the padding type.
uint32_t mode
Mode of operation: ECB, CBC, CTR.
size_t iv_size
Length of the initialization vector.
uint32_t operation
Operation: encryption or decryption.
uint32_t key_bitlen
Key size in bits.
const cipher_key_t * cipher_key
Cipher-specific context.
const cx_cipher_info_t * cipher_info
Cipher information.
size_t unprocessed_len
Length of data to process.
const cx_cipher_base_t * base
uint32_t iv_size
Initialization vector size.
uint32_t key_bitlen
Key size.
uint32_t block_size
Block size.