Go to the source code of this file.
|
| typedef struct abstract_aes_key | abstract_aes_key_t |
| | The opaque abstract aes key struct to be implemented by the backend. More...
|
| |
| typedef uint32_t(* | ndn_aes_get_key_size_impl) (const abstract_aes_key_t *aes_key) |
| | The APIs that are supposed to be implemented by the backend. More...
|
| |
| typedef const uint8_t *(* | ndn_aes_get_key_value_impl) (const abstract_aes_key_t *aes_key) |
| |
| typedef int(* | ndn_aes_load_key_impl) (abstract_aes_key_t *aes_key, const uint8_t *key_value, uint32_t key_size) |
| |
| typedef int(* | ndn_aes_cbc_encrypt_impl) (const uint8_t *input_value, uint8_t input_size, uint8_t *output_value, uint8_t output_size, const uint8_t *aes_iv, const abstract_aes_key_t *aes_key) |
| |
| typedef int(* | ndn_aes_cbc_decrypt_impl) (const uint8_t *input_value, uint8_t input_size, uint8_t *output_value, uint8_t output_size, const uint8_t *aes_iv, const abstract_aes_key_t *aes_key) |
| |
| typedef uint32_t(* | ndn_aes_probe_padding_size_impl) (uint32_t plaintext_size) |
| |
| typedef uint32_t(* | ndn_aes_parse_unpadding_size_impl) (uint8_t *plaintext_value, uint32_t plaintext_size) |
| |
| typedef struct ndn_aes_backend | ndn_aes_backend_t |
| | The structure to represent the backend implementation. More...
|
| |
| typedef struct ndn_aes_key | ndn_aes_key_t |
| | The structure to keep an AES-128 key. More...
|
| |
|
| ndn_aes_backend_t * | ndn_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...
|
| |
| static int | ndn_aes_key_init (ndn_aes_key_t *key, const uint8_t *key_value, uint32_t key_size, uint32_t key_id) |
| | Initialize an AES-128 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...
|
| |
◆ abstract_aes_key_t
The opaque abstract aes key struct to be implemented by the backend.
◆ ndn_aes_backend_t
The structure to represent the backend implementation.
◆ ndn_aes_cbc_decrypt_impl
| typedef int(* ndn_aes_cbc_decrypt_impl) (const uint8_t *input_value, uint8_t input_size, uint8_t *output_value, uint8_t output_size, const uint8_t *aes_iv, const abstract_aes_key_t *aes_key) |
◆ ndn_aes_cbc_encrypt_impl
| typedef int(* ndn_aes_cbc_encrypt_impl) (const uint8_t *input_value, uint8_t input_size, uint8_t *output_value, uint8_t output_size, const uint8_t *aes_iv, const abstract_aes_key_t *aes_key) |
◆ ndn_aes_get_key_size_impl
The APIs that are supposed to be implemented by the backend.
◆ ndn_aes_get_key_value_impl
◆ ndn_aes_key_t
The structure to keep an AES-128 key.
◆ ndn_aes_load_key_impl
| typedef int(* ndn_aes_load_key_impl) (abstract_aes_key_t *aes_key, const uint8_t *key_value, uint32_t key_size) |
◆ ndn_aes_parse_unpadding_size_impl
| typedef uint32_t(* ndn_aes_parse_unpadding_size_impl) (uint8_t *plaintext_value, uint32_t plaintext_size) |
◆ ndn_aes_probe_padding_size_impl
| typedef uint32_t(* ndn_aes_probe_padding_size_impl) (uint32_t plaintext_size) |
◆ 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_get_key_size()
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_key_init()
| static int ndn_aes_key_init |
( |
ndn_aes_key_t * |
key, |
|
|
const uint8_t * |
key_value, |
|
|
uint32_t |
key_size, |
|
|
uint32_t |
key_id |
|
) |
| |
|
inlinestatic |
Initialize an AES-128 key.
- Parameters
-
| key. | Input. The HMAC key whose info will be set. |
| key_value. | Input. The key value bytes to set. |
| key_size. | Input. The key size. Should not larger than 32 bytes. |
| key_id. | Input. The key id to be set with this key. |
- Returns
- 0 if there is no error.
◆ 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.