MSP432E4 DriverLib API Guide  1.11.00.03
Functions
Shamd5_api

Functions

void SHAMD5Reset (uint32_t ui32Base)
 
void SHAMD5DMAEnable (uint32_t ui32Base)
 
void SHAMD5DMADisable (uint32_t ui32Base)
 
uint32_t SHAMD5IntStatus (uint32_t ui32Base, bool bMasked)
 
void SHAMD5IntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void SHAMD5IntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void SHAMD5IntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void SHAMD5IntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void SHAMD5IntUnregister (uint32_t ui32Base)
 
void SHAMD5HashLengthSet (uint32_t ui32Base, uint32_t ui32Length)
 
void SHAMD5ConfigSet (uint32_t ui32Base, uint32_t ui32Mode)
 
bool SHAMD5DataWriteNonBlocking (uint32_t ui32Base, uint32_t *pui32Src)
 
void SHAMD5DataWrite (uint32_t ui32Base, uint32_t *pui32Src)
 
void SHAMD5ResultRead (uint32_t ui32Base, uint32_t *pui32Dest)
 
void SHAMD5DataProcess (uint32_t ui32Base, uint32_t *pui32DataSrc, uint32_t ui32DataLength, uint32_t *pui32HashResult)
 
void SHAMD5HMACProcess (uint32_t ui32Base, uint32_t *pui32DataSrc, uint32_t ui32DataLength, uint32_t *pui32HashResult)
 
void SHAMD5HMACPPKeyGenerate (uint32_t ui32Base, uint32_t *pui32Key, uint32_t *pui32PPKey)
 
void SHAMD5HMACKeySet (uint32_t ui32Base, uint32_t *pui32Src)
 
void SHAMD5HMACPPKeySet (uint32_t ui32Base, uint32_t *pui32Src)
 

Detailed Description

Introduction

The SHA/MD% module driver provides a method for generating hash values and hash-based message authentication codes. The configuration and feature highlights are:

API Functions

The SHA/MD5 API consists of functions for configuring the SHA/MD5 module, processing data, and reading the resultant hash.

Hashing Programming Example

The following example generates a hash using the SHA-1 algorithm.

//
// Random data to be hashed.
//
uint32_t g_ui32RandomData[16] =
{
0xe2bec16b, 0x969f402e, 0x117e3de9, 0x2a179373,
0x578a2dae, 0x9cac031e, 0xac6fb79e, 0x518eaf45,
0x461cc830, 0x11e45ca3, 0x19c1fbe5, 0xef520a1a,
0x45249ff6, 0x179b4fdf, 0x7b412bad, 0x10376ce6
};
int
main(void)
{
uint32_t ui32HashResult[5];
//
// Enable the CCM module.
//
//
// Wait for the CCM module to be ready.
//
{
}
//
// Reset the SHA/MD5 module before use.
//
SHAMD5Reset(SHAMD5_BASE);
//
// Configure the SHA/MD5 module.
//
//
// Generate the hash from the data.
//
// The resulting hash should be:
// {0x856210e0, 0xfa2dffe6, 0x94be52d0, 0xca7b2491
// 0x40d53371}
//
SHAMD5ProcessData(SHAMD5_BASE, g_ui32RandomData, 64, ui32HashResult);
}

Function Documentation

§ SHAMD5Reset()

void SHAMD5Reset ( uint32_t  ui32Base)

Resets the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.

This function performs a soft-reset of the SHA/MD5 module using the SYSCONFIG register.

Returns
None.

References ASSERT, HWREG, SHAMD5_O_SYSCONFIG, SHAMD5_O_SYSSTATUS, SHAMD5_SYSCONFIG_SIDLE_FORCE, SHAMD5_SYSCONFIG_SIDLE_M, SHAMD5_SYSCONFIG_SOFTRESET, and SHAMD5_SYSSTATUS_RESETDONE.

§ SHAMD5DMAEnable()

void SHAMD5DMAEnable ( uint32_t  ui32Base)

Enables the uDMA requests in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.

This function configures the DMA options of the SHA/MD5 module.

Returns
None

References ASSERT, HWREG, SHAMD5_O_SYSCONFIG, SHAMD5_SYSCONFIG_DMA_EN, and SHAMD5_SYSCONFIG_SADVANCED.

§ SHAMD5DMADisable()

void SHAMD5DMADisable ( uint32_t  ui32Base)

Disables the uDMA requests in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.

