MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SHA: SHA encryption decryption driver

Overview

The MCUXpresso SDK provides a peripheral driver for the SHA module in MCUXpresso SDK devices.

The driver provides blocking synchronous APIs. The SHA operations are complete (and results are made availabe for further usage) when a function returns. When called, these functions don't return until a SHA operation is complete. These functions use main CPU for simple polling loops to determine operation complete or error status and also for data movements. The driver functions are not re-entrant. These functions provide typical interface to upper layer or application software.

SHA Driver Initialization and Configuration

Clock to the SHA module has to be enabled before using the driver API.

Comments about API usage in RTOS

SHA operations provided by this driver are not re-entrant. Thus, application software shall ensure the SHA module operation is not requested from different tasks or interrupt service routines while an operation is in progress.

SHA Driver Example

Typical use case

status_t status;
uint8_t input[] = "Hello world.";
uint8_t output[32];
size_t outputSize;
status = SHA_Init(SHA0, &ctx, kSHA_Sha256);
if (status != kStatus_Success)
{
/* fail */
return;
}
status = SHA_Update(SHA0, &ctx, input, sizeof(input) - 1);
if (status != kStatus_Success)
{
/* fail */
return;
}
outputSize = 32;
status = SHA_Finish(SHA0, &ctx, output, &outputSize);
if (status != kStatus_Success)
{
/* fail */
return;
}

Modules

 Sha_algorithm_level_api
 

Files

file  fsl_sha.h
 

Macros

#define SHA_CTX_SIZE   20
 SHA Context size. More...
 

Typedefs

typedef uint32_t sha_ctx_t [SHA_CTX_SIZE]
 Storage type used to save hash context. More...
 

Enumerations

enum  sha_algo_t {
  kSHA_Sha1,
  kSHA_Sha256
}
 Supported cryptographic block cipher functions for HASH creation. More...
 

Driver version

#define FSL_SHA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 Defines LPC SHA driver version 2.0.0. More...
 

Macro Definition Documentation

#define FSL_SHA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Change log:

  • Version 2.0.0
    • initial version
#define SHA_CTX_SIZE   20

Typedef Documentation

typedef uint32_t sha_ctx_t[SHA_CTX_SIZE]

Enumeration Type Documentation

enum sha_algo_t
Enumerator
kSHA_Sha1 

SHA_1.

kSHA_Sha256 

SHA_256.