CRYPTO-C v1.1.3
C/C++ Documentation
sha256.h File Reference

Go to the source code of this file.

#include "utildev.h"

Detailed Description

SHA256 hash function support.

This file is based on Brad Conte's basic implementations of cryptography algorithms...

https://github.com/B-Con/crypto-algorithms

... and alterations to the transform function were based on Igor Pavlov's SHA256 implementation...

https://github.com/jb55/sha256.c

... both of which were released into the Public Domain.

Macros

#define SHA256LEN   32
 SHA256 message digest length, in bytes.
 

Data Structures

struct  SHA256_CTX
 

Functions

void sha256_init (SHA256_CTX *ctx)
 Initialize a SHA256 context. More...
 
void sha256_update (SHA256_CTX *ctx, const void *in, size_t inlen)
 Add inlen bytes from in to a SHA256 context for hashing. More...
 
void sha256_final (SHA256_CTX *ctx, void *out)
 Finalize a SHA256 message digest. More...
 
void sha256 (const void *in, size_t inlen, void *out)
 Convenient all-in-one SHA256 computation. More...
 

Function Documentation

◆ sha256()

void sha256 ( const void *  in,
size_t  inlen,
void *  out 
)

Convenient all-in-one SHA256 computation.

Performs sha256_init(), sha256_update() and sha256_final(), and places the resulting hash in out.

Parameters
inPointer to data to hash
inlenLength of in data, in bytes
outPointer to location to place the message digest

◆ sha256_final()

void sha256_final ( SHA256_CTX ctx,
void *  out 
)

Finalize a SHA256 message digest.

Generate the SHA256 message digest and place in out.

Parameters
ctxPointer to SHA256 context
outPointer to location to place the message digest

◆ sha256_init()

void sha256_init ( SHA256_CTX ctx)

Initialize a SHA256 context.

Parameters
ctxPointer to SHA256 context

◆ sha256_update()

void sha256_update ( SHA256_CTX ctx,
const void *  in,
size_t  inlen 
)

Add inlen bytes from in to a SHA256 context for hashing.

Parameters
ctxPointer to SHA256 context
inPointer to data to hash
inlenLength of in data, in bytes