Interface to a SHA-256 implementation. More...
#include <stddef.h>#include <stdint.h>Macros | |
| #define | SHA256_BLOCK_SIZE (64) |
| Block size. | |
| #define | SHA256_DIGEST_SIZE (32) |
| Digest size. | |
| #define | SHA256_STATE_BLOCKS (SHA256_DIGEST_SIZE / 4) |
| Number of blocks in state. | |
Functions | |
| void | tc_sha256_init (sha256_state *s) |
| The SHA state. More... | |
| void | tc_sha256_update (sha256_state *s, const uint8_t *data, size_t datalen) |
| SHA256 update procedure Hashes data_length bytes addressed by data into state s. More... | |
| void | tc_sha256_final (uint8_t *digest, sha256_state *s) |
| SHA256 final procedure Inserts the completed hash computation into digest. More... | |
Interface to a SHA-256 implementation.
Overview: SHA-256 is a NIST approved cryptographic hashing algorithm specified in FIPS 180. A hash algorithm maps data of arbitrary size to data of fixed length.
Security: SHA-256 provides 128 bits of security against collision attacks and 256 bits of security against pre-image attacks. SHA-256 does NOT behave like a random oracle, but it can be used as one if the string being hashed is prefix-free encoded before hashing.
Usage: 1) call tc_sha256_init to initialize a struct tc_sha256_state_struct before hashing a new string.
2) call tc_sha256_update to hash the next string segment; tc_sha256_update can be called as many times as needed to hash all of the segments of a string; the order is important.
3) call tc_sha256_final to out put the digest from a hashing operation.
| void tc_sha256_final | ( | uint8_t * | digest, |
| sha256_state * | s | ||
| ) |
SHA256 final procedure Inserts the completed hash computation into digest.
| digest | unsigned eight bit integer |
| s | Sha256 state struct |
| void tc_sha256_init | ( | sha256_state * | s | ) |
The SHA state.
SHA256 initialization procedure Initializes s
| s | Sha256 state struct |
| void tc_sha256_update | ( | sha256_state * | s, |
| const uint8_t * | data, | ||
| size_t | datalen | ||
| ) |
SHA256 update procedure Hashes data_length bytes addressed by data into state s.
| s | Sha256 state struct |
| data | message to hash |
| datalen | length of message to hash |