GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
sha256.h File Reference

Calculation of SHA-256 digest. More...

#include "mhd_options.h"
#include <stdint.h>
Include dependency graph for sha256.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sha256_ctx
 

Macros

#define _SHA256_DIGEST_LENGTH   8
 
#define SHA256_WORD_SIZE_BITS   32
 
#define SHA256_BYTES_IN_WORD   (SHA256_WORD_SIZE_BITS / 8)
 
#define SHA256_DIGEST_SIZE   (_SHA256_DIGEST_LENGTH * SHA256_BYTES_IN_WORD)
 
#define SHA256_DIGEST_STRING_SIZE   ((SHA256_DIGEST_SIZE) * 2 + 1)
 
#define SHA256_BLOCK_SIZE_BITS   512
 
#define SHA256_BLOCK_SIZE   (SHA256_BLOCK_SIZE_BITS / 8)
 

Functions

void MHD_SHA256_init (void *ctx_)
 
void MHD_SHA256_update (void *ctx_, const uint8_t *data, size_t length)
 
void MHD_SHA256_finish (void *ctx_, uint8_t digest[SHA256_DIGEST_SIZE])
 

Detailed Description

Calculation of SHA-256 digest.

Author
Karlson2k (Evgeny Grin)

Definition in file sha256.h.

Macro Definition Documentation

◆ _SHA256_DIGEST_LENGTH

#define _SHA256_DIGEST_LENGTH   8

Digest is kept internally as 8 32-bit words.

Definition at line 39 of file sha256.h.

◆ SHA256_BLOCK_SIZE

#define SHA256_BLOCK_SIZE   (SHA256_BLOCK_SIZE_BITS / 8)

Size of single processing block in bytes

Definition at line 70 of file sha256.h.

◆ SHA256_BLOCK_SIZE_BITS

#define SHA256_BLOCK_SIZE_BITS   512

Size of single processing block in bits

Definition at line 65 of file sha256.h.

◆ SHA256_BYTES_IN_WORD

#define SHA256_BYTES_IN_WORD   (SHA256_WORD_SIZE_BITS / 8)

Number of bytes in single SHA-256 word used to process data

Definition at line 50 of file sha256.h.

◆ SHA256_DIGEST_SIZE

#define SHA256_DIGEST_SIZE   (_SHA256_DIGEST_LENGTH * SHA256_BYTES_IN_WORD)

Size of SHA-256 digest in bytes

Definition at line 55 of file sha256.h.

◆ SHA256_DIGEST_STRING_SIZE

#define SHA256_DIGEST_STRING_SIZE   ((SHA256_DIGEST_SIZE) * 2 + 1)

Size of SHA-256 digest string in chars including termination NUL

Definition at line 60 of file sha256.h.

◆ SHA256_WORD_SIZE_BITS

#define SHA256_WORD_SIZE_BITS   32

Number of bits in single SHA-256 word

Definition at line 44 of file sha256.h.

Function Documentation

◆ MHD_SHA256_finish()

void MHD_SHA256_finish ( void *  ctx_,
uint8_t  digest[SHA256_DIGEST_SIZE] 
)

Finalise SHA256 calculation, return digest.

Parameters
ctx_must be a struct sha256_ctx *
[out]digestset to the hash, must be SHA256_DIGEST_SIZE bytes

< Number of processed bits

< Number of bytes in buffer

Definition at line 373 of file sha256.c.

References _MHD_PUT_32BIT_BE, _MHD_PUT_64BIT_BE_SAFE(), _MHD_UINT32_ALIGN, _SHA256_DIGEST_LENGTH, sha256_ctx::buffer, sha256_ctx::count, sha256_ctx::H, SHA256_BLOCK_SIZE, SHA256_BYTES_IN_WORD, SHA256_DIGEST_SIZE, SHA256_SIZE_OF_LEN_ADD, and sha256_transform().

Here is the call graph for this function:

◆ MHD_SHA256_init()

void MHD_SHA256_init ( void *  ctx_)

Initialise structure for SHA256 calculation.

Parameters
ctx_must be a struct sha256_ctx *

Definition at line 41 of file sha256.c.

References sha256_ctx::count, and sha256_ctx::H.

◆ MHD_SHA256_update()

void MHD_SHA256_update ( void *  ctx_,
const uint8_t *  data,
size_t  length 
)

Process portion of bytes.

Parameters
ctx_must be a struct sha256_ctx *
databytes to add to hash
lengthnumber of bytes in data

< Number of bytes in buffer

Definition at line 311 of file sha256.c.

References sha256_ctx::buffer, sha256_ctx::count, data, sha256_ctx::H, mhd_assert, NULL, SHA256_BLOCK_SIZE, and sha256_transform().

Here is the call graph for this function: