![]() |
TrustCore SDK NanoCrypto API reference
version 7.0
|
Header file for the NanoCrypto Cast128 APIs. More...
Go to the source code of this file.
Functions | |
MOC_EXTERN MSTATUS | CAST128_decryptBlock (cast128_ctx *pCtx, ubyte inblock[], ubyte outblock[]) |
Decrypts a block of ciphertext. More... | |
MOC_EXTERN MSTATUS | CAST128_encryptBlock (cast128_ctx *pCtx, ubyte inblock[], ubyte outblock[]) |
Encrypts a block of plaintext. More... | |
MOC_EXTERN MSTATUS | CAST128_initKey (cast128_ctx *pCtx, const ubyte *pKey, sbyte4 keyLen) |
Initializes a cast128 context with a key. More... | |
MOC_EXTERN BulkCtx | CreateCast128Ctx (MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *keyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Allocates and initalizes a new cast128 context. More... | |
MOC_EXTERN MSTATUS | DeleteCast128Ctx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ctx) |
Deletes a cast128 context. More... | |
MOC_EXTERN MSTATUS | DoCast128 (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx ctx, ubyte *data, sbyte4 dataLength, sbyte4 encrypt, ubyte *iv) |
Performs cast128 in CBC mode on a buffer of data. More... | |
This file contains the NanoCrypto Cast128 API methods.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
MOC_EXTERN MSTATUS CAST128_decryptBlock | ( | cast128_ctx * | pCtx, |
ubyte | inblock[], | ||
ubyte | outblock[] | ||
) |
Decrypts a block of ciphertext.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
pCtx | Pointer to a previously initialized context. |
inblock | Buffer of the input 8 byte block of ciphertext. |
outblock | Buffer that will hold the resulting 8 byte block of plaintext. |
OK
(0) if successful; otherwise a negative number error code definition from merrors.h.MOC_EXTERN MSTATUS CAST128_encryptBlock | ( | cast128_ctx * | pCtx, |
ubyte | inblock[], | ||
ubyte | outblock[] | ||
) |
Encrypts a block of plaintext.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
pCtx | Pointer to a previously initialized context. |
inblock | Buffer of the input 8 byte block of plaintext. |
outblock | Buffer that will hold the resulting 8 byte block of ciphertext. |
OK
(0) if successful; otherwise a negative number error code definition from merrors.h.MOC_EXTERN MSTATUS CAST128_initKey | ( | cast128_ctx * | pCtx, |
const ubyte * | pKey, | ||
sbyte4 | keyLen | ||
) |
Initializes a cast128 context with a key.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
pCtx | Pointer to a context to be initialized with a key. |
pKey | Buffer holding the input key. |
keyLen | The length of the key in bytes. |
OK
(0) if successful; otherwise a negative number error code definition from merrors.h.MOC_EXTERN BulkCtx CreateCast128Ctx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte * | keyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Allocates and initalizes a new cast128 context with an input key.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
keyMaterial | Buffer holding the input key material. |
keyLength | The length of the input key in bytes. |
encrypt | Unused. |
BulkCtx
. Otherwise NULL is returned.MOC_EXTERN MSTATUS DeleteCast128Ctx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * | ctx | ) |
Deletes and frees memory allocated for a cast128 context.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
ctx | Pointer to the location of the context to be deleted. |
OK
(0) if successful; otherwise a negative number error code definition from merrors.h.MOC_EXTERN MSTATUS DoCast128 | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | ctx, |
ubyte * | data, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | iv | ||
) |
Performs cast128 in CBC mode to encrypt or decrypt a buffer of data. The length of this data must be a multiple of the cast block size of 8 bytes. This method may be called as many times as necessary and the initialization vector will be updated in-place.
To enable this file's methods define the following flag:
__ENABLE_CAST128_CIPHER__
ctx | Pointer to a previously created context. |
data | A buffer holding the data to be encrypted or decrypted. This will be encrypted or decrypted in-place. |
dataLength | The length of the data in bytes. This must be a multiple of 8. |
encrypt | Pass TRUE (1) for encryption and FALSE (0) for decryption. |
iv | The 8 byte initialization vector. This will be updated in place to the iv for the next input block. |
OK
(0) if successful; otherwise a negative number error code definition from merrors.h.