Microchip® Advanced Software Framework

crypt.h File Reference
#include "aes.h"
#include <compiler.h>

Data Structures

struct  ctr_blk_t
 Support and FAQ: visit Microchip Support More...
 

Functions

void cbc_decrypt (uint8_t *cipherText, uint8_t *plainText, uint8_t *init_vector, uint32_t size)
 This function performs CBC decryption on input cipher text blocks. More...
 
void cbc_encrypt (uint8_t *plainText, uint8_t *cipherText, uint8_t *init_vector, uint32_t size)
 This function performs CBC encryption on input plain text blocks. More...
 
void cfb_decrypt (uint8_t *cipherText, uint8_t *plainText, uint8_t *init_vector, uint8_t mode, uint32_t size)
 This function performs CFB decryption on input cipher text blocks. More...
 
void cfb_encrypt (uint8_t *plainText, uint8_t *cipherText, uint8_t *init_vector, uint8_t mode, uint32_t size)
 This function performs CFB encryption on input plain text blocks. More...
 
void ctr_encrypt_decrypt (uint8_t *input_block, uint8_t *output_block, ctr_blk_t *counter, uint32_t size)
 This function performs CTR encryption/decryption on input blocks. Note: Both encryption and decryption is same for CTR mode. In both the cases, the input block to the cipher process is the counter. The resulting output is XOR-ed with plain text for encryption. For decryption case, it is XOR-ed with cipher text to retrieve the actual data. More...
 
void ctr_inc_counter (ctr_blk_t *counter)
 Performs counter increment to prepare input for next round. More...
 
void ecb_decrypt (uint8_t *cipherText, uint8_t *plainText, uint32_t size)
 This function performs ECB decryption on input cipher text blocks. More...
 
void ecb_encrypt (uint8_t *plainText, uint8_t *cipherText, uint32_t size)
 This function performs ECB encryption on input plain text blocks. More...
 
void ofb_decrypt (uint8_t *cipherText, uint8_t *plainText, uint8_t *init_vector, uint32_t size)
 This function performs OFB decryption on input cipher text blocks. More...
 
void ofb_encrypt (uint8_t *plainText, uint8_t *cipherText, uint8_t *init_vector, uint32_t size)
 This function performs OFB encryption on input plain text blocks. More...
 

void cbc_decrypt ( uint8_t *  cipherText,
uint8_t *  plainText,
uint8_t *  init_vector,
uint32_t  size 
)

This function performs CBC decryption on input cipher text blocks.

Parameters
cipherTextpointer to the array containing the cipher text bytes
plainTextpointer to the array where the decrypted plain text has to be stored
init_vectorpointer to the array containing the unique initialization vector
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_inverse_cipher().

Referenced by main().

void cbc_encrypt ( uint8_t *  plainText,
uint8_t *  cipherText,
uint8_t *  init_vector,
uint32_t  size 
)

This function performs CBC encryption on input plain text blocks.

Parameters
plainTextpointer to the array containing the plain text bytes
cipherTextpointer to the array where the encrypted cipher output has to be stored
init_vectorpointer to the array containing the unique initialization vector
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_cipher().

Referenced by main().

void cfb_decrypt ( uint8_t *  cipherText,
uint8_t *  plainText,
uint8_t *  init_vector,
uint8_t  mode,
uint32_t  size 
)

This function performs CFB decryption on input cipher text blocks.

Parameters
cipherTextpointer to the array containing the cipher text bytes
plainTextpointer to the array where the decrypted plain text has to be stored
init_vectorpointer to the array containing the unique initialization vector
modeCFB mode in bits - can be 8, 64, 128.
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_cipher().

Referenced by main().

void cfb_encrypt ( uint8_t *  plainText,
uint8_t *  cipherText,
uint8_t *  init_vector,
uint8_t  mode,
uint32_t  size 
)

This function performs CFB encryption on input plain text blocks.

Parameters
plainTextpointer to the array containing the plain text bytes
cipherTextpointer to the array where the encrypted cipher output has to be stored
init_vectorpointer to the array containing the unique initialization vector
modeCFB mode in bits - can be 8, 16, 32, 64, 128.
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_cipher().

Referenced by main().

void ctr_encrypt_decrypt ( uint8_t *  input_block,
uint8_t *  output_block,
ctr_blk_t counter,
uint32_t  size 
)

This function performs CTR encryption/decryption on input blocks. Note: Both encryption and decryption is same for CTR mode. In both the cases, the input block to the cipher process is the counter. The resulting output is XOR-ed with plain text for encryption. For decryption case, it is XOR-ed with cipher text to retrieve the actual data.

Parameters
plainTextpointer to the array containing the plain text bytes
cipherTextpointer to the array where the encrypted cipher output has to be stored
init_vectorpointer to the array containing the unique initialization vector
sizesize of the input plain text

This function performs CTR encryption/decryption on input blocks. Note: Both encryption and decryption is same for CTR mode. In both the cases, the input block to the cipher process is the counter. The resulting output is XOR-ed with plain text for encryption. For decryption case, it is XOR-ed with cipher text to retrieve the actual data.

Parameters
plainTextpointer to the array containing the plain text bytes
cipherTextpointer to the array where the encrypted cipher output has to be stored
counterpointer to the structure containing the counter block
sizesize of the input plain text

References AES_BLOCK_SIZE, aes_cipher(), ctr_blk_t::counter, counter_block, ctr_inc_counter(), ctr_blk_t::i_vector, and ctr_blk_t::nonce.

Referenced by main().

void ctr_inc_counter ( ctr_blk_t counter)

Performs counter increment to prepare input for next round.

Parameters
countervalue of counter used in CTR mode

References ctr_blk_t::counter, counter_block, ctr_blk_t::i_vector, and ctr_blk_t::nonce.

Referenced by ctr_encrypt_decrypt().

void ecb_decrypt ( uint8_t *  cipherText,
uint8_t *  plainText,
uint32_t  size 
)

This function performs ECB decryption on input cipher text blocks.

Parameters
cipherTextpointer to the array containing the cipher text bytes
plainTextpointer to the array where the decrypted plain text has to be stored
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_inverse_cipher().

Referenced by main().

void ecb_encrypt ( uint8_t *  plainText,
uint8_t *  cipherText,
uint32_t  size 
)

This function performs ECB encryption on input plain text blocks.

Parameters
plainTextpointer to the array containing the plain text bytes
cipherTextpointer to the array where the encrypted cipher output has to be stored
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_cipher().

Referenced by main().

void ofb_decrypt ( uint8_t *  cipherText,
uint8_t *  plainText,
uint8_t *  init_vector,
uint32_t  size 
)

This function performs OFB decryption on input cipher text blocks.

Parameters
cipherTextpointer to the array containing the cipher text bytes
plainTextpointer to the array where the decrypted plain text has to be stored
init_vectorpointer to the array containing the unique initialization vector
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_cipher().

void ofb_encrypt ( uint8_t *  plainText,
uint8_t *  cipherText,
uint8_t *  init_vector,
uint32_t  size 
)

This function performs OFB encryption on input plain text blocks.

Parameters
plainTextpointer to the array containing the plain text bytes
cipherTextpointer to the array where the encrypted cipher output has to be stored
init_vectorpointer to the array containing the unique initialization vector
sizesize of the input plain text

References AES_BLOCK_SIZE, and aes_cipher().

Referenced by main().