|
MentOS
0.8.0
The Mentoring Operating System
|
Implementation of the SHA-256 hashing algorithm. More...
Go to the source code of this file.
Classes | |
| struct | SHA256_ctx_t |
| Structure that holds context information for SHA-256 operations. More... | |
Macros | |
| #define | SHA256_BLOCK_SIZE 32 |
| SHA256 outputs a 32 byte digest. | |
Functions | |
| void | sha256_init (SHA256_ctx_t *ctx) |
| Initializes the SHA-256 context. More... | |
| void | sha256_update (SHA256_ctx_t *ctx, const uint8_t data[], size_t len) |
| Adds data to the SHA-256 context for hashing. More... | |
| void | sha256_final (SHA256_ctx_t *ctx, uint8_t hash[]) |
| Finalizes the hashing and produces the final SHA-256 digest. More... | |
| void | sha256_bytes_to_hex (uint8_t *src, size_t src_length, char *out, size_t out_length) |
| Converts a byte array to its hexadecimal string representation. More... | |
Implementation of the SHA-256 hashing algorithm.
The original code was written by Brad Conte, and is available at: https://github.com/B-Con/crypto-algorithms
SHA-256 is one of the three algorithms in the SHA2 specification. The others, SHA-384 and SHA-512, are not offered in this implementation. Algorithm specification can be found here: http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf This implementation uses little endian byte order.
Converts a byte array to its hexadecimal string representation.
| src | Pointer to the source byte array. |
| src_length | Length of the source byte array. |
| out | Pointer to the output buffer for the hexadecimal string. |
| out_length | Length of the output buffer (must be at least 2 * src_length + 1). |
The output string will be null-terminated if the buffer is large enough.
Converts a byte array to its hexadecimal string representation.
| src | Pointer to the source byte array. |
| src_length | Length of the source byte array. |
| out | Pointer to the output buffer for the hexadecimal string. |
| out_length | Length of the output buffer (must be at least 2 * src_length + 1). |
The output string will be null-terminated if the buffer is large enough.
| void sha256_final | ( | SHA256_ctx_t * | ctx, |
| uint8_t | hash[] | ||
| ) |
Finalizes the hashing and produces the final SHA-256 digest.
| ctx | Pointer to the SHA-256 context. |
| hash | Pointer to a buffer where the final hash will be stored (must be at least 32 bytes long). |
| void sha256_init | ( | SHA256_ctx_t * | ctx | ) |
Initializes the SHA-256 context.
| ctx | Pointer to the SHA-256 context to initialize. |
| void sha256_update | ( | SHA256_ctx_t * | ctx, |
| const uint8_t | data[], | ||
| size_t | len | ||
| ) |
Adds data to the SHA-256 context for hashing.
| ctx | Pointer to the SHA-256 context. |
| data | Pointer to the data to be hashed. |
| len | Length of the data to hash, in bytes. |