18 #ifndef __PUBCRYPTO_HEADER__ 19 #define __PUBCRYPTO_HEADER__ 21 #include "../cap/capasym.h" 22 #include "../crypto/cryptodecl.h" 24 #ifdef __ENABLE_MOCANA_QS__ 25 #include "../crypto_interface/crypto_interface_qs.h" 32 #if (defined(__ENABLE_MOCANA_ECC__)) 34 struct PrimeEllipticCurve;
39 #if (defined(__ENABLE_MOCANA_DSA__)) 46 typedef struct AsymmetricKey
52 #if (defined(__ENABLE_MOCANA_ECC__)) 55 #if (defined(__ENABLE_MOCANA_DSA__)) 58 struct MocAsymmetricKey *pMocAsymKey;
61 struct MAlgoId *pAlgoId;
63 #ifdef __ENABLE_MOCANA_QS__ 70 typedef struct HybridKey
122 #if (defined(__ENABLE_MOCANA_ECC__)) 173 const ubyte* modulus,
179 struct vlong **ppVlongQueue);
181 #if (defined(__ENABLE_MOCANA_ECC__)) 202 PEllipticCurvePtr pEC
205 #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE__ 252 #ifdef __ENABLE_MOCANA_QS__ 286 #if (defined(__ENABLE_MOCANA_DSA__)) 347 struct vlong **ppVlongQueue);
433 AsymmetricKey *pAsymKey,
438 MOC_EXTERN MSTATUS CRYPTO_loadAlgoId (
439 AsymmetricKey *pAsymKey,
458 AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
466 AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
474 AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
482 AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
489 MOC_EXTERN MSTATUS
KeySerializeQs (AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
496 MOC_EXTERN MSTATUS
KeySerializeHybrid (AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
498 MOC_EXTERN MSTATUS KeySerializeTpmRsa (
499 AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *);
563 MOC_ASYM(hwAccelDescr hwAccelCtx)
564 AsymmetricKey *pKeyToSerialize,
566 ubyte4 supportedAlgorithmCount,
567 serializedKeyFormat format,
568 ubyte **ppSerializedKey,
569 ubyte4 *pSerializedKeyLen
633 MOC_ASYM(hwAccelDescr hwAccelCtx)
634 ubyte *pSerializedKey,
635 ubyte4 serializedKeyLen,
637 ubyte4 supportedAlgorithmCount,
638 AsymmetricKey *pDeserializedKey
672 MOC_ASYM(hwAccelDescr hwAccelCtx)
673 AsymmetricKey *pKeyToSerialize,
674 serializedKeyFormat format,
675 ubyte **ppSerializedKey,
676 ubyte4 *pSerializedKeyLen
725 MOC_ASYM(hwAccelDescr hwAccelCtx)
726 AsymmetricKey *pKeyToSerialize,
727 serializedKeyFormat format,
731 ubyte **ppSerializedKey,
732 ubyte4 *pSerializedKeyLen
756 MOC_ASYM(hwAccelDescr hwAccelCtx)
757 ubyte *pSerializedKey,
758 ubyte4 serializedKeyLen,
760 AsymmetricKey *pDeserializedKey
789 MOC_ASYM(hwAccelDescr hwAccelCtx)
790 ubyte *pSerializedKey,
791 ubyte4 serializedKeyLen,
796 AsymmetricKey *pDeserializedKey
806 intBoolean isPrivateKey,
861 intBoolean *isPrivate
915 typedef MSTATUS (*MKeyContextCallback) (
916 AsymmetricKey *pAsymKey,
928 MKeyContextCallback KeyContextCallback;
930 } MKeyContextCallbackInfo;
941 #include "../crypto/mocasym.h" MOC_EXTERN MSTATUS CRYPTO_setECCParameters(MOC_ECC(hwAccelDescr hwAccelCtx) AsymmetricKey *pKey, ubyte4 curveId, const ubyte *point, ubyte4 pointLen, const ubyte *scalar, ubyte4 scalarLen)
Populate a caller allocated AsymmetricKey structure with the provided ECC key data.
MOC_EXTERN MSTATUS CRYPTO_makeKeyInfo(intBoolean isPrivateKey, ubyte *pAlgId, ubyte4 algIdLen, ubyte *pKeyData, ubyte4 keyDataLen, ubyte **ppKeyInfo, ubyte4 *pKeyInfoLen)
Build SubjectPublicKeyInfo or PrivateKeyInfo.
MOC_EXTERN MSTATUS CRYPTO_serializeKey(MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey *pKeyToSerialize, MKeySerialize *pSupportedAlgorithms, ubyte4 supportedAlgorithmCount, serializedKeyFormat format, ubyte **ppSerializedKey, ubyte4 *pSerializedKeyLen)
Serialize an asymmetric key.
MOC_EXTERN MSTATUS CRYPTO_serializeAsymKeyToStorage(MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey *pKeyToSerialize, serializedKeyFormat format, ubyte *pId, ubyte4 idLen, ubyte4 tokenId, ubyte **ppSerializedKey, ubyte4 *pSerializedKeyLen)
Serialize an asymmetric key to secure storage with a given token and identifier.
MOC_EXTERN MSTATUS CRYPTO_setHybridParameters(AsymmetricKey *pKey, ubyte4 curveId, ubyte4 qsAlgId, ubyte *pPubKey, ubyte4 pubKeyLen)
Populate a caller allocated AsymmetricKey structure with the provided hybrid public key data...
MOC_EXTERN MSTATUS CRYPTO_setRSAParameters(MOC_RSA(hwAccelDescr hwAccelCtx) AsymmetricKey *pKey, ubyte4 exponent, const ubyte *modulus, ubyte4 modulusLen, const ubyte *p, ubyte4 pLen, const ubyte *q, ubyte4 qLen, struct vlong **ppVlongQueue)
Populate an existing AsymmetricKey structure with the provided RSA key data.
MOC_EXTERN MSTATUS CRYPTO_deserializeAsymKey(MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte *pSerializedKey, ubyte4 serializedKeyLen, MocCtx pMocCtx, AsymmetricKey *pDeserializedKey)
Deserialize a key, building an AsymmetricKey from the byte array that is the key data.
MOC_EXTERN MSTATUS KeySerializeEcc(MOC_ASYM(hwAccelDescr) AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *)
This is an implementation of MKeySerialize.
MOC_EXTERN MSTATUS CRYPTO_createDSAKey(AsymmetricKey *pKey, struct vlong **ppVlongQueue)
Populate an existing AsymmetricKey structure with a new DSA key.
MOC_EXTERN MSTATUS CRYPTO_deserializeAsymKeyWithCreds(MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte *pSerializedKey, ubyte4 serializedKeyLen, MocCtx pMocCtx, ubyte *pPassword, ubyte4 passwordLen, void *pLoadCtx, AsymmetricKey *pDeserializedKey)
Deserialize a key, building an AsymmetricKey from the byte array that is the key data.
MSTATUS(* MKeySerialize)(MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *)
This is what an MKeySerialize really is.
Definition: pubcrypto.h:457
MOC_EXTERN MSTATUS CRYPTO_initAsymmetricKey(AsymmetricKey *pKey)
Initialize a caller allocated AsymmetricKey.
MOC_EXTERN MSTATUS CRYPTO_matchPublicKey(const AsymmetricKey *pKey1, const AsymmetricKey *pKey2)
Determine if two AsymmetricKey structures contain the same key values.
MOC_EXTERN MSTATUS CRYPTO_loadAsymmetricKey(AsymmetricKey *pAsymKey, ubyte4 keyType, void **ppAlgKey)
Load the AlgKey into the AsymKey, transferring ownership to the AsymKey.
MOC_EXTERN MSTATUS CRYPTO_getKeyTapInfo(ubyte *pKey, ubyte4 keyLen, MocCtx pMocCtx, byteBoolean *pIsTap, ubyte4 *pProvider, ubyte4 *pModuleId)
Checks a serialized key to see if it is a tradition TAP key or Secure Storage key and outputs the pro...
MOC_EXTERN MSTATUS KeySerializeRsa(MOC_ASYM(hwAccelDescr) AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *)
This is an implementation of MKeySerialize.
MOC_EXTERN MSTATUS CRYPTO_findKeyInfoComponents(ubyte *pKeyInfo, ubyte4 keyInfoLen, ubyte **ppAlgId, ubyte4 *pAlgIdLen, ubyte **ppKeyData, ubyte4 *pKeyDataLen, intBoolean *isPrivate)
Find the algorithm identifier and the actual key info in the KeyInfo.
MOC_EXTERN MSTATUS KeySerializeDsa(MOC_ASYM(hwAccelDescr) AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *)
This is an implementation of MKeySerialize.
MOC_EXTERN MSTATUS CRYPTO_createECCKeyEx(AsymmetricKey *pKey, ubyte4 eccCurveId)
Populate a caller allocated AsymmetricKey structure with a new empty ECC key.
MOC_EXTERN MSTATUS CRYPTO_createRSAKey(AsymmetricKey *pKey, struct vlong **ppVlongQueue)
Populate an existing AsymmetricKey structure with a new RSA key.
MOC_EXTERN MSTATUS CRYPTO_setDSAParameters(MOC_DSA(hwAccelDescr hwAccelCtx) AsymmetricKey *pKey, const ubyte *p, ubyte4 pLen, const ubyte *q, ubyte4 qLen, const ubyte *g, ubyte4 gLen, const ubyte *y, ubyte4 yLen, const ubyte *x, ubyte4 xLen, struct vlong **ppVlongQueue)
Populate an existing AsymmetricKey structure with a new DSA key and sets all of the DSA key parameter...
MOC_EXTERN MSTATUS CRYPTO_deserializeKey(MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte *pSerializedKey, ubyte4 serializedKeyLen, MKeySerialize *pSupportedAlgorithms, ubyte4 supportedAlgorithmCount, AsymmetricKey *pDeserializedKey)
Deserialize a key, building an AsymmetricKey from the byte array that is the key data.
MOC_EXTERN MSTATUS KeySerializeHybrid(AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *)
This is an implementation of MKeySerialize.
MOC_EXTERN MSTATUS CRYPTO_serializeAsymKey(MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey *pKeyToSerialize, serializedKeyFormat format, ubyte **ppSerializedKey, ubyte4 *pSerializedKeyLen)
Serialize an asymmetric key.
MOC_EXTERN MSTATUS KeySerializeQs(AsymmetricKey *, serializedKeyFormat, ubyte **, ubyte4 *)
This is an implementation of MKeySerialize.
MOC_EXTERN ubyte4 CRYPTO_getECCurveId(const AsymmetricKey *pKey)
Get the ECC curveId from an AsymmetricKey.
MOC_EXTERN MSTATUS CRYPTO_createECCKey(AsymmetricKey *pKey, PEllipticCurvePtr pEC)
Populate a caller allocated AsymmetricKey structure with a new empty ECC key.
MOC_EXTERN MSTATUS CRYPTO_uninitAsymmetricKey(AsymmetricKey *pKey, struct vlong **ppVlongQueue)
Uninitialize an AsymmetricKey.
MOC_EXTERN MSTATUS CRYPTO_copyAsymmetricKey(AsymmetricKey *pNew, const AsymmetricKey *pSrc)
Copy the contents an AsymmetricKey to another caller allocated AsymmetricKey.