Cryptographic Interface header file for declaring DES functions.
More...
Go to the source code of this file.
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_CloneDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx) |
| Copy a DES context previously created with CRYPTO_INTERFACE_CreateDESCtx. More...
|
|
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyMaterial, sbyte4 keyLen, sbyte4 encrypt) |
| Creates a new DES-CBC context. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DeleteDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *pCtx) |
| Deletes a DES-CBC context previously created with CRYPTO_INTERFACE_CreateDESCtx. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DES_clearKey (DES_CTX *pCtx) |
| Delete a DES-ECB context previously initialized with CRYPTO_INTERFACE_DES_initKey. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DES_decipher (DES_CTX *pCtx, ubyte *pSrc, ubyte *pDest, ubyte4 numBytes) |
| Decrypts data using the provided DES context. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DES_encipher (DES_CTX *pCtx, ubyte *pSrc, ubyte *pDest, ubyte4 numBytes) |
| Encrypts data using the provided DES context. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DES_initKey (DES_CTX *pCtx, const ubyte *pKey, sbyte4 keyLen) |
| Initialize a raw DES-ECB object for operation. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoDES (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLen, sbyte4 encrypt, ubyte *pIv) |
| Encrypt or decrypt data using the provided DES context in CBC mode. More...
|
|
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoDESEx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLen, sbyte4 encrypt, ubyte *pIv) |
| Encrypt or decrypt data using the provided DES context in CBC mode. More...
|
|
◆ CRYPTO_INTERFACE_CloneDESCtx()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_CloneDESCtx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx |
pCtx, |
|
|
BulkCtx * |
ppNewCtx |
|
) |
| |
- Parameters
-
pSrc | Pointer to a BulkCtx returned by CRYPTO_INTERFACE_CreateDESCtx. |
pDest | 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.
◆ CRYPTO_INTERFACE_CreateDESCtx()
MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateDESCtx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * |
pKeyMaterial, |
|
|
sbyte4 |
keyLen, |
|
|
sbyte4 |
encrypt |
|
) |
| |
This function will allocate and return a new DES-CBC context to be used with CRYPTO_INTERFACE_DoDES. It is the callers responsibility to free this context after use by calling CRYPTO_INTERFACE_DeleteDESCtx.
- Parameters
-
pKeyMaterial | The key material to use for this context creation. |
keyLen | Length in bytes of the key material, must be exactly 8 bytes. |
encrypt | TRUE to prepare this object for encryption or FALSE to prepare this object for decryption. |
- Returns
NULL
on error, otherwise a pointer to a DES context
◆ CRYPTO_INTERFACE_DeleteDESCtx()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DeleteDESCtx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * |
pCtx | ) |
|
Note that this function frees the underlying context created by the crypto interface. Failing to call this function after use will result in a memory leak.
- Parameters
-
pCtx | Pointer to a DES context previously created with CRYPTO_INTERFACE_CreateDESCtx. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CRYPTO_INTERFACE_DES_clearKey()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DES_clearKey |
( |
DES_CTX * |
pCtx | ) |
|
Note that this function frees the underlying context created by the crypto interface. Even though the DES_CTX pointer was originally allocated by the caller, failing to call this function after use will result in a memory leak.
- Parameters
-
pCtx | Pointer to a DES-ECB context previously initialized with CRYPTO_INTERFACE_DES_initKey. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CRYPTO_INTERFACE_DES_decipher()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DES_decipher |
( |
DES_CTX * |
pCtx, |
|
|
ubyte * |
pSrc, |
|
|
ubyte * |
pDest, |
|
|
ubyte4 |
numBytes |
|
) |
| |
The data length must be a multiple of the blocksize of 8 bytes.
- Parameters
-
pCtx | A previously initialized context to use for the cipher operation. |
pSrc | Buffer of the data to decrypt. |
pDest | Buffer to hold the resulting plaintext. This must be at least the same length as pSrc. |
numBytes | Length in bytes of the buffer pSrc. Must be a multiple of the DES blocksize of 8 bytes. |
Note that you can NOT reuse a DES context to start a new cipher operation. Ensure that each object is used for only one encrypt or decrypt operation, you must create a new object to start a new cipher operation.
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CRYPTO_INTERFACE_DES_encipher()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DES_encipher |
( |
DES_CTX * |
pCtx, |
|
|
ubyte * |
pSrc, |
|
|
ubyte * |
pDest, |
|
|
ubyte4 |
numBytes |
|
) |
| |
The data length must be a multiple of the blocksize of 8 bytes.
- Parameters
-
pCtx | A previously initialized context to use for the cipher operation. |
pSrc | Buffer of the data to encrypt. |
pDest | Buffer to hold the resulting ciphertext. This must be at least the same length as pSrc. |
numBytes | Length in bytes of the buffer pSrc. Must be a multiple of the DES blocksize of 8 bytes. |
Note that you can NOT reuse a DES context to start a new cipher operation. Ensure that each object is used for only one encrypt or decrypt operation, you must create a new object to start a new cipher operation.
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CRYPTO_INTERFACE_DES_initKey()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DES_initKey |
( |
DES_CTX * |
pCtx, |
|
|
const ubyte * |
pKey, |
|
|
sbyte4 |
keyLen |
|
) |
| |
Note that this should only be used when constructing a larger cryptographic scheme that requires a DES-ECB primitive. It is the callers responsibility to delete this context after use by calling CRYPTO_INTERFACE_DES_clearKey.
- Parameters
-
pCtx | Pointer to a caller allocated DES-ECB context to be initialized. |
pKey | Key material to use for this operation. |
keyLen | Length in bytes of key material to use, must be exactly 8 bytes. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CRYPTO_INTERFACE_DoDES()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoDES |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx |
pCtx, |
|
|
ubyte * |
pData, |
|
|
sbyte4 |
dataLen, |
|
|
sbyte4 |
encrypt, |
|
|
ubyte * |
pIv |
|
) |
| |
This function can be used to stream data. Pass in the initialization vector on the first call, but each subsequent call is not guaranteed to use the initialization vector passed in. Please use CRYPTO_INTERFACE_DoDESEx if you need a modified iv. Note that this operation is in place, so the pData buffer will contain the result.
Note that you can NOT reuse a DES context to start a new cipher operation. Ensure that each object is used for only one encrypt or decrypt operation, you must create a new object to start a new cipher operation.
- Parameters
-
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLen | Length in bytes of the data to process. |
encrypt | TRUE to encrypt, FALSE to decrypt. Must match the value used in CRYPTO_INTERFACE_Create3DESCtx. |
pIv | Initialization vector for the cipher operation. Must be exactly 8 bytes. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.
◆ CRYPTO_INTERFACE_DoDESEx()
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoDESEx |
( |
MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx |
pCtx, |
|
|
ubyte * |
pData, |
|
|
sbyte4 |
dataLen, |
|
|
sbyte4 |
encrypt, |
|
|
ubyte * |
pIv |
|
) |
| |
This function can be used to stream data. Pass in the initialization vector and it will be updated in place. Continue to pass in new data and updated initialization vector on each subsequent call. The updated iv will be written to pIv upon method completion. Note that this operation is in place, so the pData buffer will contain the result.
Note that you can NOT reuse a DES context to start a new cipher operation. Ensure that each object is used for only one encrypt or decrypt operation, you must create a new object to start a new cipher operation.
- Parameters
-
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLen | Length in bytes of the data to process. |
encrypt | TRUE to encrypt, FALSE to decrypt. Must match the value used in CRYPTO_INTERFACE_Create3DESCtx. |
pIv | Initialization vector for the cipher operation. Must be exactly 8 bytes. Will contain the working IV when the method finishes. |
- Returns
OK
(0) if successful, otherwise a negative number error code from merrors.h.