TrustCore SDK Crypto Interface API reference  version 2.0
cryptointerface.h
Go to the documentation of this file.
1 /*
2  * cryptointerface.h
3  *
4  * Implementation of Crypto Wrapper.
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
10 
25 /*------------------------------------------------------------------*/
26 
27 #ifndef __CRYPTOINTERFACE_HEADER__
28 #define __CRYPTOINTERFACE_HEADER__
29 
30 #include "../crypto/primefld.h"
31 #include "../crypto/ecc.h"
32 #include "../crypto/primefld_priv.h"
33 #include "../crypto/primeec_priv.h"
34 #include "../crypto/sha256.h"
35 #include "../crypto/pkcs1.h"
36 #include "../crypto/aes.h"
37 #include "../crypto/des.h"
38 #include "../crypto/three_des.h"
39 
40 #if defined(__ENABLE_MOCANA_TAP__)
41 #include "../tap/tap.h"
42 #include "../tap/tap_smp.h"
43 #endif
44 
45 #if defined(__ENABLE_MOCANA_CRYPTO_INTERFACE__)
46 #include "../crypto_interface/crypto_interface_rsa.h"
47 #include "../crypto_interface/crypto_interface_aes_gcm.h"
48 #include "../crypto_interface/crypto_interface_tdes.h"
49 
50 #if defined(__ENABLE_MOCANA_ECC__)
51 #include "../crypto_interface/crypto_interface_ecc.h"
52 #endif
53 
54 #if defined(__ENABLE_MOCANA_TAP__)
55 #include "../data_protection/tap_data_protect.h"
56 #endif
57 
58 #endif /* __ENABLE_MOCANA_CRYPTO_INTERFACE__ */
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 #if defined(__ENABLE_MOCANA_CRYPTO_INTERFACE__)
65 #if defined(__ENABLE_MOCANA_TAP__)
66 
67 #if defined(__ENABLE_MOCANA_TAP_EXTERN__)
68 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_TAPExternInit();
69 #endif
70 
95 typedef MSTATUS (*pFuncPtrGetTapContext)(TAP_Context **ppTapCtx,
96  TAP_EntityCredentialList **ppTapEntityCred,
97  TAP_CredentialList **ppTapKeyCred,
98  void *pKey, TapOperation op, ubyte getContext);
99 
100 MOC_EXTERN pFuncPtrGetTapContext g_pFuncPtrGetTapContext;
101 
129  FingerprintElement **ppElements,
130  ubyte4 *pNumElements,
131  ubyte **ppInitialSeed,
132  ubyte4 *pInitialSeedLen,
133  ubyte8 ek_obj_id
134  );
135 
136 #endif
137 
156 MOC_EXTERN MSTATUS
158 
159 MOC_EXTERN MSTATUS
160 CRYPTO_INTERFACE_getKeyType(void *pKey, ubyte4 *keyType);
161 
182 MOC_EXTERN MSTATUS
183 CRYPTO_INTERFACE_getKeyUsage(void *pKey, ubyte4 keyType, ubyte *pKeyUsage);
184 
185 MOC_EXTERN MSTATUS
186 CRYPTO_WRAPPER_getRSATAPKeySize(void *pKey, ubyte4 *keySize);
187 
188 MOC_EXTERN MSTATUS
189 CRYPTO_INTERFACE_getRSACipherTextLength(MOC_RSA(hwAccelDescr hwAccelCtx) void *pKey, sbyte4 *pModulusLen, ubyte4 keyType);
190 
191 MOC_EXTERN MSTATUS
192 CRYPTO_INTERFACE_copyAsymmetricKey(AsymmetricKey *pNew, const AsymmetricKey *pSrc);
193 
214 MOC_EXTERN MSTATUS
215 CRYPTO_INTERFACE_getPublicKey(AsymmetricKey *pKey, AsymmetricKey *pPubKey);
216 
217 #ifdef __ENABLE_MOCANA_ECC__
218 /* This function is deprecated. Use CRYPTO_INTERFACE_EC_getCurveIdFromKeyAux
219  * instead.
220  */
221 MOC_EXTERN MSTATUS
222 CRYPTO_INTERFACE_getECurve(void *pKey, PEllipticCurvePtr *ppECurve, ubyte4 keyType);
223 #endif
224 
225 #if (defined(__ENABLE_MOCANA_ECC__))
226 
245 MOC_EXTERN MSTATUS
246 CRYPTO_INTERFACE_getECCPublicKey(AsymmetricKey *pKey, ECCKey **ppPub);
247 #endif
248 
268 MOC_EXTERN MSTATUS
269 CRYPTO_INTERFACE_getRSAPublicKey(AsymmetricKey *pKey, RSAKey **ppPub);
270 
291 MOC_EXTERN MSTATUS
292 CRYPTO_INTERFACE_getRsaSwPubFromTapKey(RSAKey *pKey, RSAKey **ppPub);
293 
294 #if defined(__ENABLE_MOCANA_TAP__)
295 
307 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_asymmetricKeyAddCreds(
308  AsymmetricKey *pKey,
309  sbyte *pPassword,
310  sbyte4 passwordLen);
311 
322  AsymmetricKey *pKey);
323 
334 MOC_EXTERN MSTATUS
335 CRYPTO_INTERFACE_TAP_AsymDeferUnload(AsymmetricKey *pKey, byteBoolean deferredTokenUnload);
336 
340 MOC_EXTERN MSTATUS
341 CRYPTO_INTERFACE_TAP_rsaDeferUnloadMocAsym(MocAsymKey pKey, byteBoolean deferredTokenUnload);
342 
343 #if defined(__ENABLE_MOCANA_ECC__)
344 
347 MOC_EXTERN MSTATUS
348 CRYPTO_INTERFACE_TAP_eccDeferUnloadMocAsym(MocAsymKey pKey, byteBoolean deferredTokenUnload);
349 #endif /* __ENABLE_MOCANA_ECC__ */
350 
366 MOC_EXTERN MSTATUS
367 CRYPTO_INTERFACE_TAP_AsymGetKeyInfo(AsymmetricKey *pKey, ubyte4 keyType, TAP_TokenHandle *pTokenHandle, TAP_KeyHandle *pKeyHandle);
368 
372 MOC_EXTERN MSTATUS
373 CRYPTO_INTERFACE_TAP_rsaGetKeyInfoMocAsym(MocAsymKey pKey, TAP_TokenHandle *pTokenHandle, TAP_KeyHandle *pKeyHandle);
374 
375 #if defined(__ENABLE_MOCANA_ECC__)
376 
380 MOC_EXTERN MSTATUS
381 CRYPTO_INTERFACE_TAP_eccGetKeyInfoMocAsym(MocAsymKey pKey, TAP_TokenHandle *pTokenHandle, TAP_KeyHandle *pKeyHandle);
382 
383 #endif /* __ENABLE_MOCANA_ECC__ */
384 
385 
404 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_TAP_asymGetTapObjectId(AsymmetricKey *pKey, ubyte **ppId, ubyte4 *pIdLen);
405 
428 MOC_EXTERN MSTATUS
429 CRYPTO_INTERFACE_getTapKey(AsymmetricKey *pKey, TAP_Key **ppTapKey);
430 
453 MOC_EXTERN MSTATUS
454 CRYPTO_INTERFACE_unloadTapKey(TAP_Context *pTapCtx, TAP_TokenHandle tokenHandle, TAP_KeyHandle keyHandle);
455 
476 MOC_EXTERN MSTATUS
477 CRYPTO_INTERFACE_unloadTapToken(TAP_Context *pTapCtx, TAP_TokenHandle tokenHandle);
478 
501 MOC_EXTERN MSTATUS
502 CRYPTO_INTERFACE_RSA_getTapKey(RSAKey *pRsaKey, TAP_Key **ppTapKey);
503 
504 #if (defined(__ENABLE_MOCANA_ECC__))
505 
506 MOC_EXTERN MSTATUS
507 CRYPTO_INTERFACE_TAP_eccGetKeyInfo(ECCKey *pECCKey, ubyte4 keyType,
508  TAP_TokenHandle *pTokenHandle,
509  TAP_KeyHandle *pKeyHandle);
532 MOC_EXTERN MSTATUS
533 CRYPTO_INTERFACE_ECC_getTapKey(ECCKey *pEccKey, TAP_Key **ppTapKey);
534 
535 #endif /* if (defined(__ENABLE_MOCANA_ECC__)) */
536 #endif /* if defined(__ENABLE_MOCANA_TAP__) */
537 
563 MOC_EXTERN MSTATUS
564 CRYPTO_INTERFACE_RSA_signMessage(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey,
565  const ubyte* plainText, ubyte4 plainTextLen,
566  ubyte* cipherText, vlong **ppVlongQueue, ubyte4 keyType);
567 
599 MOC_EXTERN MSTATUS
600 CRYPTO_INTERFACE_RSA_signMessageEx(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey,
601  const ubyte* plainText, ubyte4 plainTextLen,
602  ubyte* cipherText, vlong **ppVlongQueue, ubyte4 keyType);
603 
604 
630 MOC_EXTERN MSTATUS
631 CRYPTO_INTERFACE_RSA_verifySignature(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey,
632  const ubyte* cipherText, ubyte* plainText, ubyte4* plainTextLen, vlong **ppVlongQueue, ubyte4 keyType);
633 
634 #if (defined(__ENABLE_MOCANA_ECC__))
635 
665 MOC_EXTERN MSTATUS
666 CRYPTO_INTERFACE_ECDSA_sign(void *pECCKey, RNGFun rngFun, void *rngArg,
667  const ubyte* hash, ubyte4 hashLen,
668  PFEPtr r, PFEPtr s, ubyte4 keyType);
700 MOC_EXTERN MSTATUS
701 CRYPTO_INTERFACE_ECDSA_signEx(void *pECCKey, RNGFun rngFun, void *rngArg,
702  const ubyte* pPlainText, ubyte4 plainTextLen,
703  PFEPtr r, PFEPtr s, ubyte4 keyType);
704 
705 
735 MOC_EXTERN MSTATUS
736 CRYPTO_INTERFACE_ECDSA_verifySignature( void *pECCKey, const ubyte* hash, ubyte4 hashLen,
737  ConstPFEPtr r, ConstPFEPtr s, ubyte4 keyType);
738 #endif
739 
750 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_freeKey(
751  void **ppKey,
752  vlong **ppVlongQueue,
753  ubyte4 keyType
754  );
755 
771  MOC_RSA(hwAccelDescr hwAccelCtx)
772  void *pKey,
773  ubyte4 exponent,
774  const ubyte *pModulus,
775  ubyte4 modulusLen,
776  vlong **ppVlongQueue,
777  ubyte4 keyType
778  );
779 
799 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_setAllKeyData(
800  MOC_RSA(hwAccelDescr hwAccelCtx)
801  void *pKey,
802  ubyte *pPubExpo,
803  ubyte4 pubExpoLen,
804  const ubyte *pModulus,
805  ubyte4 modulusLen,
806  const ubyte *pPrime,
807  ubyte4 primeLen,
808  const ubyte *pSubprime,
809  ubyte4 subprimeLen,
810  vlong **ppVlongQueue,
811  ubyte4 keyType
812  );
813 
839  MOC_RSA(hwAccelDescr hwAccelCtx)
840  void *pKey,
841  MRsaKeyTemplate *pTemplate,
842  ubyte reqType,
843  ubyte4 keyType
844  );
845 
857 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_freeKeyTemplate(
858  void *pKey,
859  MRsaKeyTemplate *pTemplate,
860  ubyte4 keyType
861  );
862 
881 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_applyPublicKey(
882  MOC_RSA(hwAccelDescr hwAccelCtx)
883  void *pKey,
884  ubyte *pInput,
885  ubyte4 inputLen,
886  ubyte **ppOutput,
887  vlong **ppVlongQueue,
888  ubyte4 keyType
889  );
890 
912 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_applyPrivateKey(
913  MOC_RSA(hwAccelDescr hwAccelCtx)
914  void *pKey,
915  RNGFun rngFun,
916  void *pRngFunArg,
917  ubyte *pInput,
918  ubyte4 inputLen,
919  ubyte **ppOutput,
920  vlong **ppVlongQueue,
921  ubyte4 keyType
922  );
923 
951 MOC_EXTERN MSTATUS
952 CRYPTO_INTERFACE_RSA_encrypt(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey,
953  const ubyte* plainText, ubyte4 plainTextLen, ubyte* cipherText,
954  RNGFun rngFun, void* rngFunArg, vlong **ppVlongQueue, ubyte4 keyType);
955 
983 MOC_EXTERN MSTATUS
984 CRYPTO_INTERFACE_RSA_decrypt(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey,
985  const ubyte* cipherText, ubyte* plainText, ubyte4* plainTextLen,
986  RNGFun rngFun, void* rngFunArg, vlong **ppVlongQueue, ubyte4 keyType);
987 
988 #if (defined(__ENABLE_MOCANA_ECC__))
989 
1000 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_deleteKey (
1001  void **ppKey,
1002  ubyte4 keyType
1003  );
1004 
1017 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_cloneKey (
1018  MOC_ECC(hwAccelDescr hwAccelCtx)
1019  void **ppNew,
1020  void *pSrc,
1021  ubyte4 keyType
1022  );
1023 
1036 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_getCurveIdFromKey (
1037  void *pKey,
1038  ubyte4 *pCurveId,
1039  ubyte4 keyType
1040  );
1041 
1056  void *pKey,
1057  ubyte4 *pLen,
1058  ubyte4 keyType
1059  );
1060 
1074  void *pKey,
1075  ubyte4 *pLen,
1076  ubyte4 keyType
1077  );
1078 
1094 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_setKeyParameters (
1095  MOC_ECC(hwAccelDescr hwAccelCtx)
1096  void *pKey,
1097  const ubyte *pPoint,
1098  ubyte4 pointLen,
1099  const ubyte *pScalar,
1100  ubyte4 scalarLen,
1101  ubyte4 keyType
1102  );
1103 
1126 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_writePublicKeyToBuffer (
1127  MOC_ECC(hwAccelDescr hwAccelCtx)
1128  void *pKey,
1129  ubyte *pBuffer,
1130  ubyte4 bufferSize,
1131  ubyte4 keyType
1132  );
1133 
1155  MOC_ECC(hwAccelDescr hwAccelCtx)
1156  void *pKey,
1157  ubyte **ppBuffer,
1158  ubyte4 *pBufferSize,
1159  ubyte4 keyType
1160  );
1161 
1186  MOC_ECC(hwAccelDescr hwAccelCtx)
1187  ubyte4 curveId,
1188  void **ppNewKey,
1189  ubyte *pByteString,
1190  ubyte4 byteStringLen,
1191  ubyte4 keyType
1192  );
1193 
1219 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_getKeyParametersAlloc (
1220  MOC_ECC(hwAccelDescr hwAccelCtx)
1221  void *pKey,
1222  MEccKeyTemplate *pTemplate,
1223  ubyte reqType,
1224  ubyte4 keyType
1225  );
1226 
1239 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_freeKeyTemplate (
1240  void *pKey,
1241  MEccKeyTemplate *pTemplate,
1242  ubyte4 keyType
1243  );
1244 
1262 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_verifyPublicKey(
1263  MOC_ECC(hwAccelDescr hwAccelCtx)
1264  void *pKey,
1265  byteBoolean *pIsValid,
1266  ubyte4 keyType
1267  );
1268 
1302 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_signDigest (
1303  MOC_ECC(hwAccelDescr hwAccelCtx)
1304  void *pKey,
1305  RNGFun rngFun,
1306  void* rngArg,
1307  ubyte *pHash,
1308  ubyte4 hashLen,
1309  ubyte *pSignature,
1310  ubyte4 bufferSize,
1311  ubyte4 *pSignatureLen,
1312  ubyte4 keyType
1313  );
1314 
1355 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_signMessage (
1356  void *pKey,
1357  RNGFun rngFun,
1358  void* rngArg,
1359  ubyte *pMessage,
1360  ubyte4 messageLen,
1361  ubyte *pSignature,
1362  ubyte4 bufferSize,
1363  ubyte4 *pSignatureLen,
1364  ubyte4 keyType
1365  );
1366 
1397  MOC_ECC(hwAccelDescr hwAccelCtx)
1398  void *pPublicKey,
1399  ubyte *pHash,
1400  ubyte4 hashLen,
1401  ubyte *pR,
1402  ubyte4 rLen,
1403  ubyte *pS,
1404  ubyte4 sLen,
1405  ubyte4 *pVerifyFailures,
1406  ubyte4 keyType
1407  );
1408 
1433  MOC_ECC(hwAccelDescr hwAccelCtx)
1434  void *pPrivateKey,
1435  void *pPublicKey,
1436  ubyte **ppSharedSecret,
1437  ubyte4 *pSharedSecretLen,
1438  sbyte4 flag,
1439  void *pKdfInfo,
1440  ubyte4 keyType
1441  );
1442 
1470  MOC_ECC(hwAccelDescr hwAccelCtx)
1471  void *pPrivateKey,
1472  ubyte *pPublicPointByteString,
1473  ubyte4 pointByteStringLen,
1474  ubyte **ppSharedSecret,
1475  ubyte4 *pSharedSecretLen,
1476  sbyte4 flag,
1477  void *pKdfInfo,
1478  ubyte4 keyType
1479  );
1480 
1481 #endif /* ifdef __ENABLE_MOCANA_ECC__ */
1482 
1494 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_cloneHashCtx (
1495  MOC_HASH(hwAccelDescr hwAccelCtx)
1496  BulkCtx pSrc,
1497  BulkCtx pDest,
1498  ubyte4 size
1499  );
1500 
1512 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_freeCloneHashCtx (
1513  BulkCtx pCtx
1514  );
1515 
1516 
1517 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_createKeyMaterial (
1518  RNGFun rngFun,
1519  void *rngArg,
1520  void **ppKeyMaterial,
1521  ubyte4 *pKeyMaterialLen,
1522  ubyte4 keyType,
1523  void *pKeyAttributes
1524  );
1525 
1526 
1527 #endif /* #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE__ */
1528 
1529 #ifdef __cplusplus
1530 }
1531 #endif
1532 
1533 #endif /* __CRYPTOINTERFACE_HEADER__ */
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_deleteKey(void **ppKey, ubyte4 keyType)
Free an ECC Key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_writePublicKeyToBufferAlloc(MOC_ECC(hwAccelDescr hwAccelCtx) void *pKey, ubyte **ppBuffer, ubyte4 *pBufferSize, ubyte4 keyType)
Allocate a new buffer and write the public point (X,Y) to it.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_verifyPublicKey(MOC_ECC(hwAccelDescr hwAccelCtx) void *pKey, byteBoolean *pIsValid, ubyte4 keyType)
Verify the public portion of an EC key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_getECCPublicKey(AsymmetricKey *pKey, ECCKey **ppPub)
Get the ECC Public key from the Asymmetric key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_signEx(void *pECCKey, RNGFun rngFun, void *rngArg, const ubyte *pPlainText, ubyte4 plainTextLen, PFEPtr r, PFEPtr s, ubyte4 keyType)
Creates ECDSA signature.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_freeKeyTemplate(void *pKey, MRsaKeyTemplate *pTemplate, ubyte4 keyType)
Free the RSA key template.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_freeKey(void **ppKey, vlong **ppVlongQueue, ubyte4 keyType)
Free an RSA key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_TAP_asymGetTapObjectId(AsymmetricKey *pKey, ubyte **ppId, ubyte4 *pIdLen)
Get the TAP ID from an Asymmetric key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_verifySignature(void *pECCKey, const ubyte *hash, ubyte4 hashLen, ConstPFEPtr r, ConstPFEPtr s, ubyte4 keyType)
Verifies ECDSA signature.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDH_generateSharedSecretFromKeys(MOC_ECC(hwAccelDescr hwAccelCtx) void *pPrivateKey, void *pPublicKey, ubyte **ppSharedSecret, ubyte4 *pSharedSecretLen, sbyte4 flag, void *pKdfInfo, ubyte4 keyType)
Generate an ECDH shared secret from a public and private key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_setKeyParameters(MOC_ECC(hwAccelDescr hwAccelCtx) void *pKey, const ubyte *pPoint, ubyte4 pointLen, const ubyte *pScalar, ubyte4 scalarLen, ubyte4 keyType)
Set the individual components of an ECC key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_getElementByteStringLen(void *pKey, ubyte4 *pLen, ubyte4 keyType)
Get the length of an individual prime field element when represented as a bytestring.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_signMessage(void *pKey, RNGFun rngFun, void *rngArg, ubyte *pMessage, ubyte4 messageLen, ubyte *pSignature, ubyte4 bufferSize, ubyte4 *pSignatureLen, ubyte4 keyType)
Perform an ECDSA signing operation on the provided message, producing the raw signature value...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_signMessageEx(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey, const ubyte *plainText, ubyte4 plainTextLen, ubyte *cipherText, vlong **ppVlongQueue, ubyte4 keyType)
Creates RSA Signature of the given input buffer.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_freeKeyTemplate(void *pKey, MEccKeyTemplate *pTemplate, ubyte4 keyType)
Frees the key data stored within the provided template structure.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_sign(void *pECCKey, RNGFun rngFun, void *rngArg, const ubyte *hash, ubyte4 hashLen, PFEPtr r, PFEPtr s, ubyte4 keyType)
Creates ECDSA signature.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDH_generateSharedSecretFromPublicByteString(MOC_ECC(hwAccelDescr hwAccelCtx) void *pPrivateKey, ubyte *pPublicPointByteString, ubyte4 pointByteStringLen, ubyte **ppSharedSecret, ubyte4 *pSharedSecretLen, sbyte4 flag, void *pKdfInfo, ubyte4 keyType)
Generate an ECDH shared secret from private key and bytestring representation of the public point...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_asymmetricKeyRemoveCreds(AsymmetricKey *pKey)
Remove credentials from a TAP key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_cloneHashCtx(MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx pSrc, BulkCtx pDest, ubyte4 size)
Clone a hash object.
MSTATUS(* pFuncPtrGetTapContext)(TAP_Context **ppTapCtx, TAP_EntityCredentialList **ppTapEntityCred, TAP_CredentialList **ppTapKeyCred, void *pKey, TapOperation op, ubyte getContext)
Function pointer to get the TAPContext.
Definition: cryptointerface.h:95
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_writePublicKeyToBuffer(MOC_ECC(hwAccelDescr hwAccelCtx) void *pKey, ubyte *pBuffer, ubyte4 bufferSize, ubyte4 keyType)
Write the public point (X,Y) to a buffer.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_TAP_AsymGetKeyInfo(AsymmetricKey *pKey, ubyte4 keyType, TAP_TokenHandle *pTokenHandle, TAP_KeyHandle *pKeyHandle)
Gets the key handle and token handle for an internal TAP key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_getPublicKey(AsymmetricKey *pKey, AsymmetricKey *pPubKey)
Get the Asymmetric Public key from the Asymmetric key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_registerTapCtxCallback(void *pCallback)
Function pointer to set the callback which can return tapcontext.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_getTapKey(RSAKey *pRsaKey, TAP_Key **ppTapKey)
Get the TAP key from an RSA key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_getRSAPublicKey(AsymmetricKey *pKey, RSAKey **ppPub)
Get the RSA Public key from the Asymmetric key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_unloadTapToken(TAP_Context *pTapCtx, TAP_TokenHandle tokenHandle)
Uninitialize the token.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_asymmetricKeyAddCreds(AsymmetricKey *pKey, sbyte *pPassword, sbyte4 passwordLen)
Add credentials to a TAP key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_applyPublicKey(MOC_RSA(hwAccelDescr hwAccelCtx) void *pKey, ubyte *pInput, ubyte4 inputLen, ubyte **ppOutput, vlong **ppVlongQueue, ubyte4 keyType)
Apply the public key to the input data.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_setPublicKeyParameters(MOC_RSA(hwAccelDescr hwAccelCtx) void *pKey, ubyte4 exponent, const ubyte *pModulus, ubyte4 modulusLen, vlong **ppVlongQueue, ubyte4 keyType)
Set the public parameters of an RSA key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_getKeyParametersAlloc(MOC_RSA(hwAccelDescr hwAccelCtx) void *pKey, MRsaKeyTemplate *pTemplate, ubyte reqType, ubyte4 keyType)
Allocates and sets the appropriate key parameters of pTemplate with the data in the key...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_cloneKey(MOC_ECC(hwAccelDescr hwAccelCtx) void **ppNew, void *pSrc, ubyte4 keyType)
Clone an ECC Key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_freeCloneHashCtx(BulkCtx pCtx)
Free a previously cloned hash object.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_getKeyUsage(void *pKey, ubyte4 keyType, ubyte *pKeyUsage)
This function returns the keyusage value based on the keytype.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_TAP_AsymDeferUnload(AsymmetricKey *pKey, byteBoolean deferredTokenUnload)
Marks an Asymmetric Key containing a TAP key to not be unloaded when done with its cipher operations...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_getRsaSwPubFromTapKey(RSAKey *pKey, RSAKey **ppPub)
Get the RSA Public key from a RSA TAP key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_setAllKeyData(MOC_RSA(hwAccelDescr hwAccelCtx) void *pKey, ubyte *pPubExpo, ubyte4 pubExpoLen, const ubyte *pModulus, ubyte4 modulusLen, const ubyte *pPrime, ubyte4 primeLen, const ubyte *pSubprime, ubyte4 subprimeLen, vlong **ppVlongQueue, ubyte4 keyType)
Set all the parameters in a RSA key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_signMessage(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey, const ubyte *plainText, ubyte4 plainTextLen, ubyte *cipherText, vlong **ppVlongQueue, ubyte4 keyType)
Creates RSA Signature of the given input buffer.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECC_getTapKey(ECCKey *pEccKey, TAP_Key **ppTapKey)
Get the TAP key from an ECC key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_getKeyParametersAlloc(MOC_ECC(hwAccelDescr hwAccelCtx) void *pKey, MEccKeyTemplate *pTemplate, ubyte reqType, ubyte4 keyType)
Allocates and sets the appropriate keys parameters of pTemplate with that from the passed in pKey...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_signDigest(MOC_ECC(hwAccelDescr hwAccelCtx) void *pKey, RNGFun rngFun, void *rngArg, ubyte *pHash, ubyte4 hashLen, ubyte *pSignature, ubyte4 bufferSize, ubyte4 *pSignatureLen, ubyte4 keyType)
Perform an ECDSA signing operation on the provided digest, producing the raw signature value...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_getCurveIdFromKey(void *pKey, ubyte4 *pCurveId, ubyte4 keyType)
Retrieve the curve identifier from a key previously created with EC_newKeyEx or generated with EC_gen...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ECDSA_verifySignatureDigest(MOC_ECC(hwAccelDescr hwAccelCtx) void *pPublicKey, ubyte *pHash, ubyte4 hashLen, ubyte *pR, ubyte4 rLen, ubyte *pS, ubyte4 sLen, ubyte4 *pVerifyFailures, ubyte4 keyType)
Verify individual signature values with the provided public key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_applyPrivateKey(MOC_RSA(hwAccelDescr hwAccelCtx) void *pKey, RNGFun rngFun, void *pRngFunArg, ubyte *pInput, ubyte4 inputLen, ubyte **ppOutput, vlong **ppVlongQueue, ubyte4 keyType)
Apply the private key to the input data.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_decrypt(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey, const ubyte *cipherText, ubyte *plainText, ubyte4 *plainTextLen, RNGFun rngFun, void *rngFunArg, vlong **ppVlongQueue, ubyte4 keyType)
Decrypts the given cipher text using RSA decryption.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_getTapKey(AsymmetricKey *pKey, TAP_Key **ppTapKey)
Get the TAP key within the Asymmetric key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_encrypt(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey, const ubyte *plainText, ubyte4 plainTextLen, ubyte *cipherText, RNGFun rngFun, void *rngFunArg, vlong **ppVlongQueue, ubyte4 keyType)
Creates RSA encryption.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_RSA_verifySignature(MOC_RSA(hwAccelDescr hwAccelCtx) void *pRSAKey, const ubyte *cipherText, ubyte *plainText, ubyte4 *plainTextLen, vlong **ppVlongQueue, ubyte4 keyType)
Verify the RSA signature against the given input ciphertext and the plain buffer. ...
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_newPublicKeyFromByteString(MOC_ECC(hwAccelDescr hwAccelCtx) ubyte4 curveId, void **ppNewKey, ubyte *pByteString, ubyte4 byteStringLen, ubyte4 keyType)
Create a new ECC public key from the bytestring representation of public point (X,Y).
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_unloadTapKey(TAP_Context *pTapCtx, TAP_TokenHandle tokenHandle, TAP_KeyHandle keyHandle)
Unload the key for a no longer needed TAP key.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_retrieveFingerPrintInfo_TAPSeed(FingerprintElement **ppElements, ubyte4 *pNumElements, ubyte **ppInitialSeed, ubyte4 *pInitialSeedLen, ubyte8 ek_obj_id)
Function to get the finger print from a tap device.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_EC_getPointByteStringLenEx(void *pKey, ubyte4 *pLen, ubyte4 keyType)
Get the length of the bytestring representation of the public key, typically used to determine the bu...