MSP432E4 DriverLib API Guide  1.11.00.03
Functions
Des_api

Functions

void DESReset (uint32_t ui32Base)
 
void DESConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void DESKeySet (uint32_t ui32Base, uint32_t *pui32Key)
 
bool DESIVSet (uint32_t ui32Base, uint32_t *pui32IVdata)
 
void DESLengthSet (uint32_t ui32Base, uint32_t ui32Length)
 
bool DESDataReadNonBlocking (uint32_t ui32Base, uint32_t *pui32Dest)
 
void DESDataRead (uint32_t ui32Base, uint32_t *pui32Dest)
 
bool DESDataWriteNonBlocking (uint32_t ui32Base, uint32_t *pui32Src)
 
void DESDataWrite (uint32_t ui32Base, uint32_t *pui32Src)
 
bool DESDataProcess (uint32_t ui32Base, uint32_t *pui32Src, uint32_t *pui32Dest, uint32_t ui32Length)
 
uint32_t DESIntStatus (uint32_t ui32Base, bool bMasked)
 
void DESIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void DESIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void DESIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void DESIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void DESIntUnregister (uint32_t ui32Base)
 
void DESDMAEnable (uint32_t ui32Base, uint32_t ui32Flags)
 
void DESDMADisable (uint32_t ui32Base, uint32_t ui32Flags)
 

Detailed Description

Introduction

The DES module driver provides a method for performing encryption and decryption operations on blocks of 64-bits of data. The configuration and feature highlights are:

API Functions

The DES API consists of functions for configuring the DES module and processing data.

DES Programming Example

The following example sets up the DES module to perform an encryption operation on four blocks of data in CBC mode with an 64-bit key.

