MentOS  0.8.0
The Mentoring Operating System
sha256.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <stdint.h>
16 #include <stddef.h>
17 
19 #define SHA256_BLOCK_SIZE 32
20 
22 typedef struct {
23  uint8_t data[64];
25  unsigned long long bitlen;
26  uint32_t state[8];
27 } SHA256_ctx_t;
28 
31 void sha256_init(SHA256_ctx_t *ctx);
32 
37 void sha256_update(SHA256_ctx_t *ctx, const uint8_t data[], size_t len);
38 
42 void sha256_final(SHA256_ctx_t *ctx, uint8_t hash[]);
43 
50 void sha256_bytes_to_hex(uint8_t *src, size_t src_length, char *out, size_t out_length);
void sha256_update(SHA256_ctx_t *ctx, const uint8_t data[], size_t len)
Adds data to the SHA-256 context for hashing.
Definition: sha256.c:211
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.
Definition: sha256.c:166
void sha256_init(SHA256_ctx_t *ctx)
Initializes the SHA-256 context.
Definition: sha256.c:186
void sha256_final(SHA256_ctx_t *ctx, uint8_t hash[])
Finalizes the hashing and produces the final SHA-256 digest.
Definition: sha256.c:244
Define basic data types.
Standard integer data-types.
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
unsigned char uint8_t
Define the unsigned 8-bit integer.
Definition: stdint.h:30
Structure that holds context information for SHA-256 operations.
Definition: sha256.h:22
uint32_t datalen
Length of the current data in the buffer (in bytes).
Definition: sha256.h:24
unsigned long long bitlen
Total length of the input in bits (for padding).
Definition: sha256.h:25