This function configures the DMA options of the SHA/MD5 module.

Returns
None

References ASSERT, HWREG, SHAMD5_O_SYSCONFIG, SHAMD5_SYSCONFIG_DMA_EN, and SHAMD5_SYSCONFIG_SADVANCED.

§ SHAMD5IntStatus()

uint32_t SHAMD5IntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Get the interrupt status of the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
bMaskedis false if the raw interrupt status is required and true if the masked interrupt status is required.

This function returns the current value of the IRQSTATUS register. The value will be a logical OR of the following:

  • SHAMD5_INT_CONTEXT_READY - Context input registers are ready.
  • SHAMD5_INT_PARTHASH_READY - Context output registers are ready after a context switch.
  • SHAMD5_INT_INPUT_READY - Data FIFO is ready to receive data.
  • SHAMD5_INT_OUTPUT_READY - Context output registers are ready.
Returns
Interrupt status

References ASSERT, HWREG, SHAMD5_O_DMAMIS, SHAMD5_O_DMARIS, SHAMD5_O_IRQENABLE, and SHAMD5_O_IRQSTATUS.

§ SHAMD5IntEnable()

void SHAMD5IntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enable interrupt sources in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
ui32IntFlagscontains desired interrupts to enable.

This function enables interrupt sources in the SHA/MD5 module. ui32IntFlags must be a logical OR of one or more of the following values:

  • SHAMD5_INT_CONTEXT_READY - Context input registers are ready.
  • SHAMD5_INT_PARTHASH_READY - Context output registers are ready after a context switch.
  • SHAMD5_INT_INPUT_READY - Data FIFO is ready to receive data.
  • SHAMD5_INT_OUTPUT_READY - Context output registers are ready.
Returns
None.

References ASSERT, HWREG, SHAMD5_INT_CONTEXT_READY, SHAMD5_INT_INPUT_READY, SHAMD5_INT_OUTPUT_READY, SHAMD5_INT_PARTHASH_READY, SHAMD5_O_DMAIM, SHAMD5_O_IRQENABLE, SHAMD5_O_SYSCONFIG, and SHAMD5_SYSCONFIG_IT_EN.

§ SHAMD5IntDisable()

void SHAMD5IntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disable interrupt sources in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
ui32IntFlagscontains desired interrupts to disable.

ui32IntFlags must be a logical OR of one or more of the following values:

  • SHAMD5_INT_CONTEXT_READY - Context input registers are ready.
  • SHAMD5_INT_PARTHASH_READY - Context output registers are ready after a context switch.
  • SHAMD5_INT_INPUT_READY - Data FIFO is ready to receive data.
  • SHAMD5_INT_OUTPUT_READY - Context output registers are ready.
Returns
None.

References ASSERT, HWREG, SHAMD5_INT_CONTEXT_READY, SHAMD5_INT_INPUT_READY, SHAMD5_INT_OUTPUT_READY, SHAMD5_INT_PARTHASH_READY, SHAMD5_O_DMAIM, SHAMD5_O_IRQENABLE, SHAMD5_O_SYSCONFIG, and SHAMD5_SYSCONFIG_IT_EN.

§ SHAMD5IntClear()

void SHAMD5IntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears interrupt sources in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
ui32IntFlagscontains desired interrupts to disable.

ui32IntFlags must be a logical OR of one or more of the following values:

  • SHAMD5_INT_CONTEXT_READY - Context input registers are ready.
  • SHAMD5_INT_PARTHASH_READY - Context output registers are ready after a context switch.
  • SHAMD5_INT_INPUT_READY - Data FIFO is ready to receive data.
  • SHAMD5_INT_OUTPUT_READY - Context output registers are ready.
Returns
None.

References ASSERT, HWREG, SHAMD5_INT_CONTEXT_READY, SHAMD5_INT_INPUT_READY, SHAMD5_INT_OUTPUT_READY, SHAMD5_INT_PARTHASH_READY, and SHAMD5_O_DMAIC.

§ SHAMD5IntRegister()

void SHAMD5IntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pfnHandleris a pointer to the function to be called when the enabled SHA/MD5 interrupts occur.

This function registers the interrupt handler in the interrupt vector table, and enables SHA/MD5 interrupts on the interrupt controller; specific SHA/MD5 interrupt sources must be enabled using SHAMD5IntEnable(). The interrupt handler being registered must clear the source of the interrupt using SHAMD5IntClear().

