TrustCore SDK NanoCrypto API reference  version 7.0
des.h
Go to the documentation of this file.
1 /*
2  * des.h
3  *
4  * DES Header
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
19 /*------------------------------------------------------------------*/
20 
21 #ifndef __DES_HEADER__
22 #define __DES_HEADER__
23 
24 #include "../cap/capdecl.h"
25 
26 #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE__
27 #include "../crypto_interface/crypto_interface_des_priv.h"
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define DES_BLOCK_SIZE (8)
35 #define DES_KEY_LENGTH (8)
36 
37 
38 /*------------------------------------------------------------------*/
39 
40 /* IMPORTANT: if the size of this context is modified be sure to modify
41  MOC_RAND_CTX_WRAPPER_STORAGE_SIZE appropriately in random.h
42  */
43 
44 typedef struct
45 {
46  ubyte4 ek[32];
47  ubyte4 dk[32];
48  MocSymCtx pMocSymCtx;
49  ubyte4 initialized;
50  ubyte4 enabled;
51 
52 } des_ctx, DES_CTX;
53 
54 
55 /*------------------------------------------------------------------*/
56 
60 MOC_EXTERN MSTATUS DES_initKey(des_ctx *p_desContext, const ubyte *pKey, sbyte4 keyLen);
61 MOC_EXTERN MSTATUS DES_encipher(des_ctx *p_desContext, ubyte *pSrc, ubyte *pDest, ubyte4 numBytes);
62 MOC_EXTERN MSTATUS DES_decipher(des_ctx *p_desContext, ubyte *pSrc, ubyte *pDest, ubyte4 numBytes);
63 MOC_EXTERN MSTATUS DES_clearKey(des_ctx *p_desContext);
68 #ifdef __ENABLE_DES_CIPHER__
69 
128 MOC_EXTERN BulkCtx CreateDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte* keyMaterial, sbyte4 keyLength, sbyte4 encrypt);
129 
172 MOC_EXTERN MSTATUS DeleteDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx* ctx);
173 
220 MOC_EXTERN MSTATUS DoDES (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx ctx, ubyte* data, sbyte4 dataLength, sbyte4 encrypt, ubyte* iv);
221 
232 MOC_EXTERN MSTATUS CloneDESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx);
233 
234 #endif /* __ENABLE_DES_CIPHER__ */
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* __DES_HEADER__ */
MOC_EXTERN MSTATUS CloneDESCtx(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx)
Clone a TDES context previously created with CreateDESCtx.
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.
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...
MOC_EXTERN MSTATUS DeleteDESCtx(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ctx)
Delete DES context data structure.