47#define SHA_256_DIGEST_LENGTH 32
48#define SHA_256_BLOCK_SIZE 64
51#define SHA_256 SHA_256_CONF
53#define SHA_256 sha_256_driver
58 uint32_t state[SHA_256_DIGEST_LENGTH /
sizeof(uint32_t)];
59 uint8_t buf[SHA_256_BLOCK_SIZE];
61} sha_256_checkpoint_t;
78 void (*
update)(
const uint8_t *data,
size_t len);
84 void (*
finalize)(uint8_t digest[
static SHA_256_DIGEST_LENGTH]);
102 void (*
hash)(
const uint8_t *data,
size_t len,
103 uint8_t digest[
static SHA_256_DIGEST_LENGTH]);
112 uint8_t digest[
static SHA_256_DIGEST_LENGTH]);
123 const uint8_t *data,
size_t data_len,
124 uint8_t hmac[
static SHA_256_DIGEST_LENGTH]);
135 const uint8_t *ikm,
size_t ikm_len,
136 uint8_t prk[
static SHA_256_DIGEST_LENGTH]);
148 const uint8_t *info,
size_t info_len,
149 uint8_t *okm, uint_fast16_t okm_len);
163 const uint8_t *ikm,
size_t ikm_len,
164 const uint8_t *info,
size_t info_len,
165 uint8_t *okm, uint_fast16_t okm_len);
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_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_hash(const uint8_t *data, size_t len, uint8_t digest[static 32])
Generic implementation of sha_256_driver::hash.
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_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.
Structure of SHA-256 drivers.
void(* create_checkpoint)(sha_256_checkpoint_t *checkpoint)
Saves the hash session, e.g., before pausing a protothread.
void(* finalize)(uint8_t digest[static 32])
Terminates the hash session and produces the digest.
void(* init)(void)
Starts a hash session.
void(* restore_checkpoint)(const sha_256_checkpoint_t *checkpoint)
Restores a hash session, e.g., after resuming a protothread.
void(* update)(const uint8_t *data, size_t len)
Processes a chunk of data.
void(* hash)(const uint8_t *data, size_t len, uint8_t digest[static 32])
Does init, update, and finalize at once.