If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable SHA/MD5 interrupts on the interrupt controller.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

References ASSERT, INT_SHA0, IntEnable(), and IntRegister().

§ SHAMD5IntUnregister()

void SHAMD5IntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.

This function unregisters the previously registered interrupt handler and disables the interrupt in the interrupt controller.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

References ASSERT, INT_SHA0, IntDisable(), and IntUnregister().

§ SHAMD5HashLengthSet()

void SHAMD5HashLengthSet ( uint32_t  ui32Base,
uint32_t  ui32Length 
)

Write the hash length to the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
ui32Lengthis the hash length in bytes.

This function writes the length of the hash data of the current operation to the SHA/MD5 module. The value must be a multiple of 64 if the close hash is not set in the mode register.

Note
When this register is written, hash processing is triggered.
Returns
None.

References ASSERT, HWREG, and SHAMD5_O_LENGTH.

Referenced by SHAMD5DataProcess(), and SHAMD5HMACProcess().

§ SHAMD5ConfigSet()

void SHAMD5ConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Mode 
)

Writes the mode in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
ui32Modeis the mode of the SHA/MD5 module.

This function writes the mode register configuring the SHA/MD5 module.

The ui32Mode parameter is a bit-wise OR of values:

  • SHAMD5_ALGO_MD5 - Regular hash with MD5
  • SHAMD5_ALGO_SHA1 - Regular hash with SHA-1
  • SHAMD5_ALGO_SHA224 - Regular hash with SHA-224
  • SHAMD5_ALGO_SHA256 - Regular hash with SHA-256
  • SHAMD5_ALGO_HMAC_MD5 - HMAC with MD5
  • SHAMD5_ALGO_HMAC_SHA1 - HMAC with SHA-1
  • SHAMD5_ALGO_HMAC_SHA224 - HMAC with SHA-224
  • SHAMD5_ALGO_HMAC_SHA256 - HMAC with SHA-256
Returns
None

References ASSERT, HWREG, SHAMD5_ALGO_HMAC_MD5, SHAMD5_ALGO_HMAC_SHA1, SHAMD5_ALGO_HMAC_SHA224, SHAMD5_ALGO_HMAC_SHA256, SHAMD5_ALGO_MD5, SHAMD5_ALGO_SHA1, SHAMD5_ALGO_SHA224, SHAMD5_ALGO_SHA256, and SHAMD5_O_MODE.

§ SHAMD5DataWriteNonBlocking()

bool SHAMD5DataWriteNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Perform a non-blocking write of 16 words of data to the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32Srcis the pointer to the 16-word array of data that will be written.

This function writes 16 words of data into the data register regardless of whether or not the module is ready to accept the data.

Returns
This function returns true if the write completed successfully. It returns false if the module was not ready.

References ASSERT, HWREG, SHAMD5_INT_INPUT_READY, SHAMD5_O_DATA_0_IN, and SHAMD5_O_IRQSTATUS.

§ SHAMD5DataWrite()

void SHAMD5DataWrite ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Perform a blocking write of 16 words of data to the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32Srcis the pointer to the 16-word array of data that will be written.

This function does not return until the module is ready to accept data and the data has been written.

Returns
None.

References ASSERT, HWREG, SHAMD5_INT_INPUT_READY, SHAMD5_O_DATA_0_IN, and SHAMD5_O_IRQSTATUS.

§ SHAMD5ResultRead()

void SHAMD5ResultRead ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads the result of a hashing operation.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32Destis the pointer to the 16-word array of data that will be written.

This function does not return until the module is ready to accept data and the data has been written.

Returns
None.

References ASSERT, HWREG, SHAMD5_MODE_ALGO_M, SHAMD5_MODE_ALGO_MD5, SHAMD5_MODE_ALGO_SHA1, SHAMD5_MODE_ALGO_SHA224, SHAMD5_MODE_ALGO_SHA256, SHAMD5_O_IDIGEST_A, and SHAMD5_O_MODE.

§ SHAMD5DataProcess()

void SHAMD5DataProcess ( uint32_t  ui32Base,
uint32_t *  pui32DataSrc,
uint32_t  ui32DataLength,
uint32_t *  pui32HashResult 
)

Compute a hash using the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32DataSrcis a pointer to an array of data that contains the data that will be hashed.
ui32DataLengthspecifies the length of the data to be hashed in bytes.
pui32HashResultis a pointer to an array that holds the result of the hashing operation.

