![]() |
ndn-lite
|
Go to the source code of this file.
Data Structures | |
struct | ndn_hmac_backend |
The structure to represent the backend implementation. More... | |
struct | ndn_hmac_key |
The structure to keep a HMAC key. More... | |
Typedefs | |
typedef struct abstract_hmac_key | abstract_hmac_key_t |
The opaque abstract hmac key struct to be implemented by the backend. More... | |
typedef uint32_t(* | ndn_hmac_get_key_size_impl) (const abstract_hmac_key_t *hmac_key) |
The APIs that are supposed to be implemented by the backend. More... | |
typedef const uint8_t *(* | ndn_hmac_get_key_value_impl) (const abstract_hmac_key_t *hmac_key) |
typedef int(* | ndn_hmac_load_key_impl) (abstract_hmac_key_t *hmac_key, const uint8_t *key_value, uint32_t key_size) |
typedef int(* | ndn_hmac_sha256_impl) (const void *payload, uint32_t payload_length, const abstract_hmac_key_t *hmac_key, uint8_t *hmac_result) |
typedef int(* | ndn_hmac_make_key_impl) (abstract_hmac_key_t *key, const uint8_t *input_value, uint32_t input_size, const uint8_t *personalization, uint32_t personalization_size, const uint8_t *seed_value, uint32_t seed_size, const uint8_t *additional_value, uint32_t additional_size, uint32_t salt_size) |
typedef int(* | ndn_hkdf_impl) (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_size, const uint8_t *seed_value, uint32_t seed_size) |
typedef int(* | ndn_hmacprng_impl) (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_size, const uint8_t *seed_value, uint32_t seed_size, const uint8_t *additional_value, uint32_t additional_size) |
typedef struct ndn_hmac_backend | ndn_hmac_backend_t |
The structure to represent the backend implementation. More... | |
typedef struct ndn_hmac_key | ndn_hmac_key_t |
The structure to keep a HMAC key. More... | |
Functions | |
ndn_hmac_backend_t * | ndn_hmac_get_backend (void) |
uint32_t | ndn_hmac_get_key_size (const ndn_hmac_key_t *hmac_key) |
Get hmac key size in unit of byte. More... | |
const uint8_t * | ndn_hmac_get_key_value (const ndn_hmac_key_t *hmac_key) |
Get hmac key bytes. More... | |
int | ndn_hmac_load_key (ndn_hmac_key_t *hmac_key, const uint8_t *key_value, uint32_t key_size) |
Load in-memory key bits into an NDN hmac key. More... | |
static int | ndn_hmac_key_init (ndn_hmac_key_t *hmac_key, const uint8_t *key_value, uint32_t key_size, uint32_t key_id) |
Initialize a HMAC key. More... | |
int | ndn_hmac_sha256 (const void *payload, uint32_t payload_length, const ndn_hmac_key_t *hmac_key, uint8_t *hmac_result) |
Generate HMAC using sha256 digest algorithm. More... | |
int | ndn_hmac_sign (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_max_size, const ndn_hmac_key_t *hmac_key, uint32_t *output_used_size) |
Sign a buffer using HMAC algorithm. More... | |
int | ndn_hmac_verify (const uint8_t *input_value, uint32_t input_size, const uint8_t *sig_value, uint32_t sig_size, const ndn_hmac_key_t *hmac_key) |
Verify a HMAC signature. More... | |
int | ndn_hmac_make_key (ndn_hmac_key_t *key, uint32_t key_id, const uint8_t *input_value, uint32_t input_size, const uint8_t *personalization, uint32_t personalization_size, const uint8_t *seed_value, uint32_t seed_size, const uint8_t *additional_value, uint32_t additional_size, uint32_t salt_size) |
Generate a HMAC key with specific key size and key id. More... | |
int | ndn_hkdf (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_size, const uint8_t *seed_value, uint32_t seed_size) |
Use HMAC-KDF (key derivation function) to generate a secure HMAC key. More... | |
int | ndn_hmacprng (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_size, const uint8_t *seed_value, uint32_t seed_size, const uint8_t *additional_value, uint32_t additional_size) |
Use HMAC-PRNG algorithm to generate pseudo-random bytes. More... | |
typedef struct abstract_hmac_key abstract_hmac_key_t |
The opaque abstract hmac key struct to be implemented by the backend.
typedef int(* ndn_hkdf_impl) (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_size, const uint8_t *seed_value, uint32_t seed_size) |
typedef struct ndn_hmac_backend ndn_hmac_backend_t |
The structure to represent the backend implementation.
typedef uint32_t(* ndn_hmac_get_key_size_impl) (const abstract_hmac_key_t *hmac_key) |
The APIs that are supposed to be implemented by the backend.
typedef const uint8_t*(* ndn_hmac_get_key_value_impl) (const abstract_hmac_key_t *hmac_key) |
typedef struct ndn_hmac_key ndn_hmac_key_t |
The structure to keep a HMAC key.
typedef int(* ndn_hmac_load_key_impl) (abstract_hmac_key_t *hmac_key, const uint8_t *key_value, uint32_t key_size) |
typedef int(* ndn_hmac_make_key_impl) (abstract_hmac_key_t *key, const uint8_t *input_value, uint32_t input_size, const uint8_t *personalization, uint32_t personalization_size, const uint8_t *seed_value, uint32_t seed_size, const uint8_t *additional_value, uint32_t additional_size, uint32_t salt_size) |
typedef int(* ndn_hmac_sha256_impl) (const void *payload, uint32_t payload_length, const abstract_hmac_key_t *hmac_key, uint8_t *hmac_result) |
typedef int(* ndn_hmacprng_impl) (const uint8_t *input_value, uint32_t input_size, uint8_t *output_value, uint32_t output_size, const uint8_t *seed_value, uint32_t seed_size, const uint8_t *additional_value, uint32_t additional_size) |
int ndn_hkdf | ( | const uint8_t * | input_value, |
uint32_t | input_size, | ||
uint8_t * | output_value, | ||
uint32_t | output_size, | ||
const uint8_t * | seed_value, | ||
uint32_t | seed_size | ||
) |
Use HMAC-KDF (key derivation function) to generate a secure HMAC key.
This function requires proper entropy source.
input_value. | Input. Random input that requires KDF. |
input_size. | Input. Random input length in bytes. |
output_value. | Output. Buffer to receive output. |
output_size. | Input. Size of the output buffer. |
seed_value. | Input. Entropy to mix into the prng. |
seed_size. | Input. Entropy length in bytes. |
ndn_hmac_backend_t* ndn_hmac_get_backend | ( | void | ) |
uint32_t ndn_hmac_get_key_size | ( | const ndn_hmac_key_t * | hmac_key | ) |
Get hmac key size in unit of byte.
hmac_key. | Input. NDN hmac key. |
const uint8_t* ndn_hmac_get_key_value | ( | const ndn_hmac_key_t * | hmac_key | ) |
Get hmac key bytes.
hmac_key. | Input. NDN hmac key. |
|
inlinestatic |
Initialize a HMAC key.
hmac_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. |
int ndn_hmac_load_key | ( | ndn_hmac_key_t * | hmac_key, |
const uint8_t * | key_value, | ||
uint32_t | key_size | ||
) |
Load in-memory key bits into an NDN hmac key.
hmac_key. | Output. NDN hmac key. |
key_value. | Input. Key bytes. |
key_size. | Input. The size of the key bytes. |
int ndn_hmac_make_key | ( | ndn_hmac_key_t * | key, |
uint32_t | key_id, | ||
const uint8_t * | input_value, | ||
uint32_t | input_size, | ||
const uint8_t * | personalization, | ||
uint32_t | personalization_size, | ||
const uint8_t * | seed_value, | ||
uint32_t | seed_size, | ||
const uint8_t * | additional_value, | ||
uint32_t | additional_size, | ||
uint32_t | salt_size | ||
) |
Generate a HMAC key with specific key size and key id.
This function requires proper entropy source.
input_value. | Input. Personalization string. |
input_size. | Input. Personalization length in bytes. |
output_value. | Output. Buffer to receive output. |
output_size. | Input. Size of the output buffer. |
seed_value. | Input. Entropy to mix into the prng. |
seed_size. | Input. Entropy length in bytes. |
additional_value. | Input. Additional input to the prng. |
additional_size. | Input. Additional input length in bytes. |
int ndn_hmac_sha256 | ( | const void * | payload, |
uint32_t | payload_length, | ||
const ndn_hmac_key_t * | hmac_key, | ||
uint8_t * | hmac_result | ||
) |
Generate HMAC using sha256 digest algorithm.
int ndn_hmac_sign | ( | const uint8_t * | input_value, |
uint32_t | input_size, | ||
uint8_t * | output_value, | ||
uint32_t | output_max_size, | ||
const ndn_hmac_key_t * | hmac_key, | ||
uint32_t * | output_used_size | ||
) |
Sign a buffer using HMAC algorithm.
The memory buffer to hold the signature should not be smaller than 32 bytes.
input_value. | Input. Buffer prepared to sign. |
input_size. | Input. Size of input buffer. |
output_value. | Output. Signature value. |
output_max_size. | Input. Buffer size of output_value |
key_value. | Input. HMAC key. |
key_size. | Input. Size of HMAC key. |
output_used_size. | Output. Size of used output buffer when signing complete. |
int ndn_hmac_verify | ( | const uint8_t * | input_value, |
uint32_t | input_size, | ||
const uint8_t * | sig_value, | ||
uint32_t | sig_size, | ||
const ndn_hmac_key_t * | hmac_key | ||
) |
Verify a HMAC signature.
input_value. | Input. HMAC-signed buffer. |
input_size. | Input. Size of input buffer. |
sig_value. | Input. HMAC signature value. |
sig_size. | Input. HMAC signature size. Should be 32 bytes. |
key_value. | Input. HMAC key buffer. |
key_size. | Input. size of HMAC key. |
int ndn_hmacprng | ( | const uint8_t * | input_value, |
uint32_t | input_size, | ||
uint8_t * | output_value, | ||
uint32_t | output_size, | ||
const uint8_t * | seed_value, | ||
uint32_t | seed_size, | ||
const uint8_t * | additional_value, | ||
uint32_t | additional_size | ||
) |
Use HMAC-PRNG algorithm to generate pseudo-random bytes.
This function requires proper entropy source.
input_value. | Input. Personalization string. |
input_size. | Input. Personalization length in bytes. |
output_value. | Output. Buffer to receive output. |
output_size. | Input. Size of the output buffer. |
seed_value. | Input. Entropy to mix into the prng, highly recommend larger than 32 bytes. |
seed_size. | Input. Entropy length in bytes, highly recommend larger than 32 bytes. |
additional_value. | Input. Additional input to the prng |
additional_size. | Input. Additional input length in bytes |