CC26xx Driver Library
sha2.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "../inc/hw_types.h"
#include "../inc/hw_memmap.h"
#include "../inc/hw_ints.h"
#include "../inc/hw_crypto.h"
#include "../inc/hw_ccfg.h"
#include "debug.h"
#include "interrupt.h"
#include "cpu.h"

Macros

#define SHA2_DMA_IN_DONE   (CRYPTO_IRQEN_DMA_IN_DONE_M)
 
#define SHA2_RESULT_RDY   (CRYPTO_IRQEN_RESULT_AVAIL_M)
 
#define SHA2_DMA_BUS_ERR   (CRYPTO_IRQCLR_DMA_BUS_ERR_M)
 
#define SHA2_SUCCESS   0
 
#define SHA2_INVALID_ALGORITHM   1
 
#define SHA2_DMA_BUSY   3
 
#define SHA2_DMA_ERROR   4
 
#define SHA2_DIGEST_NOT_READY   5
 
#define SHA2_OLD_DIGEST_NOT_READ   6
 
#define SHA2_SHA224_DIGEST_LENGTH_BYTES   (224 / 8)
 
#define SHA2_SHA256_DIGEST_LENGTH_BYTES   (256 / 8)
 
#define SHA2_SHA384_DIGEST_LENGTH_BYTES   (384 / 8)
 
#define SHA2_SHA512_DIGEST_LENGTH_BYTES   (512 / 8)
 
#define SHA2_MODE_SELECT_SHA224   (CRYPTO_HASHMODE_SHA224_MODE_M)
 
#define SHA2_MODE_SELECT_SHA256   (CRYPTO_HASHMODE_SHA256_MODE_M)
 
#define SHA2_MODE_SELECT_SHA384   (CRYPTO_HASHMODE_SHA384_MODE_M)
 
#define SHA2_MODE_SELECT_SHA512   (CRYPTO_HASHMODE_SHA512_MODE_M)
 
#define SHA2_MODE_SELECT_NEW_HASH   (CRYPTO_HASHMODE_NEW_HASH_M)
 
#define SHA2_SHA224_BLOCK_SIZE_BYTES   (512 / 8)
 
#define SHA2_SHA256_BLOCK_SIZE_BYTES   (512 / 8)
 
#define SHA2_SHA384_BLOCK_SIZE_BYTES   (1024 / 8)
 
#define SHA2_SHA512_BLOCK_SIZE_BYTES   (1024 / 8)
 
#define SHA2_DMA_CHANNEL0_ACTIVE   (CRYPTO_DMASTAT_CH0_ACT_M)
 
#define SHA2_DMA_CHANNEL1_ACTIVE   (CRYPTO_DMASTAT_CH1_ACT_M)
 
#define SHA2_DMA_PORT_ERROR   (CRYPTO_DMASTAT_PORT_ERR_M)
 
#define SHA2_ALGSEL_SHA256   0x04
 
#define SHA2_ALGSEL_SHA512   0x08
 
#define SHA2_ALGSEL_TAG   (CRYPTO_ALGSEL_TAG_M)
 

Functions

void SHA2StartDMAOperation (uint8_t *channel0Addr, uint32_t channel0Length, uint8_t *channel1Addr, uint32_t channel1Length)
 Start a crypto DMA operation. More...
 
uint32_t SHA2WaitForIRQFlags (uint32_t irqFlags)
 Poll the interrupt status register and clear when done. More...
 
uint32_t SHA2ComputeInitialHash (const uint8_t *message, uint32_t *intermediateDigest, uint32_t hashAlgorithm, uint32_t initialMessageLength)
 Start a new SHA-2 hash operation. More...
 
uint32_t SHA2ComputeIntermediateHash (const uint8_t *message, uint32_t *intermediateDigest, uint32_t hashAlgorithm, uint32_t intermediateMessageLength)
 Resume a SHA-2 hash operation but do not finalize it. More...
 
uint32_t SHA2ComputeFinalHash (const uint8_t *message, uint8_t *resultDigest, uint32_t *intermediateDigest, uint32_t totalMsgLength, uint32_t messageLength, uint32_t hashAlgorithm)
 Resume a SHA-2 hash operation and finalize it. More...
 
uint32_t SHA2ComputeHash (const uint8_t *message, uint8_t *resultDigest, uint32_t totalMsgLength, uint32_t hashAlgorithm)
 Start a SHA-2 hash operation and return the finalized digest. More...
 
static void SHA2SelectAlgorithm (uint32_t algorithm)
 Configure the crypto DMA for a particular operation. More...
 
static void SHA2SetMessageLength (uint32_t length)
 Specify the total length of the message. More...
 
static void SHA2SetDigest (uint32_t *digest, uint8_t digestLength)
 Load an intermediate digest. More...
 
static uint32_t SHA2GetDigest (uint32_t *digest, uint8_t digestLength)
 Read the intermediate or final digest. More...
 
static void SHA2ClearDigestAvailableFlag (void)
 Confirm digest was read. More...
 
static void SHA2IntEnable (uint32_t intFlags)
 Enable individual crypto interrupt sources. More...
 
static void SHA2IntDisable (uint32_t intFlags)
 Disable individual crypto interrupt sources. More...
 
static uint32_t SHA2IntStatusMasked (void)
 Get the current masked interrupt status. More...
 
static uint32_t SHA2IntStatusRaw (void)
 Get the current raw interrupt status. More...
 
static void SHA2IntClear (uint32_t intFlags)
 Clear crypto interrupt sources. More...
 
static void SHA2IntRegister (void(*handlerFxn)(void))
 Register an interrupt handler for a crypto interrupt in the dynamic interrupt table. More...
 
static void SHA2IntUnregister (void)
 Unregister an interrupt handler for a crypto interrupt in the dynamic interrupt table. More...