SHA_256Components > Security

Description

SHA-256 digest functionality for the bootloader.

Data Structures

union  Sha256Context
 Context type for SHA algorithm.
 

Macros

#define BTL_SECURITY_SHA256_DIGEST_LENGTH   32
 Number of bytes in a SHA-256 digest.
 

Typedefs

typedef union Sha256Context Sha256Context_t
 Context type for SHA algorithm.
 

Functions

void btl_initSha256 (void *ctx)
 
void btl_updateSha256 (void *ctx, const void *data, size_t length)
 
void btl_finalizeSha256 (void *ctx)
 
int32_t btl_verifySha256 (void *ctx, const void *sha256)
 

Function Documentation

void btl_initSha256 ( void *  ctx)

Initialize SHA256 context variable.

Parameters
ctxPointer to the SHA256 context variable to be initialized

Wipes out the SHA256 context variable and sets it up for re-use.

void btl_updateSha256 ( void *  ctx,
const void *  data,
size_t  length 
)

Run data through the SHA256 hashing function.

Parameters
ctxPointer to the SHA256 context variable
dataPointer to an array of binary data to add to the SHA256 calculation in progress
lengthLength of the byte array with data.
void btl_finalizeSha256 ( void *  ctx)

Finalize the SHA256 calculation.

Parameters
ctxPointer to the SHA256 context variable to be initialized

Finalizes the running SHA256 calculation. After finalization, the SHA value in the context variable will be valid and no more data can be added.

int32_t btl_verifySha256 ( void *  ctx,
const void *  sha256 
)

Compare the SHA256 from the context variable to a known value.

Parameters
ctxPointer to the SHA256 context variable to be initialized
sha256Byte array containing SHA256 value to compare to
Returns
BOOTLOADER_OK if both hash values are equal, else error code from BOOTLOADER_ERROR_SECURITY_BASE range.

Convenience function to compare a known SHA256 hash against the result of a calculation.