![]() |
TrustCore SDK NanoCrypto API reference
version 7.0
|
Header file for the NanoCrypto Blowfish API. More...
Go to the source code of this file.
Functions | |
MOC_EXTERN MSTATUS | CloneBlowfishCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx) |
Clones a Blowfish context. More... | |
MOC_EXTERN BulkCtx | CreateBlowfishCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *keyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Get a new Blowfish context data structure (for operations using a Blowfish key) and prepare the key schedule. More... | |
MOC_EXTERN MSTATUS | DeleteBlowfishCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ctx) |
Delete Blowfish context data structure. More... | |
MOC_EXTERN MSTATUS | DoBlowfish (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx ctx, ubyte *data, sbyte4 dataLength, sbyte4 encrypt, ubyte *iv) |
Blowfish-encrypt or Blowfish-decrypt a data buffer. More... | |
Header file for the NanoCrypto Blowfish API.
MOC_EXTERN MSTATUS CloneBlowfishCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
BulkCtx * | ppNewCtx | ||
) |
Clones a Blowfish context. Be sure to free the new contex with a call to DeleteBlowfishCtx
.
To enable this function, the following flag must be defined:
__ENABLE_BLOWFISH_CIPHERS__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pCtx | Source Blowfish context. |
ppNewCtx | Will point to the newly allocated copy of the source context. |
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.MOC_EXTERN BulkCtx CreateBlowfishCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | keyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
This function creates and returns a context data structure for Blowfish operations, and prepares the key schedule (intermediate key material). This is the first function your application calls when performing Blowfish operations (encryption or decryption). Your application uses the returned structure in subsequent DoBlowfish() function calls.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | Blowfish |
The Blowfish context is an opaque data structure that holds information such as Blowfish context and key. To avoid memory leaks, your application code must call the DeleteBlowfishCtx() function after completing Blowfish operations (because the Blowfish context is dynamically allocated by this function during context creation).
NULL
is returned for the context pointer, you cannot use it as input to any subsequent DoBlowfish() function calls.To enable this function, the following flag must be defined:
__ENABLE_BLOWFISH_CIPHERS__
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. |
pKeyMaterial | Blowfish key to use for encryption or decryption. |
keyLength | Number of bytes in the Blowfish key; must be a valid Blowfish key length (expected value is 16 bytes). |
encrypt | TRUE to prepare the key schedule for encryption; FALSE to prepare the key schedule for decryption. |
NULL
if any error; otherwise pointer to created Blowfish context.MOC_EXTERN MSTATUS DeleteBlowfishCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * | ctx | ) |
This function deletes a Blowfish context data structure previously created by CreateBlowfishCtx(). To avoid memory leaks, your application must call this function after completing Blowfish-related operations for a given context.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | Blowfish |
To enable this function, the following flag must be defined:
__ENABLE_BLOWFISH_CIPHERS__
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 Blowfish context to delete. |
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.MOC_EXTERN MSTATUS DoBlowfish | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | ctx, |
ubyte * | data, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | iv | ||
) |
This function Blowfish-encrypts or Blowfish-decrypts a data buffer in CBC mode. Before calling this function, your application must call the CreateBlowfishCtx() function to dynamically create a valid Blowfish context.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | Blowfish |
To enable this function, the following flag must be defined:
__ENABLE_BLOWFISH_CIPHERS__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
ctx | Blowfish context, previously created by CreateBlowfishCtx(). |
data | Data to encrypt or decrypt. |
dataLength | Number of bytes of data to encrypt or decrypt (data ). |
encrypt | TRUE to encrypt the data; FALSE to decrypt the data. |
iv | Unique IV for the Blowfish operation (encryption or decryption). |
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.