Contiki-NG
Loading...
Searching...
No Matches
sha-256.h File Reference

Platform-independent SHA-256 API. More...

#include "contiki.h"
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  sha_256_driver
 Structure of SHA-256 drivers. More...
 

Functions

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.
 
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.
 

Detailed Description

Platform-independent SHA-256 API.

Author
Konrad Krentz konra.nosp@m.d.kr.nosp@m.entz@.nosp@m.gmai.nosp@m.l.com

Definition in file sha-256.h.

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 442 of file sha-256.c.

◆ 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 410 of file sha-256.c.

◆ 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