32 #include "../common/initmocana.h" 34 #ifndef __CERT_STORE_HEADER__ 35 #define __CERT_STORE_HEADER__ 47 #ifndef MAX_SIZE_CERT_STORE_TRUST_HASH_TABLE 48 #define MAX_SIZE_CERT_STORE_TRUST_HASH_TABLE (0x1f) 52 #define CERT_STORE_ALGO_FLAG_RESERVED (0xFF000000L) 54 #define CERT_STORE_ALGO_FLAG_ECCURVES (0x00FF0000L) 56 #define CERT_STORE_ALGO_FLAG_SIGNKEYTYPE (0x0000FF00L) 58 #define CERT_STORE_ALGO_FLAG_HASHALGO (0x000000FFL) 61 #define CERT_STORE_ALGO_ID_SET_KEYTYPE( id, value) (id) |= (((value) & 0xff) << 24 ) 62 #define CERT_STORE_ALGO_ID_SET_HASH( id, value) (id) |= (((value) & 0xff) << 16 ) 63 #define CERT_STORE_ALGO_ID_SET_QSALG( id, value) (id) |= (((value) & 0xffff) << 8 ) 64 #define CERT_STORE_ALGO_ID_SET_CURVE( id, value) (id) |= ((value) & 0xff) 66 #define CERT_STORE_ALGO_ID_GET_KEYTYPE(id) ((id & 0xff000000) >> 24) 67 #define CERT_STORE_ALGO_ID_GET_HASH(id) ((id & 0x00ff0000) >> 16) 69 #define CERT_STORE_ALGO_ID_HASH_MASK (0x00ff0000L) 71 #define CERT_STORE_ALGO_ID_MASK_REMOVE_HASH_MASK (~CERT_STORE_ALGO_ID_HASH_MASK) 72 #define CERT_STORE_ALGO_ID_MASK_REMOVE_CURVE_MASK (0xffffff00L) 85 #define CERT_STORE_ALGO_FLAG_EC192 (0x00010000L) 92 #define CERT_STORE_ALGO_FLAG_EC224 (0x00020000L) 99 #define CERT_STORE_ALGO_FLAG_EC256 (0x00040000L) 106 #define CERT_STORE_ALGO_FLAG_EC384 (0x00080000L) 113 #define CERT_STORE_ALGO_FLAG_EC521 (0x00100000L) 114 #define CERT_STORE_ALGO_FLAG_EC25519 (0x00200000L) 115 #define CERT_STORE_ALGO_FLAG_EC448 (0x00400000L) 124 #define CERT_STORE_ALGO_FLAG_RSA (0x00000100L) 131 #define CERT_STORE_ALGO_FLAG_ECDSA (0x00000200L) 138 #define CERT_STORE_ALGO_FLAG_DSA (0x00000400L) 139 #define CERT_STORE_ALGO_FLAG_EDDSA_25519 (0x00000800L) 140 #define CERT_STORE_ALGO_FLAG_EDDSA_448 (0x00001000L) 141 #define CERT_STORE_ALGO_FLAG_HYBRID (0x00002000L) 150 #define CERT_STORE_ALGO_FLAG_MD5 (0x00000001L) 157 #define CERT_STORE_ALGO_FLAG_SHA1 (0x00000002L) 165 #define CERT_STORE_ALGO_FLAG_SHA224 (0x00000004L) 173 #define CERT_STORE_ALGO_FLAG_SHA256 (0x00000008L) 181 #define CERT_STORE_ALGO_FLAG_SHA384 (0x00000010L) 189 #define CERT_STORE_ALGO_FLAG_SHA512 (0x00000020L) 190 #define CERT_STORE_ALGO_FLAG_INTRINSIC (0x00000040L) 201 CERT_STORE_AUTH_TYPE_RSA = 0,
202 CERT_STORE_AUTH_TYPE_ECDSA = 1,
203 CERT_STORE_AUTH_TYPE_DSA = 2,
204 CERT_STORE_AUTH_TYPE_RSA_PSS = 3,
205 CERT_STORE_AUTH_TYPE_EDDSA = 4,
206 CERT_STORE_AUTH_TYPE_HYBRID = 5,
207 CERT_STORE_AUTH_TYPE_ARRAY_SIZE = 6
220 CERT_STORE_IDENTITY_TYPE_NAKED = 0,
221 CERT_STORE_IDENTITY_TYPE_CERT_X509_V3 = 1,
222 CERT_STORE_IDENTITY_TYPE_ARRAY_SIZE = 2
227 struct AsymmetricKey;
231 typedef struct certStore* certStorePtr;
233 #if defined(__ENABLE_MOCANA_MINIMAL_CA__) 234 struct certStoreIssuer;
235 typedef struct certStoreIssuer* certStoreIssuerPtr;
238 typedef sbyte4 (*ExtendedDataCallback)(sbyte4 extDataIdentifier,
enum dataType *pType,
enum dataEncoding *pFormat,
239 sbyte **ppBuffer, sbyte4 *pBufferLen);
261 certStorePtr *ppNewStore
280 certStorePtr *ppReleaseStore
292 MOC_EXTERN MSTATUS CERT_STORE_loadMocCtx (
293 certStorePtr pCertStore,
298 MOC_EXTERN MSTATUS CERT_STORE_convertCertStoreKeyTypeToPubKeyType(ubyte4 certStoreKeyType, ubyte4 *pRetPubKeyType);
305 #ifndef __DISABLE_MOCANA_CERTIFICATE_PARSING__ 338 certStorePtr pCertStore,
339 const ubyte *pDerCert,
340 ubyte4 derCertLength,
341 const ubyte *pKeyBlob,
384 certStorePtr pCertStore,
388 ubyte4 derCertLength,
422 certStorePtr pCertStore,
423 struct SizedBuffer *certificates,
424 ubyte4 numCertificate,
425 const ubyte *pKeyBlob,
459 struct SizedBuffer *certificates,
460 ubyte4 numCertificate,
461 const ubyte *pKeyBlob,
462 ubyte4 keyBlobLength,
463 ExtendedDataCallback extDataFunc,
464 sbyte4 extDataIdentifier
496 certStorePtr pCertStore,
499 struct SizedBuffer *certificates,
500 ubyte4 numCertificate,
501 const ubyte *pKeyBlob,
502 ubyte4 keyBlobLength,
503 ExtendedDataCallback extDataFunc,
504 sbyte4 extDataIdentifier
543 certStorePtr pCertStore,
546 struct SizedBuffer *certificates,
547 ubyte4 numCertificate,
548 const ubyte *pKeyBlob,
571 certStorePtr pCertStore,
572 const ubyte *pKeyBlob,
597 certStorePtr pCertStore,
631 const ubyte *pPskIdentity,
632 ubyte4 pskIdentityLength,
633 const ubyte *pPskHint,
634 ubyte4 pskHintLength,
635 const ubyte *pPskSecret,
636 ubyte4 pskSecretLength);
638 #ifndef __DISABLE_MOCANA_CERTIFICATE_PARSING__ 661 const ubyte *pDerTrustPoint,
662 ubyte4 derTrustPointLength);
664 #ifdef __ENABLE_MOCANA_CV_CERT__ 688 MOC_EXTERN MSTATUS CERT_STORE_CVC_addTrustPoint(certStorePtr pCertStore,
689 const ubyte *pTrustPoint,
690 ubyte4 trustPointLength);
723 const ubyte *subject,
724 ubyte4 subjectLength,
725 const ubyte **ppRetDerCert,
726 ubyte4 *pRetDerCertLength,
727 const void** iterator);
751 const ubyte **ppRetDerCert,
752 ubyte4* pRetDerCertLength);
778 const ubyte* testCert,
813 const certStorePtr pCertStore,
814 const ubyte* subject,
815 ubyte4 subjectLength,
818 const ubyte** ppRetDerCert,
819 ubyte4* pRetDerCertLength);
824 MOC_EXTERN MSTATUS CERT_STORE_traverseTrustPoints(MOC_ASYM(hwAccelDescr hwAccelCtx)
825 const certStorePtr pCertStore,
878 certStorePtr pCertStore,
881 struct AsymmetricKey **ppReturnIdentityKey,
882 ubyte **ppRetDerCert,
883 ubyte4 *pRetDerCertLength
946 certStorePtr pCertStore,
949 ubyte4 *pSupportedCertKeyAlgos,
950 ubyte4 supportedCertKeyAlgosLen,
951 ubyte4 *pSupportedSignAlgos,
952 ubyte4 supportedSignAlgosLen,
955 struct AsymmetricKey **ppReturnIdentityKey,
956 struct SizedBuffer **ppRetCertificates,
957 ubyte4 *pRetNumCertificates,
999 MOC_EXTERN MSTATUS CERT_STORE_findIdentityByAliasEx (
1000 certStorePtr pCertStore,
1003 struct AsymmetricKey **ppReturnIdentityKey,
1004 struct SizedBuffer **ppRetCertificates,
1005 ubyte4 *pRetNumCertificates
1008 MOC_EXTERN MSTATUS CERT_STORE_updateIdentityByAliasExtData (
1009 certStorePtr pCertStore,
1012 struct SizedBuffer *pCertChain,
1013 ubyte4 certChainCount,
1014 const ubyte *pKeyBlob,
1016 ExtendedDataCallback extDataFunc,
1017 sbyte4 extDataIdentifier
1020 MOC_EXTERN MSTATUS CERT_STORE_getIdentityPairExtData (
1022 ExtendedDataCallback *pExtDataFunc,
1023 sbyte4 *pExtDataIdentifier
1026 MOC_EXTERN MSTATUS CERT_STORE_updateIdentityByAlias (
1027 certStorePtr pCertStore,
1030 struct SizedBuffer *pCertChain,
1031 ubyte4 certChainCount,
1032 const ubyte *pKeyBlob,
1074 const struct AsymmetricKey** ppRetIdentityKey,
1075 const ubyte **ppRetDerCert,
1076 ubyte4 *pRetDerCertLength,
1111 const struct AsymmetricKey** ppRetIdentityKey,
1112 const ubyte **ppRetDerCert,
1113 ubyte4 *pRetDerCertLength,
1163 ubyte4 supportedAlgoFlags,
1164 const struct AsymmetricKey** ppRetIdentityKey,
1165 const struct SizedBuffer** ppRetCertificates,
1166 ubyte4 *pRetNumberCertificate,
1202 ubyte4 supportedKeyTypeAndAlgoFlags,
1203 const struct AsymmetricKey** ppRetIdentityKey,
1204 const struct SizedBuffer** ppRetCertificates,
1205 ubyte4 *pRetNumberCertificate,
1262 const certStorePtr pCertStore,
1265 ubyte4 *pSupportedCertKeyIds,
1266 ubyte4 supportedCertKeyIdsLen,
1267 ubyte4 *pSupportedSignAlgoIds,
1268 ubyte4 supportedSignAlgoIdsLen,
1269 const struct AsymmetricKey** ppRetIdentityKey,
1270 const struct SizedBuffer** ppRetCertificates,
1271 ubyte4 *pRetNumberCertificate,
1313 const certStorePtr pCertStore,
1316 ubyte4 *pSupportedCertKeyIds,
1317 ubyte4 supportedCertKeyIdsLen,
1318 ubyte4 *pSupportedSignAlgoIds,
1319 ubyte4 supportedSignAlgoIdsLen,
1320 const struct AsymmetricKey** ppRetIdentityKey,
1321 const struct SizedBuffer** ppRetCertificates,
1322 ubyte4 *pRetNumberCertificate,
1352 ubyte4 supportedAlgoFlags,
1353 const struct AsymmetricKey** ppRetIdentityKey,
1354 const struct SizedBuffer** ppRetCertificates,
1355 ubyte4 *pRetNumberCertificate,
1385 ubyte4 supportedKeyTypeAndAlgoFlags,
1386 const struct AsymmetricKey** ppRetIdentityKey,
1387 const struct SizedBuffer** ppRetCertificates,
1388 ubyte4 *pRetNumberCertificate,
1395 MOC_EXTERN MSTATUS CERT_STORE_traversePskListHead(
const certStorePtr pCertStore,
1396 ubyte **ppRetPskIdentity,
1397 ubyte4 *pRetPskIdentityLength,
1398 ubyte **ppRetPskHint,
1399 ubyte4 *pRetPskHintLength,
1400 ubyte **ppRetPskSecret,
1401 ubyte4 *pRetPskSecretLength,
1403 MOC_EXTERN MSTATUS CERT_STORE_traversePskListNext(
const certStorePtr pCertStore,
1404 ubyte **ppRetPskIdentity,
1405 ubyte4 *pRetPskIdentityLength,
1406 ubyte **ppRetPskHint,
1407 ubyte4 *pRetPskHintLength,
1408 ubyte **ppRetPskSecret,
1409 ubyte4 *pRetPskSecretLength,
1411 MOC_EXTERN MSTATUS CERT_STORE_findPskByIdentity(
const certStorePtr pCertStore,
1412 ubyte *pPskIdentity,
1413 ubyte4 pskIdentityLength,
1414 ubyte **ppRetPskSecret,
1415 ubyte4 *pRetPskSecretLength);
1450 const ubyte* pIssuer,
1451 ubyte4 issuerLength,
1452 const ubyte* serialNumber,
1453 ubyte4 serialNumberLength,
1454 const ubyte** ppRetDerCert,
1455 ubyte4* ppRetDerCertLength,
1456 const struct AsymmetricKey** pRetPrivateKey);
1458 #if defined(__ENABLE_MOCANA_MINIMAL_CA__) 1468 CERT_STORE_createIssuerStore(sbyte *pDirPath, certStoreIssuerPtr *pStore);
1478 CERT_STORE_releaseIssuerStore(certStoreIssuerPtr *pStore);
1488 CERT_STORE_traverseChildCertsByFile(
1489 certStoreIssuerPtr pStore,
void **ppCookie, ubyte4 *pIndex, sbyte **ppFile);
MOC_EXTERN MSTATUS CERT_STORE_addIdentityWithCertificateChainExtData(certStorePtr pCertStore, struct SizedBuffer *certificates, ubyte4 numCertificate, const ubyte *pKeyBlob, ubyte4 keyBlobLength, ExtendedDataCallback extDataFunc, sbyte4 extDataIdentifier)
This is the same as CERT_STORE_addIdentityWithCertificateChain, except the caller also supplies a cal...
MOC_EXTERN MSTATUS CERT_STORE_findIdentityByAlias(certStorePtr pCertStore, ubyte *pAlias, ubyte4 aliasLen, struct AsymmetricKey **ppReturnIdentityKey, ubyte **ppRetDerCert, ubyte4 *pRetDerCertLength)
Find the identity in the cert store associated with the given "alias".
MOC_EXTERN MSTATUS CERT_STORE_findIdentityCertChainNext(const certStorePtr pCertStore, ubyte4 pubKeyType, ubyte4 supportedKeyTypeAndAlgoFlags, const struct AsymmetricKey **ppRetIdentityKey, const struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumberCertificate, void **ppRetHint)
Continue the search for an identity from the hint provided.
MOC_EXTERN MSTATUS CERT_STORE_addTrustPoint(certStorePtr pCertStore, const ubyte *pDerTrustPoint, ubyte4 derTrustPointLength)
Add a trust point to a Digicert SoT Platform certificate store.
MOC_EXTERN MSTATUS CERT_STORE_findIdentityCertChainFirst(const certStorePtr pCertStore, ubyte4 pubKeyType, ubyte4 supportedAlgoFlags, const struct AsymmetricKey **ppRetIdentityKey, const struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumberCertificate, void **ppRetHint)
Retrieve the first identity stored for the specified key type and supported algorithm.
MOC_EXTERN MSTATUS CERT_STORE_addIdentityNakedKeyEx(certStorePtr pCertStore, ubyte *pAlias, ubyte4 aliasLen, ubyte *pKeyBlob, ubyte4 keyBlobLength)
This is the same as CERT_STORE_addIdentityNakedKey, except the caller also supplies an "alias"...
MOC_EXTERN MSTATUS CERT_STORE_addIdentityWithCertificateChain(certStorePtr pCertStore, struct SizedBuffer *certificates, ubyte4 numCertificate, const ubyte *pKeyBlob, ubyte4 keyBlobLength)
This is the same as CERT_STORE_addIdentity except the caller can specify multiple certificates...
MOC_EXTERN MSTATUS CERT_STORE_findTrustPointBySubjectNext(const void **iterator, const ubyte **ppRetDerCert, ubyte4 *pRetDerCertLength)
This function continues a search for a certificate based on the iterator.
MOC_EXTERN MSTATUS CERT_STORE_findTrustPointBySubjectFirst(const certStorePtr pCertStore, const ubyte *subject, ubyte4 subjectLength, const ubyte **ppRetDerCert, ubyte4 *pRetDerCertLength, const void **iterator)
Find a trusted certificate by subject.
MOC_EXTERN MSTATUS CERT_STORE_addIdentityNakedKey(certStorePtr pCertStore, const ubyte *pKeyBlob, ubyte4 keyBlobLength)
This API adds a key blob to the certificate store.
MOC_EXTERN MSTATUS CERT_STORE_findTrustPointBySubject(MOC_ASYM(hwAccelDescr hwAccelCtx) const certStorePtr pCertStore, const ubyte *subject, ubyte4 subjectLength, const void *cbArg, CERT_STORE_MatchFun cb, const ubyte **ppRetDerCert, ubyte4 *pRetDerCertLength)
Find a trusted certificate by subject and user defined callback.
MOC_EXTERN MSTATUS CERT_STORE_addIdentityWithCertificateChainEx(certStorePtr pCertStore, ubyte *pAlias, ubyte4 aliasLen, struct SizedBuffer *certificates, ubyte4 numCertificate, const ubyte *pKeyBlob, ubyte4 keyBlobLength)
This is the same as CERT_STORE_addIdentityWithCertificateChain, except the caller also supplies an "a...
identityTypes
The certificate store has two types of identities.
Definition: cert_store.h:218
MOC_EXTERN MSTATUS CERT_STORE_findCertificateByIssuerSerialNumber(const certStorePtr pCertStore, const ubyte *pIssuer, ubyte4 issuerLength, const ubyte *serialNumber, ubyte4 serialNumberLength, const ubyte **ppRetDerCert, ubyte4 *ppRetDerCertLength, const struct AsymmetricKey **pRetPrivateKey)
Retrieve the certificate and associated private key if available.
MOC_EXTERN MSTATUS CERT_STORE_findIdentityByAliasAndAlgo(certStorePtr pCertStore, ubyte4 pubKeyType, ubyte2 keyUsage, ubyte4 *pSupportedCertKeyAlgos, ubyte4 supportedCertKeyAlgosLen, ubyte4 *pSupportedSignAlgos, ubyte4 supportedSignAlgosLen, ubyte *pAlias, ubyte4 aliasLen, struct AsymmetricKey **ppReturnIdentityKey, struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumCertificates, void **ppRetHint)
Find the identity in the cert store associated with the given "alias" and verify it satisfies a given...
MOC_EXTERN MSTATUS CERT_STORE_findIdentityByTypeFirst(const certStorePtr pCertStore, enum authTypes authType, enum identityTypes identityType, const struct AsymmetricKey **ppRetIdentityKey, const ubyte **ppRetDerCert, ubyte4 *pRetDerCertLength, void **ppRetHint)
Retrieve the first identity stored for the specified auth type and identity type. ...
MOC_EXTERN MSTATUS CERT_STORE_addIdentityPSK(certStorePtr pCertStore, const ubyte *pPskIdentity, ubyte4 pskIdentityLength, const ubyte *pPskHint, ubyte4 pskHintLength, const ubyte *pPskSecret, ubyte4 pskSecretLength)
Add a PSK to the certificate store.
MOC_EXTERN MSTATUS CERT_STORE_addIdentityWithCertificateChainExtDataEx(certStorePtr pCertStore, ubyte *pAlias, ubyte4 aliasLen, struct SizedBuffer *certificates, ubyte4 numCertificate, const ubyte *pKeyBlob, ubyte4 keyBlobLength, ExtendedDataCallback extDataFunc, sbyte4 extDataIdentifier)
This is the same as CERT_STORE_addIdentityWithCertificateChain, except the caller also supplies a cal...
MOC_EXTERN MSTATUS CERT_STORE_addIdentity(certStorePtr pCertStore, const ubyte *pDerCert, ubyte4 derCertLength, const ubyte *pKeyBlob, ubyte4 keyBlobLength)
Load a certificate and key pair into the certificate store.
authTypes
The certificate store places identities into algorithm indexes.
Definition: cert_store.h:199
MOC_EXTERN MSTATUS CERT_STORE_releaseStore(certStorePtr *ppReleaseStore)
Delete a certificate store object.
MOC_EXTERN MSTATUS CERT_STORE_findIdentityCertChainNextEx(const certStorePtr pCertStore, ubyte4 pubKeyType, ubyte2 keyUsage, ubyte4 supportedKeyTypeAndAlgoFlags, const struct AsymmetricKey **ppRetIdentityKey, const struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumberCertificate, void **ppRetHint)
Continue the search for an identity from the hint provided.
MOC_EXTERN MSTATUS CERT_STORE_findIdentityCertChainFirstFromList(const certStorePtr pCertStore, ubyte4 pubKeyType, ubyte2 keyUsage, ubyte4 *pSupportedCertKeyIds, ubyte4 supportedCertKeyIdsLen, ubyte4 *pSupportedSignAlgoIds, ubyte4 supportedSignAlgoIdsLen, const struct AsymmetricKey **ppRetIdentityKey, const struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumberCertificate, void **ppRetHint)
Retrieve the first identity stored for the specified key type and supported algorithms.
MOC_EXTERN MSTATUS CERT_STORE_findIdentityByTypeNext(const certStorePtr pCertStore, enum authTypes authType, enum identityTypes identityType, const struct AsymmetricKey **ppRetIdentityKey, const ubyte **ppRetDerCert, ubyte4 *pRetDerCertLength, void **ppRetHint)
This function continues the search for a hint.
MOC_EXTERN MSTATUS CERT_STORE_findIdentityCertChainNextFromList(const certStorePtr pCertStore, ubyte4 pubKeyType, ubyte2 keyUsage, ubyte4 *pSupportedCertKeyIds, ubyte4 supportedCertKeyIdsLen, ubyte4 *pSupportedSignAlgoIds, ubyte4 supportedSignAlgoIdsLen, const struct AsymmetricKey **ppRetIdentityKey, const struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumberCertificate, void **ppRetHint)
Continue the search for an identity from the hint provided.
MOC_EXTERN MSTATUS CERT_STORE_addIdentityEx(certStorePtr pCertStore, ubyte *pAlias, ubyte4 aliasLen, ubyte *pDerCert, ubyte4 derCertLength, ubyte *pKeyBlob, ubyte4 keyBlobLength)
This is the same as CERT_STORE_addIdentity except the caller also supplies an "alias".
MOC_EXTERN MSTATUS CERT_STORE_findIdentityCertChainFirstEx(const certStorePtr pCertStore, ubyte4 pubKeyType, ubyte2 keyUsage, ubyte4 supportedAlgoFlags, const struct AsymmetricKey **ppRetIdentityKey, const struct SizedBuffer **ppRetCertificates, ubyte4 *pRetNumberCertificate, void **ppRetHint)
Retrieve the first identity stored for the specified key type and supported algorithm.
MOC_EXTERN MSTATUS CERT_STORE_createStore(certStorePtr *ppNewStore)
Create a certificate store object.
MSTATUS(* CERT_STORE_MatchFun)(MOC_ASYM(hwAccelDescr hwAccelCtx) const void *arg, const ubyte *testCert, ubyte4 testCertLen)
Certificate store callback.
Definition: cert_store.h:776