27 #ifndef __CRYPTOINTERFACE_HEADER__ 28 #define __CRYPTOINTERFACE_HEADER__ 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" 40 #if defined(__ENABLE_MOCANA_TAP__) 41 #include "../tap/tap.h" 42 #include "../tap/tap_smp.h" 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" 50 #if defined(__ENABLE_MOCANA_ECC__) 51 #include "../crypto_interface/crypto_interface_ecc.h" 54 #if defined(__ENABLE_MOCANA_TAP__) 55 #include "../data_protection/tap_data_protect.h" 64 #if defined(__ENABLE_MOCANA_CRYPTO_INTERFACE__) 65 #if defined(__ENABLE_MOCANA_TAP__) 67 #if defined(__ENABLE_MOCANA_TAP_EXTERN__) 68 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_TAPExternInit();
96 TAP_EntityCredentialList **ppTapEntityCred,
97 TAP_CredentialList **ppTapKeyCred,
98 void *pKey, TapOperation op, ubyte getContext);
129 FingerprintElement **ppElements,
130 ubyte4 *pNumElements,
131 ubyte **ppInitialSeed,
132 ubyte4 *pInitialSeedLen,
160 CRYPTO_INTERFACE_getKeyType(
void *pKey, ubyte4 *keyType);
186 CRYPTO_WRAPPER_getRSATAPKeySize(
void *pKey, ubyte4 *keySize);
189 CRYPTO_INTERFACE_getRSACipherTextLength(MOC_RSA(hwAccelDescr hwAccelCtx)
void *pKey, sbyte4 *pModulusLen, ubyte4 keyType);
192 CRYPTO_INTERFACE_copyAsymmetricKey(AsymmetricKey *pNew,
const AsymmetricKey *pSrc);
217 #ifdef __ENABLE_MOCANA_ECC__ 222 CRYPTO_INTERFACE_getECurve(
void *pKey, PEllipticCurvePtr *ppECurve, ubyte4 keyType);
225 #if (defined(__ENABLE_MOCANA_ECC__)) 294 #if defined(__ENABLE_MOCANA_TAP__) 322 AsymmetricKey *pKey);
341 CRYPTO_INTERFACE_TAP_rsaDeferUnloadMocAsym(MocAsymKey pKey, byteBoolean deferredTokenUnload);
343 #if defined(__ENABLE_MOCANA_ECC__) 348 CRYPTO_INTERFACE_TAP_eccDeferUnloadMocAsym(MocAsymKey pKey, byteBoolean deferredTokenUnload);
373 CRYPTO_INTERFACE_TAP_rsaGetKeyInfoMocAsym(MocAsymKey pKey, TAP_TokenHandle *pTokenHandle, TAP_KeyHandle *pKeyHandle);
375 #if defined(__ENABLE_MOCANA_ECC__) 381 CRYPTO_INTERFACE_TAP_eccGetKeyInfoMocAsym(MocAsymKey pKey, TAP_TokenHandle *pTokenHandle, TAP_KeyHandle *pKeyHandle);
504 #if (defined(__ENABLE_MOCANA_ECC__)) 507 CRYPTO_INTERFACE_TAP_eccGetKeyInfo(ECCKey *pECCKey, ubyte4 keyType,
508 TAP_TokenHandle *pTokenHandle,
509 TAP_KeyHandle *pKeyHandle);
565 const ubyte* plainText, ubyte4 plainTextLen,
566 ubyte* cipherText, vlong **ppVlongQueue, ubyte4 keyType);
601 const ubyte* plainText, ubyte4 plainTextLen,
602 ubyte* cipherText, vlong **ppVlongQueue, ubyte4 keyType);
632 const ubyte* cipherText, ubyte* plainText, ubyte4* plainTextLen, vlong **ppVlongQueue, ubyte4 keyType);
634 #if (defined(__ENABLE_MOCANA_ECC__)) 667 const ubyte* hash, ubyte4 hashLen,
668 PFEPtr r, PFEPtr s, ubyte4 keyType);
702 const ubyte* pPlainText, ubyte4 plainTextLen,
703 PFEPtr r, PFEPtr s, ubyte4 keyType);
737 ConstPFEPtr r, ConstPFEPtr s, ubyte4 keyType);
752 vlong **ppVlongQueue,
771 MOC_RSA(hwAccelDescr hwAccelCtx)
774 const ubyte *pModulus,
776 vlong **ppVlongQueue,
800 MOC_RSA(hwAccelDescr hwAccelCtx)
804 const ubyte *pModulus,
808 const ubyte *pSubprime,
810 vlong **ppVlongQueue,
839 MOC_RSA(hwAccelDescr hwAccelCtx)
841 MRsaKeyTemplate *pTemplate,
859 MRsaKeyTemplate *pTemplate,
882 MOC_RSA(hwAccelDescr hwAccelCtx)
887 vlong **ppVlongQueue,
913 MOC_RSA(hwAccelDescr hwAccelCtx)
920 vlong **ppVlongQueue,
953 const ubyte* plainText, ubyte4 plainTextLen, ubyte* cipherText,
954 RNGFun rngFun,
void* rngFunArg, vlong **ppVlongQueue, ubyte4 keyType);
985 const ubyte* cipherText, ubyte* plainText, ubyte4* plainTextLen,
986 RNGFun rngFun,
void* rngFunArg, vlong **ppVlongQueue, ubyte4 keyType);
988 #if (defined(__ENABLE_MOCANA_ECC__)) 1018 MOC_ECC(hwAccelDescr hwAccelCtx)
1095 MOC_ECC(hwAccelDescr hwAccelCtx)
1097 const ubyte *pPoint,
1099 const ubyte *pScalar,
1127 MOC_ECC(hwAccelDescr hwAccelCtx)
1155 MOC_ECC(hwAccelDescr hwAccelCtx)
1158 ubyte4 *pBufferSize,
1186 MOC_ECC(hwAccelDescr hwAccelCtx)
1190 ubyte4 byteStringLen,
1220 MOC_ECC(hwAccelDescr hwAccelCtx)
1222 MEccKeyTemplate *pTemplate,
1241 MEccKeyTemplate *pTemplate,
1263 MOC_ECC(hwAccelDescr hwAccelCtx)
1265 byteBoolean *pIsValid,
1303 MOC_ECC(hwAccelDescr hwAccelCtx)
1311 ubyte4 *pSignatureLen,
1363 ubyte4 *pSignatureLen,
1397 MOC_ECC(hwAccelDescr hwAccelCtx)
1405 ubyte4 *pVerifyFailures,
1433 MOC_ECC(hwAccelDescr hwAccelCtx)
1436 ubyte **ppSharedSecret,
1437 ubyte4 *pSharedSecretLen,
1470 MOC_ECC(hwAccelDescr hwAccelCtx)
1472 ubyte *pPublicPointByteString,
1473 ubyte4 pointByteStringLen,
1474 ubyte **ppSharedSecret,
1475 ubyte4 *pSharedSecretLen,
1495 MOC_HASH(hwAccelDescr hwAccelCtx)
1517 MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_createKeyMaterial (
1520 void **ppKeyMaterial,
1521 ubyte4 *pKeyMaterialLen,
1523 void *pKeyAttributes
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...