49#define SHA_256_DIGEST_LENGTH 32
50#define SHA_256_BLOCK_SIZE 64
53#define SHA_256 SHA_256_CONF
55#define SHA_256 sha_256_driver
60 uint32_t state[SHA_256_DIGEST_LENGTH /
sizeof(uint32_t)];
61 uint8_t buf[SHA_256_BLOCK_SIZE];
63 uint8_t opad[SHA_256_BLOCK_SIZE];
64} sha_256_checkpoint_t;
81 void (*
update)(
const uint8_t *data,
size_t len);
87 void (*
finalize)(uint8_t digest[
static SHA_256_DIGEST_LENGTH]);
105 void (*
hash)(
const uint8_t *data,
size_t len,
106 uint8_t digest[
static SHA_256_DIGEST_LENGTH]);
115 uint8_t digest[
static SHA_256_DIGEST_LENGTH]);
146 const uint8_t *data,
size_t data_len,
147 uint8_t hmac[
static SHA_256_DIGEST_LENGTH]);
158 const uint8_t *ikm,
size_t ikm_len,
159 uint8_t prk[
static SHA_256_DIGEST_LENGTH]);
171 const uint8_t *info,
size_t info_len,
172 uint8_t *okm, uint_fast16_t okm_len);
186 const uint8_t *ikm,
size_t ikm_len,
187 const uint8_t *info,
size_t info_len,
188 uint8_t *okm, uint_fast16_t okm_len);
void sha_256_hmac_update(const uint8_t *data, size_t data_len)
Proceeds with the computation of an HMAC-SHA-256.
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_hmac_finish(uint8_t hmac[static 32])
Finishes the computation of an HMAC-SHA-256.
void sha_256_hmac_init(const uint8_t *key, size_t key_len)
Initiates a stepwise HMAC-SHA-256 computation.
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.