Header file for the NanoCrypto DES API.
More...
Go to the source code of this file.
|
typedef struct des_ctx | DES_CTX |
|
|
MOC_EXTERN MSTATUS | CloneDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx) |
| Clone a TDES context previously created with CreateDESCtx. More...
|
|
MOC_EXTERN BulkCtx | CreateDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *keyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
| Get a new DES context data structure (for operations using a DES key) and prepare the key schedule. More...
|
|
MOC_EXTERN MSTATUS | DeleteDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ctx) |
| Delete DES context data structure. More...
|
|
MOC_EXTERN MSTATUS | DoDES (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx ctx, ubyte *data, sbyte4 dataLength, sbyte4 encrypt, ubyte *iv) |
| DES-encrypt or DES-decrypt a data buffer. More...
|
|
Header file for the NanoCrypto DES API.
◆ CloneDESCtx()
MOC_EXTERN MSTATUS CloneDESCtx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx |
pCtx, |
|
|
BulkCtx * |
ppNewCtx |
|
) |
| |
- Parameters
-
pCtx | Pointer to a BulkCtx returned by CreateDESCtx. |
ppNewCtx | Double pointer to the BulkCtx to be created and populated with the key data from the source key. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CreateDESCtx()
MOC_EXTERN BulkCtx CreateDESCtx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * |
keyMaterial, |
|
|
sbyte4 |
keyLength, |
|
|
sbyte4 |
encrypt |
|
) |
| |
This function creates and returns a context data structure for DES operations that use a DES key, and prepares the key schedule (intermediate key material). This is the first function your application calls when performing DES operations (encryption or decryption). Your application uses the returned structure in subsequent DoDES() function calls.
FIPS Approved |
|
Suite B Algorithm |
|
Flowchart | DES |
The DES context is an opaque data structure that holds information such as DES context and key. To avoid memory leaks, your application code must call the DeleteDESCtx() function after completing DES-related operations (because the DES context is dynamically allocated by this function during context creation).
- Warning
- If
NULL
is returned for the context pointer, you cannot use it as input to any subsequent DoDES() function calls.
To enable this function, the following flag must be defined:
des.h
- Parameters
-
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr
hwAccelCtx". Otherwise, this macro resolves to nothing. But... what does the user specify? In the 5.3.1 docs, we just said that this was "Reserved
for future use." Ditto this for all aes_ccm.{c,h} functions. |
keyMaterial | DES key to use for encryption or decryption. |
keyLength | Number of bytes in the DES key; must be a valid DES key length (expected value is 8 bytes). |
encrypt | TRUE to prepare the key schedule for encryption; FALSE to prepare the key schedule for decryption. |
- Returns
NULL
if any error; otherwise pointer to created DES context.
des.h
◆ DeleteDESCtx()
MOC_EXTERN MSTATUS DeleteDESCtx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * |
ctx | ) |
|
This function deletes a DES context data structure previously created by CreateDESCtx(). To avoid memory leaks, your application must call this function after completing DES-related operations for a given context.
FIPS Approved |
|
Suite B Algorithm |
|
Flowchart | DES |
To enable this function, the following flag must be defined:
des.h
- Parameters
-
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr
hwAccelCtx". Otherwise, this macro resolves to nothing. |
ctx | Pointer to DES context to delete. |
- Returns
OK
(0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR
macro.
des.h
◆ DoDES()
MOC_EXTERN MSTATUS DoDES |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx |
ctx, |
|
|
ubyte * |
data, |
|
|
sbyte4 |
dataLength, |
|
|
sbyte4 |
encrypt, |
|
|
ubyte * |
iv |
|
) |
| |
This function DES-encrypts or DES-decrypts a data buffer. Before calling this function, your application must call the CreateDESCtx() function to dynamically create a valid DES context.
FIPS Approved |
|
Suite B Algorithm |
|
Flowchart | DES |
To enable this function, the following flag must be defined:
des.h
- Parameters
-
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr
hwAccelCtx". Otherwise, this macro resolves to nothing. |
ctx | DES context, previously created by CreateDESCtx. |
data | Data to be encrypted or decrypted. |
dataLength | Number of bytes of data to be encrypted or decrypted (data ). |
encrypt | TRUE to encrypt the data; FALSE to decrypt the data. |
iv | Unique IV for the DES operation (encryption or decryption). |
- Returns
OK
(0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR
macro.
des.h