ndn-lite
Functions | Variables
ndn-lite-aes.c File Reference
#include "ndn-lite-aes.h"

Functions

ndn_aes_backend_tndn_aes_get_backend (void)
 
uint32_t ndn_aes_get_key_size (const ndn_aes_key_t *aes_key)
 Get aes key size in unit of byte. More...
 
const uint8_t * ndn_aes_get_key_value (const ndn_aes_key_t *aes_key)
 Get aes key bytes. More...
 
int ndn_aes_load_key (ndn_aes_key_t *aes_key, const uint8_t *key_value, uint32_t key_size)
 Load in-memory key bits into an NDN aes key. More...
 
int ndn_aes_cbc_encrypt (const uint8_t *input_value, uint8_t input_size, uint8_t *output_value, uint8_t output_size, const uint8_t *aes_iv, const ndn_aes_key_t *aes_key)
 Use AES-128-CBC algorithm to encrypt a buffer. More...
 
int ndn_aes_cbc_decrypt (const uint8_t *input_value, uint8_t input_size, uint8_t *output_value, uint8_t output_size, const uint8_t *aes_iv, const ndn_aes_key_t *aes_key)
 Use AES-128-CBC algorithm to decrypt an encrypted buffer. More...
 
uint32_t ndn_aes_probe_padding_size (uint32_t plaintext_size)
 Probe after padding size of plaintext. More...
 
uint32_t ndn_aes_parse_unpadding_size (uint8_t *plaintext_value, uint32_t plaintext_size)
 Parse the orginal plaintext size after stripping padding byte. More...
 

Variables

ndn_aes_backend_t ndn_aes_backend
 

Function Documentation

◆ ndn_aes_cbc_decrypt()

int ndn_aes_cbc_decrypt ( const uint8_t *  input_value,
uint8_t  input_size,
uint8_t *  output_value,
uint8_t  output_size,
const uint8_t *  aes_iv,
const ndn_aes_key_t aes_key 
)

Use AES-128-CBC algorithm to decrypt an encrypted buffer.

This function is implemented with padding PKCS#7, but should call additional function to parse the unpadding size.

Parameters
input_value.Input. Buffer to decrypt.
input_size.Input. Size of input buffer.
output_value.Output. Decrypted buffer.
output_size.Input. Size of decrypted buffer.
aes_iv.Input. AES Initialization Vector, whose length should be NDN_AES_BLOCK_SIZE.
key_value.Input. AES-128 key to perform decryption. Should be same as encryption key.
key_size.Input. Size of used AES-128 key.
Returns
NDN_SUCCESS if there is no error.

◆ ndn_aes_cbc_encrypt()

int ndn_aes_cbc_encrypt ( const uint8_t *  input_value,
uint8_t  input_size,
uint8_t *  output_value,
uint8_t  output_size,
const uint8_t *  aes_iv,
const ndn_aes_key_t aes_key 
)

Use AES-128-CBC algorithm to encrypt a buffer.

This function performs PKCS#7 padding. The input_size must be a multiple of NDN_AES_BLOCK_SIZE to obtain a successful encryption.

Parameters
input_value.Input. Buffer to encrypt.
input_size.Input. Size of input buffer.
output_value.Output. Encrypted buffer.
output_size.Input. Size of encrypted buffer.
aes_iv.Input. AES Initialization Vector, whose length should be NDN_AES_BLOCK_SIZE.
key_value.Input. AES-128 key to perform encryption.
key_size.Input. Size of used AES-128 key.
Returns
NDN_SUCCESS if there is no error.

◆ ndn_aes_get_backend()

ndn_aes_backend_t* ndn_aes_get_backend ( void  )

◆ ndn_aes_get_key_size()

uint32_t ndn_aes_get_key_size ( const ndn_aes_key_t aes_key)

Get aes key size in unit of byte.

Parameters
aes_key.Input. NDN aes key.

◆ ndn_aes_get_key_value()

const uint8_t* ndn_aes_get_key_value ( const ndn_aes_key_t aes_key)

Get aes key bytes.

Parameters
aes_key.Input. NDN aes key.

◆ ndn_aes_load_key()

int ndn_aes_load_key ( ndn_aes_key_t aes_key,
const uint8_t *  key_value,
uint32_t  key_size 
)

Load in-memory key bits into an NDN aes key.

Parameters
aes_key.Output. NDN aes key.
key_value.Input. Key bytes.
key_size.Input. The size of the key bytes.

◆ ndn_aes_parse_unpadding_size()

uint32_t ndn_aes_parse_unpadding_size ( uint8_t *  plaintext_value,
uint32_t  plaintext_size 
)

Parse the orginal plaintext size after stripping padding byte.

Input size should be multiple of NDN_AES_BLOCK_SIZE.

Parameters
plaintext_value.Input. Input buffer before unpadding.
plaintext_size.Input. Size of input buffer.
Returns
original plaintext size.

◆ ndn_aes_probe_padding_size()

uint32_t ndn_aes_probe_padding_size ( uint32_t  plaintext_size)

Probe after padding size of plaintext.

Ouput should be multiple of NDN_AES_BLOCK_SIZE.

Parameters
plaintext_size.Input. Size of original plaintext.
Returns
after padding size.

Variable Documentation

◆ ndn_aes_backend