versadac  1
versadac - Scalable Recorder Firmware
Classes | Macros | Typedefs | Functions
sha256.h File Reference
#include <stdint.h>

Go to the source code of this file.

Classes

struct  sha256_ctx_t
 

Macros

#define SHA256_HASH_BITS   256
 
#define SHA256_HASH_BYTES   (SHA256_HASH_BITS/8)
 
#define SHA256_BLOCK_BITS   512
 
#define SHA256_BLOCK_BYTES   (SHA256_BLOCK_BITS/8)
 

Typedefs

typedef uint8_t sha256_hash_t[SHA256_HASH_BYTES]
 SHA-256 hash value type. More...
 

Functions

void sha256_init (sha256_ctx_t *state)
 initialise a SHA-256 context More...
 
void sha256_nextBlock (sha256_ctx_t *state, const void *block)
 update the context with a given block More...
 
void sha256_lastBlock (sha256_ctx_t *state, const void *block, uint16_t length_b)
 finalize the context with the given block More...
 
void sha256_ctx2hash (sha256_hash_t *dest, const sha256_ctx_t *state)
 convert the hash state into the hash value This function reads the context and writes the hash value to the destination More...
 
void sha256 (sha256_hash_t *dest, const void *msg, uint32_t length_b)
 simple SHA-256 hashing function for direct hashing More...
 
bool TempRegressionTest_SHA256 (void)
 

Detailed Description

Author
Daniel Otte
Date
2006-05-16 GPLv3 or later

Macro Definition Documentation

#define SHA256_BLOCK_BITS   512

defines the size of a SHA-256 input block in bits

#define SHA256_BLOCK_BYTES   (SHA256_BLOCK_BITS/8)

defines the size of a SHA-256 input block in bytes

#define SHA256_HASH_BITS   256

defines the size of a SHA-256 hash value in bits

#define SHA256_HASH_BYTES   (SHA256_HASH_BITS/8)

defines the size of a SHA-256 hash value in bytes

Typedef Documentation

sha256_hash_t

SHA-256 hash value type.

A variable of this type may hold the hash value produced by the sha256_ctx2hash(sha256_hash_t* dest, const sha256_ctx_t* state) function.

Function Documentation

void sha256 ( sha256_hash_t dest,
const void *  msg,
uint32_t  length_b 
)

simple SHA-256 hashing function for direct hashing

This function automaticaly hashes a given message of arbitary length with the SHA-256 hashing algorithm.

Parameters
destpointer to the location where the hash value is going to be written to
msgpointer to the message thats going to be hashed
length_blength of the message in bits
void sha256_ctx2hash ( sha256_hash_t dest,
const sha256_ctx_t state 
)

convert the hash state into the hash value This function reads the context and writes the hash value to the destination

Parameters
destpointer to the location where the hash value should be written
statepointer to the SHA-256 hash context
void sha256_init ( sha256_ctx_t state)

initialise a SHA-256 context

This function sets a sha256_ctx_t to the initial values for hashing.

Parameters
statepointer to the SHA-256 hashing context

initialise a SHA-256 context

Parameters
statepointer to a sha256 context
Returns
none
void sha256_lastBlock ( sha256_ctx_t state,
const void *  block,
uint16_t  length 
)

finalize the context with the given block

This function finalizes the SHA-256 hash context by processing the given block of variable length.

Parameters
statepointer to the SHA-256 hash context
blockpointer to the block of fixed length (512 bit = 64 byte)
length_bthe length of the block in bits

finalize the context with the given block

Parameters
statePointer to the context in which this block should be processed.
blockPointer to the message wich should be hashed.
lengthis the length of only THIS block in BITS not in bytes! bits are big endian, meaning high bits come first. if you have a message with bits at the end, the byte must be padded with zeros
void sha256_nextBlock ( sha256_ctx_t state,
const void *  block 
)

update the context with a given block

This function updates the SHA-256 hash context by processing the given block of fixed length.

Parameters
statepointer to the SHA-256 hash context
blockpointer to the block of fixed length (512 bit = 64 byte)

block must be, 512, Bit = 64, Byte, long !!!