Software APIs
Data Fields
sha256_state Struct Reference

A type that holds the context for an ongoing SHA-256 operation. More...

#include <sw/device/lib/crypto/impl/sha2/sha256.h>

Data Fields

uint32_t H [kSha256StateWords]
 Working state for a SHA-256 or SHA-384 computation.
 
uint32_t partial_block [kSha256MessageBlockWords]
 Partial block, if any. More...
 
uint64_t total_len
 Total message length so far, in bits.
 

Detailed Description

A type that holds the context for an ongoing SHA-256 operation.

IMPORTANT: Every member of this struct should be a word-aligned type and have a size divisible by sizeof(uint32_t); otherwise sha256_state_t will not be suitable for hardened_memcpy().

Definition at line 62 of file sha256.h.

Field Documentation

◆ H

uint32_t sha256_state::H[kSha256StateWords]

Working state for a SHA-256 or SHA-384 computation.

Definition at line 66 of file sha256.h.

◆ partial_block

uint32_t sha256_state::partial_block[kSha256MessageBlockWords]

Partial block, if any.

If we get an update() with a message that isn't an even number of blocks, there's no way to know if we should pad it or not until we get the next update() or final(). The length of actual data in this block is always (total_len % kSha256MessageBlockBytes) bytes.

Definition at line 75 of file sha256.h.

◆ total_len

uint64_t sha256_state::total_len

Total message length so far, in bits.

Definition at line 79 of file sha256.h.