CryptoAuthLib
Microchip CryptoAuthentication Library
sha2_routines.c File Reference

Software implementation of the SHA256 algorithm. More...

#include <string.h>
#include "sha2_routines.h"

Macros

#define rotate_right(value, places)   ((value >> places) | (value << (32 - places)))
 

Functions

void sw_sha256_init (sw_sha256_ctx *ctx)
 Intialize the software SHA256. More...
 
void sw_sha256_update (sw_sha256_ctx *ctx, const uint8_t *msg, uint32_t msg_size)
 updates the running hash with the next block of data, called iteratively for the entire stream of data to be hashed using the SHA256 software More...
 
void sw_sha256_final (sw_sha256_ctx *ctx, uint8_t digest[SHA256_DIGEST_SIZE])
 completes the final SHA256 calculation and returns the final digest/hash More...
 
void sw_sha256 (const uint8_t *message, unsigned int len, uint8_t digest[SHA256_DIGEST_SIZE])
 single call convenience function which computes Hash of given data using SHA256 software More...
 

Detailed Description

Software implementation of the SHA256 algorithm.

Macro Definition Documentation

◆ rotate_right

#define rotate_right (   value,
  places 
)    ((value >> places) | (value << (32 - places)))

Function Documentation

◆ sw_sha256()

void sw_sha256 ( const uint8_t *  message,
unsigned int  len,
uint8_t  digest[SHA256_DIGEST_SIZE] 
)

single call convenience function which computes Hash of given data using SHA256 software

Parameters
[in]messagepointer to stream of data to hash
[in]lensize of data stream to hash
[out]digestresult

◆ sw_sha256_final()

void sw_sha256_final ( sw_sha256_ctx ctx,
uint8_t  digest[SHA256_DIGEST_SIZE] 
)

completes the final SHA256 calculation and returns the final digest/hash

Parameters
[in]ctxptr to context data structure
[out]digestreceives the computed digest of the SHA 256

◆ sw_sha256_init()

void sw_sha256_init ( sw_sha256_ctx ctx)

Intialize the software SHA256.

Parameters
[in]ctxSHA256 hash context

◆ sw_sha256_update()

void sw_sha256_update ( sw_sha256_ctx ctx,
const uint8_t *  msg,
uint32_t  msg_size 
)

updates the running hash with the next block of data, called iteratively for the entire stream of data to be hashed using the SHA256 software

Parameters
[in]ctxSHA256 hash context
[in]msgRaw blocks to be processed
[in]msg_sizeThe size of the message passed