This function computes the hash of an array of data using the SHA/MD5 module.

The length of the hash result is dependent on the algorithm that is in use. The following table shows the correct array size for each algorithm:


| Algorithm | Number of Words in Result |

| MD5 | 4 Words (128 bits) | | SHA-1 | 5 Words (160 bits) | | SHA-224 | 7 Words (224 bits) |

| SHA-256 | 8 Words (256 bits) |

Returns
None

References ASSERT, HWREG, SHAMD5_INT_CONTEXT_READY, SHAMD5_O_IRQSTATUS, and SHAMD5HashLengthSet().

§ SHAMD5HMACProcess()

void SHAMD5HMACProcess ( uint32_t  ui32Base,
uint32_t *  pui32DataSrc,
uint32_t  ui32DataLength,
uint32_t *  pui32HashResult 
)

Compute a HMAC with key pre-processing using the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32DataSrcis a pointer to an array of data that contains the data that is to be hashed.
ui32DataLengthspecifies the length of the data to be hashed in bytes.
pui32HashResultis a pointer to an array that holds the result of the hashing operation.

This function computes a HMAC with the given data using the SHA/MD5 module with a preprocessed key.

The length of the hash result is dependent on the algorithm that is selected with the ui32Algo argument. The following table shows the correct array size for each algorithm:


| Algorithm | Number of Words in Result |

| MD5 | 4 Words (128 bits) | | SHA-1 | 5 Words (160 bits) | | SHA-224 | 7 Words (224 bits) |

| SHA-256 | 8 Words (256 bits) |

Returns
None

References ASSERT, HWREG, SHAMD5_INT_CONTEXT_READY, SHAMD5_O_IRQSTATUS, and SHAMD5HashLengthSet().

§ SHAMD5HMACPPKeyGenerate()

void SHAMD5HMACPPKeyGenerate ( uint32_t  ui32Base,
uint32_t *  pui32Key,
uint32_t *  pui32PPKey 
)

Process an HMAC key using the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32Keyis a pointer to an array that contains the key to be processed.
pui32PPKeyis the pointer to the array that contains the pre-processed key.

This function processes an HMAC key using the SHA/MD5. The resultant pre-processed key can then be used with later HMAC operations to speed processing time.

The pui32Key array must be 16 words (512 bits) long. If the key is less than 512 bits, it must be padded with zeros. The pui32PPKey array must each be 16 words (512 bits) long.

Returns
None

References ASSERT, HWREG, SHAMD5_INT_CONTEXT_READY, SHAMD5_INT_OUTPUT_READY, SHAMD5_MODE_HMAC_KEY_PROC, SHAMD5_O_IRQSTATUS, SHAMD5_O_LENGTH, SHAMD5_O_MODE, and SHAMD5_O_ODIGEST_A.

§ SHAMD5HMACKeySet()

void SHAMD5HMACKeySet ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes an HMAC key to the digest registers in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32Srcis the pointer to the 16-word array of the HMAC key.

This function is used to write HMAC key to the digest registers for key preprocessing. The size of pui32Src must be 512 bytes. If the key is less than 512 bytes, then it must be padded with zeros.

Note
It is recommended to use the SHAMD5IntStatus() function to check whether the context is ready before writing the key.
Returns
None

References ASSERT, HWREG, SHAMD5_MODE_CLOSE_HASH, SHAMD5_MODE_HMAC_KEY_PROC, SHAMD5_MODE_HMAC_OUTER_HASH, SHAMD5_O_MODE, and SHAMD5_O_ODIGEST_A.

§ SHAMD5HMACPPKeySet()

void SHAMD5HMACPPKeySet ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes a pre-processed HMAC key to the digest registers in the SHA/MD5 module.

Parameters
ui32Baseis the base address of the SHA/MD5 module.
pui32Srcis the pointer to the 16-word array of the HMAC key.

This function is used to write HMAC key to the digest registers for key preprocessing. The size of pui32Src must be 512 bytes. If the key is less than 512 bytes, then it must be padded with zeros.

Note
It is recommended to use the SHAMD5IntStatus() function to check whether the context is ready before writing the key.
Returns
None

References ASSERT, HWREG, SHAMD5_MODE_CLOSE_HASH, SHAMD5_MODE_HMAC_OUTER_HASH, SHAMD5_O_DIGEST_COUNT, SHAMD5_O_MODE, and SHAMD5_O_ODIGEST_A.

© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale