Contiki-NG
Loading...
Searching...
No Matches
Cryptographic primitives

Topics

 Cryptographically-secure PRNG
 In contrast to a normal PRNG, a CSPRNG generates a stream of pseudo-random numbers that is indistinguishable from the uniform distribution to a computationally-bounded adversary who does not know the seed.
 

Files

file  aes-128.c
 Wrapped AES-128 implementation from Texas Instruments.
 
file  aes-128.h
 AES-128.
 
file  ccm-star.c
 AES_128-based CCM* implementation.
 
file  ccm-star.h
 CCM* header file.
 
file  sha-256.c
 Software implementation of SHA-256.
 
file  sha-256.h
 Platform-independent SHA-256 API.
 

Data Structures

struct  aes_128_driver
 Structure of AES drivers. More...
 
struct  ccm_star_driver
 Structure of CCM* drivers. More...
 
struct  sha_256_driver
 Structure of SHA-256 drivers. More...
 

Functions

void sha_256_hkdf_expand (const uint8_t *prk, size_t prk_len, const uint8_t *info, size_t info_len, uint8_t *okm, uint_fast16_t okm_len)
 Expands a key as per RFC 5869.
 
void sha_256_hkdf (const uint8_t *salt, size_t salt_len, const uint8_t *ikm, size_t ikm_len, const uint8_t *info, size_t info_len, uint8_t *okm, uint_fast16_t okm_len)
 Performs both extraction and expansion as per RFC 5869.
 
void sha_256_hash (const uint8_t *data, size_t len, uint8_t digest[static 32])
 Generic implementation of sha_256_driver::hash.
 
void sha_256_hmac (const uint8_t *key, size_t key_len, const uint8_t *data, size_t data_len, uint8_t hmac[static 32])
 Computes HMAC-SHA-256 as per RFC 2104.
 
void sha_256_hkdf_extract (const uint8_t *salt, size_t salt_len, const uint8_t *ikm, size_t ikm_len, uint8_t prk[static 32])
 Extracts a key as per RFC 5869.
 

Detailed Description

Function Documentation

◆ sha_256_hkdf()

void sha_256_hkdf ( const uint8_t * salt,
size_t salt_len,
const uint8_t * ikm,
size_t ikm_len,
const uint8_t * info,
size_t info_len,
uint8_t * okm,
uint_fast16_t okm_len )

Performs both extraction and expansion as per RFC 5869.

Parameters
saltoptional salt value
salt_lenlength of salt in bytes
ikminput keying material
ikm_lenlength of ikm in bytes
infooptional context and application specific information
info_lenlength of info in bytes
okmoutput keying material
okm_lenlength of okm in bytes (<= 255 * SHA_256_DIGEST_LENGTH)

Definition at line 449 of file sha-256.c.

References sha_256_hkdf_expand().

◆ sha_256_hkdf_expand()

void sha_256_hkdf_expand ( const uint8_t * prk,
size_t prk_len,
const uint8_t * info,
size_t info_len,
uint8_t * okm,
uint_fast16_t okm_len )

Expands a key as per RFC 5869.

Parameters
prka pseudorandom key of at least SHA_256_DIGEST_LENGTH bytes
prk_lenlength of prk in bytes
infooptional context and application specific information
info_lenlength of info in bytes
okmoutput keying material
okm_lenlength of okm in bytes (<= 255 * SHA_256_DIGEST_LENGTH)

Definition at line 417 of file sha-256.c.

Referenced by sha_256_hkdf().

◆ sha_256_hkdf_extract()

void sha_256_hkdf_extract ( const uint8_t * salt,
size_t salt_len,
const uint8_t * ikm,
size_t ikm_len,
uint8_t prk[static 32] )

Extracts a key as per RFC 5869.

Parameters
saltoptional salt value
salt_lenlength of salt in bytes
ikminput keying material
ikm_lenlength of ikm in bytes
prkpointer to where the extracted key shall be stored

◆ sha_256_hmac()

void sha_256_hmac ( const uint8_t * key,
size_t key_len,
const uint8_t * data,
size_t data_len,
uint8_t hmac[static 32] )

Computes HMAC-SHA-256 as per RFC 2104.

Parameters
keythe key to authenticate with
key_lenlength of key in bytes
datathe data to authenticate
data_lenlength of data in bytes
hmacpointer to where the resulting HMAC shall be stored