Contiki-NG

Driver for the cc2538 SHA-256 mode of the security core. More...

Files

file  sha256.c
 Implementation of the cc2538 SHA-256 driver.
 
file  sha256.h
 Header file for the cc2538 SHA-256 driver.
 

Functions

static uint8_t new_hash (sha256_state_t *state, const void *data, void *hash)
 Starts a new hash session in hardware. More...
 
static uint8_t resume_hash (sha256_state_t *state, const void *data, void *hash)
 Resumes an already started hash session in hardware. More...
 

SHA-256 functions

uint8_t sha256_init (sha256_state_t *state)
 Initializes the hash state. More...
 
uint8_t sha256_process (sha256_state_t *state, const void *data, uint32_t len)
 Processes a block of memory through the hash. More...
 
uint8_t sha256_done (sha256_state_t *state, void *hash)
 Terminates hash session to get the digest. More...
 

Detailed Description

Driver for the cc2538 SHA-256 mode of the security core.

Function Documentation

◆ new_hash()

static uint8_t new_hash ( sha256_state_t *  state,
const void *  data,
void *  hash 
)
static

Starts a new hash session in hardware.

Parameters
stateHash state
dataPointer to input message
hashDestination of the hash (32 bytes)
Returns
CRYPTO_SUCCESS if successful, or CRYPTO/SHA256 error code

Definition at line 63 of file sha256.c.

◆ resume_hash()

static uint8_t resume_hash ( sha256_state_t *  state,
const void *  data,
void *  hash 
)
static

Resumes an already started hash session in hardware.

Parameters
stateHash state
dataPointer to the input message
hashPointer to the destination of the hash (32 bytes)
Returns
CRYPTO_SUCCESS if successful, or CRYPTO/SHA256 error code

Definition at line 140 of file sha256.c.

◆ sha256_done()

uint8_t sha256_done ( sha256_state_t *  state,
void *  hash 
)

Terminates hash session to get the digest.

Parameters
statePointer to hash state
hashPointer to hash
Returns
CRYPTO_SUCCESS if successful, or CRYPTO/SHA256 error code
Note
This function must be called only after sha256_process().

Definition at line 320 of file sha256.c.

◆ sha256_init()

uint8_t sha256_init ( sha256_state_t *  state)

Initializes the hash state.

Parameters
statePointer to hash state to initialize
Returns
CRYPTO_SUCCESS if successful, or CRYPTO/SHA256 error code

Definition at line 229 of file sha256.c.

◆ sha256_process()

uint8_t sha256_process ( sha256_state_t *  state,
const void *  data,
uint32_t  len 
)

Processes a block of memory through the hash.

Parameters
statePointer to hash state
dataPointer to the data to hash
lenLength of the data to hash in bytes (octets)
Returns
CRYPTO_SUCCESS if successful, or CRYPTO/SHA256 error code
Note
This function must be called only after sha256_init().

Definition at line 243 of file sha256.c.