TrustCore SDK NanoCrypto API reference  version 7.0
blowfish.h
Go to the documentation of this file.
1 /*
2  * blowfish.h
3  *
4  * Blowfish Header
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
19 /*------------------------------------------------------------------*/
20 
21 #ifndef __BLOWFISH_HEADER__
22 #define __BLOWFISH_HEADER__
23 
24 #include "../cap/capdecl.h"
25 
26 #if defined(__ENABLE_MOCANA_CRYPTO_INTERFACE__)
27 #include "../crypto_interface/crypto_interface_blowfish_priv.h"
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define MAXKEYBYTES (56) /* 448 bits */
35 #define BLOWFISH_BLOCK_SIZE (8)
36 
37 typedef struct
38 {
39  ubyte4 S[4][256], P[18];
40 
41  MocSymCtx pMocSymCtx;
42  ubyte enabled;
43  ubyte initialized;
44 
45 } blf_ctx;
46 
47 /*------------------------------------------------------------------*/
48 
109 MOC_EXTERN BulkCtx CreateBlowfishCtx(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte* keyMaterial, sbyte4 keyLength, sbyte4 encrypt);
110 
153 MOC_EXTERN MSTATUS DeleteBlowfishCtx(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx* ctx);
154 
202 MOC_EXTERN MSTATUS DoBlowfish(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx ctx, ubyte* data, sbyte4 dataLength, sbyte4 encrypt, ubyte* iv);
203 
204 
232 MOC_EXTERN MSTATUS CloneBlowfishCtx(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx);
233 
234 #ifdef __cplusplus
235 }
236 #endif
237 
238 #endif /* __BLOWFISH_HEADER__ */
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.
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 s...
MOC_EXTERN MSTATUS DeleteBlowfishCtx(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ctx)
Delete Blowfish context data structure.
MOC_EXTERN MSTATUS CloneBlowfishCtx(MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx)
Clones a Blowfish context.