|
C Fundamentals
Algorithms · data structures · cryptography · systems — pure C11, zero deps
|
SHA-256 implementation per FIPS 180-4. More...
Go to the source code of this file.
Functions | |
| static void | process_block (uint32_t H[8], const uint8_t block[64]) |
| static uint32_t | rotr (uint32_t x, unsigned n) |
| void | sha256 (const uint8_t *data, size_t len, uint8_t digest[SHA256_DIGEST_BYTES]) |
| void | sha256_to_hex (const uint8_t digest[SHA256_DIGEST_BYTES], char hex_out[SHA256_HEX_BYTES]) |
Variables | |
| static const uint32_t | K [64] |
SHA-256 implementation per FIPS 180-4.
Single-shot interface only — given the bytes, returns the digest. The 32-bit constants K[0..63] are the first 32 bits of the fractional parts of the cube roots of the first 64 primes; H0[0..7] are the same for the square roots of the first 8 primes.
Definition in file sha256.c.
|
static |
|
static |
Definition at line 28 of file sha256.c.
Referenced by process_block().
| void sha256 | ( | const uint8_t * | data, |
| size_t | len, | ||
| uint8_t | digest[SHA256_DIGEST_BYTES] | ||
| ) |
Compute SHA-256(data[0..len)) into the 32-byte digest buffer.
Definition at line 66 of file sha256.c.
References process_block().
Referenced by main().
| void sha256_to_hex | ( | const uint8_t | digest[SHA256_DIGEST_BYTES], |
| char | hex_out[SHA256_HEX_BYTES] | ||
| ) |
Format a 32-byte digest as a 64-char lowercase hex string + NUL.
Definition at line 112 of file sha256.c.
References SHA256_DIGEST_BYTES.
Referenced by main().
|
static |
Definition at line 14 of file sha256.c.
Referenced by process_block().