//
// Random data for encryption/decryption.
//
uint32_t g_ui32DESPlainText[16] = {
0xe2bec16b, 0x969f402e, 0x117e3de9, 0x2a179373,
0x578a2dae, 0x9cac031e, 0xac6fb79e, 0x518eaf45,
0x461cc830, 0x11e45ca3, 0x19c1fbe5, 0xef520a1a,
0x45249ff6, 0x179b4fdf, 0x7b412bad, 0x10376ce6
};
uint32_t g_ui32DESKey[2] = {
0xc7f51c87, 0x8076211f
};
uint32_t g_ui32DESIV[2] = {
0x6d8ecac4, 0x3b27c885
};
int
main(void)
{
pui32DESCipherText[16];
//
// Enable the CCM module.
//
//
// Wait for the CCM module to be ready.
//
{
}
//
// Reset the DES module before use.
//
DESReset(DES_BASE);
//
// Configure the DES module.
//
DESConfigSet(DES_BASE,
//
// Set the key.
//
DESKeySet(DES_BASE, g_ui32DESKey);
//
// Write the initial value registers.
//
DESIVSet(DES_BASE, g_ui32DESIV);
//
// Perform the encryption.
//
// The ciphertext should be:
// {0x95a74bd5, 0x8595094a, 0xf116bd1d, 0x2aed0a67,
// 0x4b4e730b, 0x163335ca, 0x8554d039, 0xb9f7e301,
// 0x599421e2, 0x5db5db40, 0x17fc1ce2, 0xf048de81,
// 0xabdf0d51, 0x6ce768f1, 0x8233fbdb, 0x3efe7bae}
//
DESDataProcess(DES_BASE, g_ui32DESPlainText, g_ui32DESCipherText, 64);
}

Function Documentation

§ DESReset()

void DESReset ( uint32_t  ui32Base)

Resets the DES Module.

Parameters
ui32Baseis the base address of the DES module.

This function performs a soft-reset sequence of the DES module.

Returns
None.

References ASSERT, DES_O_SYSCONFIG, DES_O_SYSSTATUS, DES_SYSCONFIG_SOFTRESET, DES_SYSSTATUS_RESETDONE, and HWREG.

§ DESConfigSet()

void DESConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the DES module for operation.

Parameters
ui32Baseis the base address of the DES module.
ui32Configis the configuration of the DES module.

This function configures the DES module for operation.

The ui32Config parameter is a bit-wise OR of a number of configuration flags. The valid flags are grouped below based on their function.

The direction of the operation is specified with one of the following two flags. Only one is permitted.

  • DES_CFG_DIR_ENCRYPT - Encryption
  • DES_CFG_DIR_DECRYPT - Decryption

The operational mode of the DES engine is specified with one of the following flags. Only one is permitted.

  • DES_CFG_MODE_ECB - Electronic Codebook Mode
  • DES_CFG_MODE_CBC - Cipher-Block Chaining Mode
  • DES_CFG_MODE_CFB - Cipher Feedback Mode

The selection of single DES or triple DES is specified with one of the following two flags. Only one is permitted.

  • DES_CFG_SINGLE - Single DES
  • DES_CFG_TRIPLE - Triple DES
Returns
None.

References ASSERT, DES_CTRL_CONTEXT, DES_O_CTRL, and HWREG.

§ DESKeySet()

void DESKeySet ( uint32_t  ui32Base,
uint32_t *  pui32Key 
)

Sets the key used for DES operations.

Parameters
ui32Baseis the base address of the DES module.
pui32Keyis a pointer to an array that holds the key

This function sets the key used for DES operations.

pui32Key should be 64 bits long (2 words) if single DES is being used or 192 bits (6 words) if triple DES is being used.

Returns
None.

References ASSERT, DES_CFG_TRIPLE, DES_O_CTRL, DES_O_KEY1_H, DES_O_KEY1_L, DES_O_KEY2_H, DES_O_KEY2_L, DES_O_KEY3_H, DES_O_KEY3_L, and HWREG.

§ DESIVSet()

bool DESIVSet ( uint32_t  ui32Base,
uint32_t *  pui32IVdata 
)

Sets the initialization vector in the DES module.

Parameters
ui32Baseis the base address of the DES module.
pui32IVdatais a pointer to an array of 64 bits (2 words) of data to be written into the initialization vectors registers.

This function sets the initialization vector in the DES module. It returns true if the registers were successfully written. If the context registers cannot be written at the time the function was called, then false is returned.

Returns
True or false.

References ASSERT, DES_CTRL_CONTEXT, DES_O_CTRL, DES_O_IV_H, DES_O_IV_L, and HWREG.

§ DESLengthSet()

void DESLengthSet ( uint32_t  ui32Base,
uint32_t  ui32Length 
)

Sets the crytographic data length in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32Lengthis the length of the data in bytes.

This function writes the cryptographic data length into the DES module. When this register is written, the engine is triggered to start using this context.

Note
Data lengths up to (2^32 - 1) bytes are allowed.
Returns
None.

References ASSERT, DES_O_LENGTH, and HWREG.

§ DESDataReadNonBlocking()

bool DESDataReadNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads plaintext/ciphertext from data registers without blocking

Parameters
ui32Baseis the base address of the DES module.
pui32Destis a pointer to an array of 2 words.

This function returns true if the data was ready when the function was called. If the data was not ready, false is returned.

Returns
True or false.

References ASSERT, DES_CTRL_OUTPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

Referenced by DESDataProcess().

§ DESDataRead()

void DESDataRead ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads plaintext/ciphertext from data registers with blocking.

Parameters
ui32Baseis the base address of the DES module.
pui32Destis a pointer to an array of bytes.

This function waits until the DES module is finished and encrypted or decrypted data is ready. The output data is then stored in the pui32Dest array.

Returns
None

References ASSERT, DES_CTRL_OUTPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

§ DESDataWriteNonBlocking()

bool DESDataWriteNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes plaintext/ciphertext to data registers without blocking

Parameters
ui32Baseis the base address of the DES module.
pui32Srcis a pointer to an array of 2 words.

This function returns false if the DES module is not ready to accept data. It returns true if the data was written successfully.

Returns
true or false.

References ASSERT, DES_CTRL_INPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

Referenced by DESDataProcess().

§ DESDataWrite()

void DESDataWrite ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes plaintext/ciphertext to data registers without blocking

Parameters
ui32Baseis the base address of the DES module.
pui32Srcis a pointer to an array of bytes.

This function waits until the DES module is ready before writing the data contained in the pui32Src array.

Returns
None.

References ASSERT, DES_CTRL_INPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

§ DESDataProcess()

bool DESDataProcess ( uint32_t  ui32Base,
uint32_t *  pui32Src,
uint32_t *  pui32Dest,
uint32_t  ui32Length 
)

Processes blocks of data through the DES module.

Parameters
ui32Baseis the base address of the DES module.
pui32Srcis a pointer to an array of words that contains the source data for processing.
pui32Destis a pointer to an array of words consisting of the processed data.
ui32Lengthis the length of the cryptographic data in bytes. It must be a multiple of eight.

This function takes the data contained in the pui32Src array and processes it using the DES engine. The resulting data is stored in the pui32Dest array. The function blocks until all of the data has been processed. If processing is successful, the function returns true.

Note
This functions assumes that the DES module has been configured, and initialization values and keys have been written.
Returns
true or false.

References ASSERT, DES_CTRL_INPUT_READY, DES_CTRL_OUTPUT_READY, DES_O_CTRL, DES_O_LENGTH, DESDataReadNonBlocking(), DESDataWriteNonBlocking(), and HWREG.

§ DESIntStatus()

uint32_t DESIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Returns the current interrupt status of the DES module.

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

This function gets the current interrupt status of the DES module. The value returned is a logical OR of the following values:

  • DES_INT_CONTEXT_IN - Context interrupt
  • DES_INT_DATA_IN - Data input interrupt
  • DES_INT_DATA_OUT_INT - Data output interrupt
  • DES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • DES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • DES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Returns
A bit mask of the current interrupt status.

References ASSERT, DES_O_DMAMIS, DES_O_DMARIS, DES_O_IRQENABLE, DES_O_IRQSTATUS, and HWREG.

§ DESIntEnable()

void DESIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables interrupts in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32IntFlagsis a bit mask of the interrupts to be enabled.

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

  • DES_INT_CONTEXT_IN - Context interrupt
  • DES_INT_DATA_IN - Data input interrupt
  • DES_INT_DATA_OUT - Data output interrupt
  • DES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • DES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • DES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Returns
None.

References ASSERT, DES_INT_CONTEXT_IN, DES_INT_DATA_IN, DES_INT_DATA_OUT, DES_INT_DMA_CONTEXT_IN, DES_INT_DMA_DATA_IN, DES_INT_DMA_DATA_OUT, DES_O_DMAIM, DES_O_IRQENABLE, and HWREG.

§ DESIntDisable()

void DESIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables interrupts in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32IntFlagsis a bit mask of the interrupts to be disabled.

This function disables interrupt sources in the DES module. ui32IntFlags should be a logical OR of one or more of the following values:

  • DES_INT_CONTEXT_IN - Context interrupt
  • DES_INT_DATA_IN - Data input interrupt
  • DES_INT_DATA_OUT - Data output interrupt
  • DES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • DES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • DES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Returns
None.

References ASSERT, DES_INT_CONTEXT_IN, DES_INT_DATA_IN, DES_INT_DATA_OUT, DES_INT_DMA_CONTEXT_IN, DES_INT_DMA_DATA_IN, DES_INT_DMA_DATA_OUT, DES_O_DMAIM, DES_O_IRQENABLE, and HWREG.

§ DESIntClear()

void DESIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears interrupts in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32IntFlagsis a bit mask of the interrupts to be disabled.

This function disables interrupt sources in the DES module. ui32IntFlags should be a logical OR of one or more of the following values:

  • DES_INT_DMA_CONTEXT_IN - Context interrupt
  • DES_INT_DMA_DATA_IN - Data input interrupt
  • DES_INT_DMA_DATA_OUT - Data output interrupt
Note
The DMA done interrupts are the only interrupts that can be cleared. The remaining interrupts can be disabled instead using DESIntDisable().
Returns
None.

References ASSERT, DES_INT_DMA_CONTEXT_IN, DES_INT_DMA_DATA_IN, DES_INT_DMA_DATA_OUT, DES_O_DMAIC, and HWREG.

§ DESIntRegister()

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

Registers an interrupt handler for the DES module.

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

This function registers the interrupt handler in the interrupt vector table, and enables DES interrupts on the interrupt controller; specific DES interrupt sources must be enabled using DESIntEnable(). The interrupt handler being registered must clear the source of the interrupt using DESIntClear().

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 DES interrupts on the interrupt controller.

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

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

§ DESIntUnregister()

void DESIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the DES module.

Parameters
ui32Baseis the base address of the DES 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_DES0, IntDisable(), and IntUnregister().

§ DESDMAEnable()

void DESDMAEnable ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Enables DMA request sources in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32Flagsis a bit mask of the DMA requests to be enabled.

This function enables DMA request sources in the DES module. The ui32Flags parameter should be the logical OR of any of the following:

  • DES_DMA_CONTEXT_IN - Context In
  • DES_DMA_DATA_OUT - Data Out
  • DES_DMA_DATA_IN - Data In
Returns
None.

References ASSERT, DES_DMA_CONTEXT_IN, DES_DMA_DATA_IN, DES_DMA_DATA_OUT, DES_O_SYSCONFIG, and HWREG.

§ DESDMADisable()

void DESDMADisable ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Disables DMA request sources in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32Flagsis a bit mask of the DMA requests to be disabled.

This function disables DMA request sources in the DES module. The ui32Flags parameter should be the logical OR of any of the following:

  • DES_DMA_CONTEXT_IN - Context In
  • DES_DMA_DATA_OUT - Data Out
  • DES_DMA_DATA_IN - Data In
Returns
None.

References ASSERT, DES_DMA_CONTEXT_IN, DES_DMA_DATA_IN, DES_DMA_DATA_OUT, DES_O_SYSCONFIG, and HWREG.

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