STM32F7 Ethernet interface for nucleo STM32F767

Embed: (wiki syntax)

« Back to documentation index

ns_sha256.h File Reference

ns_sha256.h File Reference

SHA-256 cryptographic hash function. More...

Go to the source code of this file.

Data Structures

struct  ns_sha256_context
 SHA-256 context structure. More...

Functions

static void ns_sha256_init (ns_sha256_context *ctx)
 Initialize SHA-256 context.
static void ns_sha256_free (ns_sha256_context *ctx)
 Clear SHA-256 context.
static void ns_sha256_clone (ns_sha256_context *dst, const ns_sha256_context *src)
 Clone (the state of) a SHA-256 context.
static void ns_sha256_starts (ns_sha256_context *ctx)
 SHA-256 context setup.
static void ns_sha256_update (ns_sha256_context *ctx, const void *input, size_t ilen)
 SHA-256 process buffer.
static void ns_sha256_finish (ns_sha256_context *ctx, void *output)
 SHA-256 final digest.
static void ns_sha256 (const void *input, size_t ilen, void *output)
 Output = SHA-256( input buffer )
static void ns_sha256_finish_nbits (ns_sha256_context *ctx, void *output, unsigned obits)
 SHA-256 final digest.
static void ns_sha256_nbits (const void *input, size_t ilen, void *output, unsigned obits)
 Output = SHA-256( input buffer )

Detailed Description

SHA-256 cryptographic hash function.

This file is derived from sha256.h in mbed TLS 2.3.0.

This file provides an API very similar to mbed TLS, either implemented locally, or by calling mbed TLS, depending on NS_USE_EXTERNAL_MBED_TLS.

Differences from mbed TLS:

a) ns_ prefix instead of mbedtls_; b) Pointers are void * instead of unsigned char * to avoid type clashes; c) SHA-224 not supported; d) Ability to output truncated hashes.

Definition in file ns_sha256.h.


Function Documentation

void ns_sha256 ( const void *  input,
size_t  ilen,
void *  output 
) [static]

Output = SHA-256( input buffer )

Parameters:
inputbuffer holding the data
ilenlength of the input data
outputSHA-256 checksum result

Definition at line 75 of file ns_sha256.h.

void ns_sha256_clone ( ns_sha256_context dst,
const ns_sha256_context src 
) [static]

Clone (the state of) a SHA-256 context.

Parameters:
dstThe destination context
srcThe context to be cloned

Definition at line 53 of file ns_sha256.h.

void ns_sha256_finish ( ns_sha256_context ctx,
void *  output 
) [static]

SHA-256 final digest.

Parameters:
ctxSHA-256 context
outputSHA-256 checksum result

Definition at line 70 of file ns_sha256.h.

void ns_sha256_finish_nbits ( ns_sha256_context ctx,
void *  output,
unsigned  obits 
) [static]

SHA-256 final digest.

Parameters:
ctxSHA-256 context
outputSHA-256 checksum result
obitsNumber of bits of to output - must be multiple of 32

Definition at line 82 of file ns_sha256.h.

void ns_sha256_free ( ns_sha256_context ctx ) [static]

Clear SHA-256 context.

Parameters:
ctxSHA-256 context to be cleared

Definition at line 48 of file ns_sha256.h.

void ns_sha256_init ( ns_sha256_context ctx ) [static]

Initialize SHA-256 context.

Parameters:
ctxSHA-256 context to be initialized

Definition at line 43 of file ns_sha256.h.

void ns_sha256_nbits ( const void *  input,
size_t  ilen,
void *  output,
unsigned  obits 
) [static]

Output = SHA-256( input buffer )

Parameters:
inputbuffer holding the data
ilenlength of the input data
outputSHA-256 checksum result
obitsNumber of bits of to output - must be multiple of 32

Definition at line 93 of file ns_sha256.h.

void ns_sha256_starts ( ns_sha256_context ctx ) [static]

SHA-256 context setup.

Parameters:
ctxcontext to be initialized

Definition at line 59 of file ns_sha256.h.

void ns_sha256_update ( ns_sha256_context ctx,
const void *  input,
size_t  ilen 
) [static]

SHA-256 process buffer.

Parameters:
ctxSHA-256 context
inputbuffer holding the data
ilenlength of the input data

Definition at line 64 of file ns_sha256.h.