TrustCore SDK NanoCert API reference  version 7.0
ca_mgmt.h
Go to the documentation of this file.
1 /*
2  * ca_mgmt.h
3  *
4  * Certificate Authority Management Factory
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
10 
36 /*------------------------------------------------------------------*/
37 
38 #ifndef __CA_MGMT_HEADER__
39 #define __CA_MGMT_HEADER__
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 
46 /*------------------------------------------------------------------*/
47 
48 /* these values are serialized -- add but don't modify */
49 /* valid values for the AsymmetricKey type field */
50 /* The akt_custom is for custom keys, such as hardware keys.
51  */
52 enum
53 {
54  akt_undefined = 0, /* keep it 0 -> static var are correctly initialized */
55  /* as undefined */
56  akt_rsa = 1,
57  akt_ecc = 2,
58  akt_dsa = 3,
59  akt_dh = 4,
60  akt_rsa_pss = 5,
61 
62  akt_custom = 101,
63  akt_moc = 102,
64 
65  akt_ecc_ed = 112,
66 
67  akt_hybrid = 113,
68  akt_qs = 114,
69 
70  akt_tap_rsa = 0x00020001,
71  akt_tap_ecc = 0x00020002,
72  akt_hsm_rsa = 0x00010001,
73  akt_hsm_ecc = 0x00010002
74 };
75 
76 #if (defined(__ENABLE_MOCANA_ECC__))
77 /*
78  curveId: they actually match the suffix of the OID
79  for these curves or algorithm identifiers
80  */
81 enum
82 {
83  cid_EC_P192 = 1,
84  cid_EC_P256 = 7,
85  cid_EC_P224 = 33,
86  cid_EC_P384 = 34,
87  cid_EC_P521 = 35,
88  cid_EC_X25519 = 110, /* edDH X25519 suffix */
89  cid_EC_X448 = 111, /* edDH X448 suffix */
90  cid_EC_Ed25519 = 112, /* edDSA 25519 suffix */
91  cid_EC_Ed448 = 113 /* edDSA 448 suffix */
92 };
93 
94 #endif
95 
96 #if (defined(__ENABLE_MOCANA_QS__))
97 /* Identifiers for quantum safe sig algs, SIG values match the OID suffix for each algorithm */
98 enum
99 {
100  cid_QS_SIG_DILITHIUM_2 = 0x04,
101  cid_QS_SIG_DILITHIUM_3 = 0x05,
102  cid_QS_SIG_DILITHIUM_4 = 0x06,
103  cid_QS_SIG_DILITHIUM_5 = 0x07,
104  cid_QS_SIG_FALCON_512 = 0x10,
105  cid_QS_SIG_FALCON_1024 = 0x11,
106  cid_QS_SIG_SPHINCS_PLUS_SHA2_128S = 0x50,
107  cid_QS_SIG_SPHINCS_PLUS_SHA2_128F = 0x51,
108  cid_QS_SIG_SPHINCS_PLUS_SHAKE_128S = 0x52,
109  cid_QS_SIG_SPHINCS_PLUS_SHAKE_128F = 0x53,
110  cid_QS_SIG_SPHINCS_PLUS_SHA2_192S = 0x54,
111  cid_QS_SIG_SPHINCS_PLUS_SHA2_192F = 0x55,
112  cid_QS_SIG_SPHINCS_PLUS_SHAKE_192S = 0x56,
113  cid_QS_SIG_SPHINCS_PLUS_SHAKE_192F = 0x57,
114  cid_QS_SIG_SPHINCS_PLUS_SHA2_256S = 0x58,
115  cid_QS_SIG_SPHINCS_PLUS_SHA2_256F = 0x59,
116  cid_QS_SIG_SPHINCS_PLUS_SHAKE_256S = 0x5a,
117  cid_QS_SIG_SPHINCS_PLUS_SHAKE_256F = 0x5b,
118 #if 0
119  cid_QS_SIG_RAINBOW_IA_CLASSIC = 0x20,
120  cid_QS_SIG_RAINBOW_IA_CYCLIC = 0x21,
121  cid_QS_SIG_RAINBOW_IA_CYCLIC_COMPRESSED = 0x22,
122  cid_QS_SIG_RAINBOW_IIIC_CLASSIC = 0x23,
123  cid_QS_SIG_RAINBOW_IIIC_CYCLIC = 0x24,
124  cid_QS_SIG_RAINBOW_IIIC_CYCLIC_COMPRESSED = 0x25,
125  cid_QS_SIG_RAINBOW_VC_CLASSIC = 0x26,
126  cid_QS_SIG_RAINBOW_VC_CYCLIC = 0x27,
127  cid_QS_SIG_RAINBOW_VC_CYCLIC_COMPRESSED = 0x28,
128  cid_QS_SIG_QTESLA_P_I = 0x30,
129  cid_QS_SIG_MQDSS_31_48 = 0x40,
130 #endif
131  cid_QS_KEM_MCELIECE_348864 = 0x100,
132  cid_QS_KEM_MCELIECE_348864F = 0x101,
133  cid_QS_KEM_MCELIECE_460896 = 0x102,
134  cid_QS_KEM_MCELIECE_460896F = 0x103,
135  cid_QS_KEM_MCELIECE_6688128 = 0x104,
136  cid_QS_KEM_MCELIECE_6688128F = 0x105,
137  cid_QS_KEM_MCELIECE_6960119 = 0x106,
138  cid_QS_KEM_MCELIECE_6960119F = 0x107,
139  cid_QS_KEM_MCELIECE_8192128 = 0x108,
140  cid_QS_KEM_MCELIECE_8192128F = 0x109,
141  cid_QS_KEM_KYBER_512 = 0x110,
142  cid_QS_KEM_KYBER_768 = 0x111,
143  cid_QS_KEM_KYBER_1024 = 0x112,
144  cid_QS_KEM_KYBER_512_90S = 0x113,
145  cid_QS_KEM_KYBER_768_90S = 0x114,
146  cid_QS_KEM_KYBER_1024_90S = 0x115,
147  cid_QS_KEM_NTRU_HPS_2048_509 = 0x120,
148  cid_QS_KEM_NTRU_HPS_2048_677 = 0x121,
149  cid_QS_KEM_NTRU_HPS_4096_821 = 0x122,
150  cid_QS_KEM_NTRU_HRSS_701 = 0x123,
151  cid_QS_KEM_LIGHTSABER = 0x130,
152  cid_QS_KEM_SABER = 0x131,
153  cid_QS_KEM_FIRESABER = 0x132,
154  cid_QS_KEM_FRODOKEM_640_AES = 0x140,
155  cid_QS_KEM_NEWHOPE_512CCA = 0x150,
156  cid_QS_KEM_SIKE_P434 = 0x160,
157  cid_QS_KEM_SIDH_P434 = 0x170
158 };
159 #endif
160 
161 
162 /*------------------------------------------------------------------*/
163 
164 struct AsymmetricKey;
165 
181 typedef struct certDescriptor
182 {
187  ubyte* pCertificate;
188 
193  ubyte4 certLength;
194 
199  ubyte* pKeyBlob;
200 
206 
213  struct AsymmetricKey* pKey;
214 
215 #if !(defined __ENABLE_MOCANA_64_BIT__)
216 
226  ubyte4 cookie;
227 #else
228 
238  ubyte8 cookie;
239 #endif
241 
242 /* old structure */
243 
291 typedef struct nameAttr
292 {
307  const ubyte *oid; /* the OID of the attribute */
320  ubyte type;
327  ubyte* value;
332  ubyte4 valueLen;
333 } nameAttr;
334 
396 typedef struct relativeDN /* RDN */
397 {
409 } relativeDN;
410 
424 typedef struct certDistinguishedName
425 {
437  ubyte4 dnCount;
438 
448  sbyte* pStartDate; /* 030526000126Z */
449 
459  sbyte* pEndDate; /* 330524230347Z */
460 
462 
473 typedef struct extensions
474 {
511  ubyte* oid;
512 
517  byteBoolean isCritical;
518 
539  ubyte* value;
540 
547  ubyte4 valueLen;
548 } extensions;
549 
560 typedef struct certExtensions
561 {
568  byteBoolean hasBasicConstraints;
569 
576  byteBoolean isCA;
577 
588  sbyte certPathLen; /* if negative omit this */
589 
596  /* key usage */
597  byteBoolean hasKeyUsage;
598 
617  ubyte2 keyUsage;
618 
624 
631 
632 enum matchFlag
633 {
634  matchFlagSuffix = 0x01, /* match only the last part "server1.acme.com" matches "acme.com" */
635  noWildcardMatch = 0x02, /* name is not following rules... */
636  matchFlagNoWildcard = 0x02,
637  matchFlagDotSuffix = 0x04
638  /* others tbd */
639 };
640 
641 
646 typedef struct CNMatchInfo
647 {
648  ubyte4 flags;
649  const sbyte* name;
650 } CNMatchInfo;
651 
652 /* subtype of SubjectAltName */
653 enum
654 {
655  SubjectAltName_otherName,
656  SubjectAltName_rfc822Name,
657  SubjectAltName_dNSName,
658  SubjectAltName_x400Address,
659  SubjectAltName_directoryName,
660  SubjectAltName_ediPartyName,
661  SubjectAltName_uniformResourceIdentifier,
662  SubjectAltName_iPAddress,
663  SubjectAltName_registeredID
664 };
665 
666 typedef struct Blob
667 {
668  ubyte4 dataLen;
669  ubyte* data;
670 } Blob;
671 
672 /* similar to nameAttr */
673 typedef struct SubjectAltNameAttr
674 {
675  Blob subjectAltNameValue;
676  ubyte subjectAltNameType;
677 } SubjectAltNameAttr;
678 
679 
680 /* keyPropertyType values */
681 enum
682 {
683  kp_undefined = 0,
684  kp_size = 1,
685  kp_blob = 2,
686  kp_key = 3
687 };
688 
689 /* properties to use when creating a certificate
690  all are optional, if not specified, appropriate default values will be used */
691 typedef struct CertProperties
692 {
693  ubyte signAlgorithm;
694  ubyte keyPropertyType; /* kp_xxxx */
695  union
696  {
697  Blob keyBlob;
698  const struct AsymmetricKey* pKey;
699  ubyte4 keySize;
700  } keyProperty;
701  const certDescriptor* pParentCert;
702  const certExtensions* pExtensions;
703  Blob serialNumber;
704 } CertProperties;
705 
706 
707 /*------------------------------------------------------------------*/
708 
709 /* common server (certificate & key related methods) */
710 /* signAlgo is now the last digit of the PKCS1 OID ex: md5withRSAEncryption */
711 /* more complex versions of these -- specify extensions and parent certificate */
712 MOC_EXTERN sbyte4 CA_MGMT_generateCertificateEx( certDescriptor *pRetCertificate, ubyte4 keySize,
713  const certDistinguishedName *pCertInfo, ubyte signAlgorithm,
714  const certExtensions* pExtensions,
715  const certDescriptor* pParentCertificate);
716 
717 MOC_EXTERN sbyte4 CA_MGMT_generateCertificateWithProperties( certDescriptor *pRetCertificate,
718  const certDistinguishedName* forName,
719  const CertProperties* properties);
720 
721 MOC_EXTERN sbyte4 CA_MGMT_generateCertificateEx2( certDescriptor *pRetCertificate,
722  struct AsymmetricKey* key,
723  const certDistinguishedName *pCertInfo,
724  ubyte signAlgorithm);
725 
803 MOC_EXTERN sbyte4 CA_MGMT_generateCertificateExType( certDescriptor *pRetCertificate, ubyte4 keyType, ubyte4 keySize,
804  const certDistinguishedName *pCertInfo, ubyte signAlgorithm,
805  const certExtensions* pExtensions,
806  const certDescriptor* pParentCertificate);
807 
861 MOC_EXTERN sbyte4 CA_MGMT_generateCertificateHybrid( certDescriptor *pRetCertificate, ubyte4 curve, ubyte4 qsAlg,
862  const certDistinguishedName *pCertInfo, const certExtensions* pExtensions,
863  const certDescriptor* pParentCertificate);
864 
865 
866 MOC_EXTERN sbyte4 CA_MGMT_makeSubjectAltNameExtension( extensions* pExtension,
867  const SubjectAltNameAttr* nameAttrs,
868  sbyte4 numNameAttrs);
869 
870 
908 MOC_EXTERN sbyte4 CA_MGMT_freeCertificate(certDescriptor *pRetCertificateDescr);
909 
910 #if 0
911 /*
912  @cond
913 
914  @brief Get a copy of an SoT Platform key blob's public key.
915 
916  @details This function gets a copy of the public key in an SoT Platform
917  key blob returned by CA_MGMT_generateCertificate().
918 
919  @ingroup cert_mgmt_functions
920 
921  @since 1.41
922  @version 1.41 and later
923 
924  @flags
925  To enable this function, the following flag must \b not be defined:
926  + \c \__DISABLE_MOCANA_CERTIFICATE_GENERATION__
927 
928  @inc_file ca_mgmt.h
929 
930  @param pCertificateDescr Pointer to the certificate descriptor containing
931  the X.509 certificate and key blob from which
932  you want to extract the key.
933  @param ppRetPublicKey On return, pointer to the extracted public key.
934  @param pRetPublicKeyLength On return, pointer to number of bytes in the
935  generated public key.
936 
937  @return \c OK (0) if successful; otherwise a negative number error code
938  definition from merrors.h. To retrieve a string containing an
939  English text error identifier corresponding to the function's
940  returned error status, use the \c DISPLAY_ERROR macro.
941 
942  @remark This is a convenience function provided for your application's
943  use; it is not used by Digicert SoT Platform internal code.
944 
945  @code
946  sbyte4 status = 0;
947 
948  status = CA_MGMT_returnPublicKey(pCertificateDescr, &pRetPublicKey, &retPublicKeyLength);
949  @endcode
950 
951  @funcdoc ca_mgmt.h
952  */
953 MOC_EXTERN sbyte4 CA_MGMT_returnPublicKey(certDescriptor *pCertificateDescr, ubyte **ppRetPublicKey, ubyte4 *pRetPublicKeyLength);
954 
955 /*
956  @brief Get number of bytes in a certificate's public key.
957 
958  @details This function gets the number of bytes in a specified
959  certificate's public key.
960 
961  @ingroup cert_mgmt_functions
962 
963  @since 1.41
964  @version 1.41 and later
965 
966  @flags
967  To enable this function, the following flag must \b not be defined:
968  + \c \__DISABLE_MOCANA_CERTIFICATE_GENERATION__
969 
970  @inc_file ca_mgmt.h
971 
972  @param pCertificateDescr Pointer to the certificate descriptor
973  containing the X.509 certificate and
974  key blob generated public key whose
975  length you want.
976  @param pRetPublicKeyLengthInBits On return, pointer to length (in bits) of
977  the generated public key.
978 
979  @return \c OK (0) if successful; otherwise a negative number error code
980  definition from merrors.h. To retrieve a string containing an
981  English text error identifier corresponding to the function's
982  returned error status, use the \c DISPLAY_ERROR macro.
983 
984  @remark This is a convenience function provided for your application's
985  use; it is not used by Digicert SoT Platform internal code.
986 
987  @funcdoc ca_mgmt.h
988  */
989 MOC_EXTERN sbyte4 CA_MGMT_returnPublicKeyBitLength(certDescriptor *pCertificateDescr, ubyte4 *pRetPublicKeyLengthInBits);
990 
991 /*
992  @brief Free memory allocated by CA_MGMT_returnPublicKey().
993 
994  @details This function frees the memory in the specified buffer that was
995  previously allocated by a call to CA_MGMT__returnPublicKey().
996 
997  @ingroup cert_mgmt_functions
998 
999  @since 1.41
1000  @version 1.41 and later
1001 
1002  @flags
1003  To enable this function, the following flag must \b not be defined:
1004  + \c \__DISABLE_MOCANA_CERTIFICATE_GENERATION__
1005 
1006  @inc_file ca_mgmt.h
1007 
1008  @param ppRetPublicKey Pointer to the public key to free.
1009 
1010  @return \c OK (0) if successful; otherwise a negative number error code
1011  definition from merrors.h. To retrieve a string containing an
1012  English text error identifier corresponding to the function's
1013  returned error status, use the \c DISPLAY_ERROR macro.
1014 
1015  @code
1016  sbyte4 status = 0;
1017 
1018  status = CA_MGMT_freePublicKey(&pRetPublicKey);
1019  @endcode
1020 
1021  @funcdoc ca_mgmt.h
1022  */
1023 MOC_EXTERN sbyte4 CA_MGMT_freePublicKey(ubyte **ppRetPublicKey);
1024 
1028 #endif
1029 
1059 MOC_EXTERN sbyte4 CA_MGMT_allocCertDistinguishedName(certDistinguishedName **ppNewCertDistName);
1060 
1109 MOC_EXTERN sbyte4 CA_MGMT_extractCertDistinguishedName(ubyte *pCertificate, ubyte4 certificateLength, sbyte4 isSubject, certDistinguishedName *pRetDN);
1110 
1150 MOC_EXTERN sbyte4 CA_MGMT_returnCertificatePrints(ubyte *pCertificate, ubyte4 certLength, ubyte *pShaFingerPrint, ubyte *pMD5FingerPrint);
1151 
1152 
1183 MOC_EXTERN sbyte4 CA_MGMT_freeCertDistinguishedName(certDistinguishedName **ppFreeCertDistName);
1184 
1262 MOC_EXTERN sbyte4 CA_MGMT_extractCertASN1Name(const ubyte *pCertificate, ubyte4 certificateLength,
1263  sbyte4 isSubject, sbyte4 includeASN1SeqHeader, ubyte4* pASN1NameOffset, ubyte4* pASN1NameLen);
1264 
1270 MOC_EXTERN sbyte4 CA_MGMT_convertKeyDER(ubyte *pDerRsaKey, ubyte4 derRsaKeyLength, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength);
1276 MOC_EXTERN sbyte4 CA_MGMT_convertKeyPEM(ubyte *pPemRsaKey, ubyte4 pemRsaKeyLength, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength);
1282 MOC_EXTERN MSTATUS CA_MGMT_keyBlobToDER(const ubyte *pKeyBlob, ubyte4 keyBlobLength, ubyte **ppRetKeyDER, ubyte4 *pRetKeyDERLength);
1288 MOC_EXTERN MSTATUS CA_MGMT_publicKeyBlobToDER(const ubyte *pPublicKeyBlob, ubyte4 publicKeyBlobLength,
1289  ubyte **ppRetKeyDER, ubyte4 *pRetKeyDERLength);
1295 MOC_EXTERN MSTATUS CA_MGMT_keyBlobToPEM(const ubyte *pKeyBlob, ubyte4 keyBlobLength, ubyte **ppRetKeyPEM, ubyte4 *pRetKeyPEMLength);
1296 
1348 MOC_EXTERN MSTATUS CA_MGMT_convertRSAPublicKeyInfoDER (
1349  ubyte *pDerRsaKey,
1350  ubyte4 derRsaKeyLength,
1351  ubyte **ppRetKeyBlob,
1352  ubyte4 *pRetKeyBlobLength
1353  );
1354 
1355 struct vlong;
1356 
1357 /* Build the DER encoding of
1358  * <pre>
1359  * <code>
1360  * MocanaTPM1.2RSAKeyData ::= SEQUENCE {
1361  * OCTET STRING encryptedPrivateKey,
1362  * INTEGER modulus,
1363  * INTEGER publicExponent }
1364  * </code>
1365  * </pre>
1366  * <p>This function will allocate space for the encoding and return a pointer to
1367  * this allocated memory at the address given by ppDerEncoding.
1368  * <p>Note that the blob is the Digicert version 2 blob.
1369  */
1370 MOC_EXTERN MSTATUS CA_MGMT_tpm12RsaKeyBlobToDer (
1371  ubyte *pKeyBlob,
1372  ubyte4 keyBlobLen,
1373  struct vlong *pModulus,
1374  struct vlong *pPubExpo,
1375  ubyte **ppDerEncoding,
1376  ubyte4 *pDerEncodingLen
1377  );
1378 
1407 MOC_EXTERN MSTATUS CA_MGMT_verifyCertDate(ubyte *pCert, ubyte4 certLen);
1408 
1443 MOC_EXTERN sbyte4 CA_MGMT_verifyCertWithKeyBlob(certDescriptor *pCertificateDescr, sbyte4 *pIsGood);
1444 
1484 MOC_EXTERN sbyte4 CA_MGMT_extractCertTimes(ubyte *pCertificate, ubyte4 certificateLength, certDistinguishedName *pRetDN);
1485 
1523 MOC_EXTERN sbyte4 CA_MGMT_decodeCertificate(ubyte* pKeyFile, ubyte4 fileSize, ubyte** ppDecodeFile, ubyte4 *pDecodedLength);
1524 
1525 #ifdef __ENABLE_MOCANA_CERTIFICATE_SEARCH_SUPPORT__
1526 MOC_EXTERN sbyte4 CA_MGMT_extractSerialNum (ubyte* pCertificate, ubyte4 certificateLength, ubyte** ppRetSerialNum, ubyte4* pRetSerialNumLength);
1527 MOC_EXTERN sbyte4 CA_MGMT_freeSearchDetails(ubyte** ppFreeData);
1528 
1533 typedef sbyte4 (*CA_MGMT_EnumItemCBFun)( const ubyte* pContent, ubyte4 contentLen, ubyte4 contentType,
1534  ubyte4 index, void* userArg);
1535 
1536 
1598 MOC_EXTERN sbyte4 CA_MGMT_enumCrl(ubyte* pCertificate, ubyte4 certificateLength,
1599  CA_MGMT_EnumItemCBFun callbackFunc, void* userArg);
1600 
1666 MOC_EXTERN sbyte4 CA_MGMT_enumAltName( ubyte* pCertificate, ubyte4 certificateLength, sbyte4 isSubject,
1667  CA_MGMT_EnumItemCBFun callbackFunc, void* userArg);
1668 #endif
1669 
1670 #ifdef __PUBCRYPTO_HEADER__
1671 
1676 MOC_EXTERN MSTATUS CA_MGMT_makeKeyBlobEx(const AsymmetricKey *pKey, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyLength);
1682 MOC_EXTERN MSTATUS CA_MGMT_extractKeyBlobEx(const ubyte *pKeyBlob, ubyte4 keyBlobLength, AsymmetricKey* pKey);
1688 MOC_EXTERN MSTATUS CA_MGMT_extractKeyBlobTypeEx(const ubyte *pKeyBlob, ubyte4 keyBlobLength, ubyte4 *pRetKeyType);
1694 MOC_EXTERN MSTATUS CA_MGMT_extractPublicKey(const ubyte *pKeyBlob, ubyte4 keyBlobLength, ubyte **ppRetPublicKeyBlob, ubyte4 *pRetPublicKeyBlobLength, ubyte4 *pRetKeyType);
1695 #endif /* __PUBCRYPTO_HEADER__ */
1696 
1697 #ifdef __ENABLE_MOCANA_EXTRACT_CERT_BLOB__
1698 MOC_EXTERN sbyte4 CA_MGMT_findCertDistinguishedName(ubyte *pCertificate, ubyte4 certificateLength, intBoolean isSubject, ubyte **ppRetDistinguishedName, ubyte4 *pRetDistinguishedNameLen);
1699 #endif
1700 
1741 MOC_EXTERN sbyte4 CA_MGMT_generateNakedKey(ubyte4 keyType, ubyte4 keySize, ubyte **ppRetNewKeyBlob, ubyte4 *pRetNewKeyBlobLength);
1742 
1815 MOC_EXTERN sbyte4 CA_MGMT_generateNakedHybridKey(ubyte4 keyType, ubyte4 legacyKeyType, ubyte4 legacyKeySize, ubyte4 qsAlgoId,
1816  ubyte **ppRetNewKeyBlob, ubyte4 *pRetNewKeyBlobLength);
1842 MOC_EXTERN sbyte4 CA_MGMT_freeNakedKey(ubyte **ppFreeKeyBlob);
1843 
1887 MOC_EXTERN sbyte4 CA_MGMT_convertPKCS8KeyToKeyBlob(const ubyte* pPKCS8DER, ubyte4 pkcs8DERLen, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength);
1888 
1934 MOC_EXTERN sbyte4 CA_MGMT_convertProtectedPKCS8KeyToKeyBlob(const ubyte* pPKCS8DER, ubyte4 pkcs8DERLen, ubyte *pPassword, ubyte4 passwordLen, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength);
1935 
1936 #ifdef __PKCS_KEY_HEADER__
1937 
1981 MOC_EXTERN sbyte4 CA_MGMT_convertKeyBlobToPKCS8Key(const ubyte *pKeyBlob, ubyte4 keyBlobLength, enum PKCS8EncryptionType encType, const ubyte *pPassword, ubyte4 passwordLen, ubyte **ppRetPKCS8DER, ubyte4 *pRetPkcs8DERLen);
1982 #endif
1983 
1984 #if !(defined(__DISABLE_MOCANA_KEY_GENERATION__)) && !(defined(__DISABLE_MOCANA_CERTIFICATE_PARSING__))
1985 
2001 MOC_EXTERN sbyte4 CA_MGMT_extractPublicKeyInfo(ubyte *pCertificate, ubyte4 certificateLen, ubyte** ppRetKeyBlob, ubyte4 *pRetKeyBlobLen);
2002 #endif
2003 
2017 MOC_EXTERN sbyte4 CA_MGMT_verifySignature(const ubyte* pIssuerCertBlob, ubyte4 issuerCertBlobLen, ubyte* pCertificate, ubyte4 certLen);
2018 
2034 MOC_EXTERN sbyte4 CA_MGMT_extractSignature(ubyte* pCertificate, ubyte4 certificateLen, ubyte** ppSignature, ubyte4* pSignatureLen);
2035 
2043 MOC_EXTERN sbyte4 CA_MGMT_extractBasicConstraint(ubyte* pCertificate, ubyte4 certificateLen, intBoolean* pIsCritical, certExtensions* pCertExtensions);
2044 
2061 MOC_EXTERN MSTATUS CA_MGMT_getCertSignAlgoType(ubyte *pCertificate, ubyte4 certificateLen, ubyte4* pHashType, ubyte4* pPubKeyType);
2062 
2080 MOC_EXTERN MSTATUS CA_MGMT_convertIpAddress(ubyte *pIpString, ubyte *pIpBytes, ubyte4 *pIpLen);
2081 
2082 #ifdef __cplusplus
2083 }
2084 #endif
2085 
2086 #endif /* __CA_MGMT_HEADER__ */
ubyte4 valueLen
Number of bytes in the name value buffer (value).
Definition: ca_mgmt.h:332
ubyte4 cookie
Application-specific cookie.
Definition: ca_mgmt.h:226
MOC_EXTERN MSTATUS CA_MGMT_getCertSignAlgoType(ubyte *pCertificate, ubyte4 certificateLen, ubyte4 *pHashType, ubyte4 *pPubKeyType)
Gets the hash type and public key type out of a cert.
MOC_EXTERN sbyte4 CA_MGMT_verifySignature(const ubyte *pIssuerCertBlob, ubyte4 issuerCertBlobLen, ubyte *pCertificate, ubyte4 certLen)
Verifies the signature in a certificate.
Container for nameAttr structure information required to construct an ASN.1 RelativeDistinguishedName...
Definition: ca_mgmt.h:396
sbyte * pStartDate
String identifying certificate&#39;s start date, in the format yymmddhhmmssZ; for example, "030526000126Z" specifies May 26th, 2003 12:01:26 AM.
Definition: ca_mgmt.h:448
ubyte4 dnCount
Number of relative distinguished names in pDistinguishedName buffer.
Definition: ca_mgmt.h:437
MOC_EXTERN sbyte4 CA_MGMT_extractCertDistinguishedName(ubyte *pCertificate, ubyte4 certificateLength, sbyte4 isSubject, certDistinguishedName *pRetDN)
Get a DER-encoded X.509 certificate&#39;s subject or issuer (as specified by the isSubject parameter) dis...
ubyte4 otherExtCount
Number of extensions in the extensions array.
Definition: ca_mgmt.h:629
Version 3 certificate or CRL extension (as defined in RFC&#160;3280).
Definition: ca_mgmt.h:473
MOC_EXTERN sbyte4 CA_MGMT_generateCertificateHybrid(certDescriptor *pRetCertificate, ubyte4 curve, ubyte4 qsAlg, const certDistinguishedName *pCertInfo, const certExtensions *pExtensions, const certDescriptor *pParentCertificate)
Generates a signed X.509 certificate and private/public key pair for a hybrid authentication algorith...
ubyte2 keyUsage
Bit-string representing the desired version 3 certificate extensions.
Definition: ca_mgmt.h:617
MOC_EXTERN sbyte4 CA_MGMT_convertKeyPEM(ubyte *pPemRsaKey, ubyte4 pemRsaKeyLength, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)
This is an old function.
MOC_EXTERN sbyte4 CA_MGMT_convertKeyDER(ubyte *pDerRsaKey, ubyte4 derRsaKeyLength, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)
This is an old function.
ubyte4 valueLen
Number of bytes in the DER-encoded extension value (value).
Definition: ca_mgmt.h:547
relativeDN * pDistinguishedName
Pointer to buffer array of relative distinguished names.
Definition: ca_mgmt.h:430
MOC_EXTERN sbyte4 CA_MGMT_extractCertTimes(ubyte *pCertificate, ubyte4 certificateLength, certDistinguishedName *pRetDN)
Get a DER-encoded X.509 certificate&#39;s start and expiration times and dates.
MOC_EXTERN sbyte4 CA_MGMT_extractSignature(ubyte *pCertificate, ubyte4 certificateLen, ubyte **ppSignature, ubyte4 *pSignatureLen)
Gets the signature out of a cert.
sbyte * pEndDate
String identifying certificate&#39;s end date, in the format yymmddhhmmssZ; for example, "330524230347Z" specifies May 24th, 2033 11:03:47 PM.
Definition: ca_mgmt.h:459
MOC_EXTERN sbyte4 CA_MGMT_freeCertDistinguishedName(certDistinguishedName **ppFreeCertDistName)
Free certDistinguishedName structure&#39;s memory.
ubyte * value
(Optional) String containing information applicable to the oid field.
Definition: ca_mgmt.h:327
nameAttr * pNameAttr
Array of nameAttr of length dnCount.
Definition: ca_mgmt.h:403
ubyte type
(Optional) DirectoryString CHOICE for the value field, such as UTF8String.
Definition: ca_mgmt.h:320
MOC_EXTERN sbyte4 CA_MGMT_generateNakedHybridKey(ubyte4 keyType, ubyte4 legacyKeyType, ubyte4 legacyKeySize, ubyte4 qsAlgoId, ubyte **ppRetNewKeyBlob, ubyte4 *pRetNewKeyBlobLength)
Generate a naked key.
byteBoolean hasKeyUsage
TRUE specifies that the certificate contains a keyUsage extension; FALSE otherwise.
Definition: ca_mgmt.h:597
ubyte4 certLength
Number of bytes in pCertificate.
Definition: ca_mgmt.h:193
byteBoolean hasBasicConstraints
TRUE specifies that the certificate contains a basicConstraints extension; FALSE otherwise.
Definition: ca_mgmt.h:568
MOC_EXTERN MSTATUS CA_MGMT_convertRSAPublicKeyInfoDER(ubyte *pDerRsaKey, ubyte4 derRsaKeyLength, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)
Convert the DER encoding of an RSA public key in PublicKeyInfo format into a Digicert key blob...
MOC_EXTERN MSTATUS CA_MGMT_publicKeyBlobToDER(const ubyte *pPublicKeyBlob, ubyte4 publicKeyBlobLength, ubyte **ppRetKeyDER, ubyte4 *pRetKeyDERLength)
This is an old function.
Certificate generation support for constructing an AttributeTypeAndValues ASN.1 object.
Definition: ca_mgmt.h:291
MOC_EXTERN sbyte4 CA_MGMT_allocCertDistinguishedName(certDistinguishedName **ppNewCertDistName)
Allocate and initialize a pCertificateDesc structure.
MOC_EXTERN sbyte4 CA_MGMT_extractPublicKeyInfo(ubyte *pCertificate, ubyte4 certificateLen, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLen)
Gets the public key from a certificate.
ubyte4 nameAttrCount
Number of nameAttr objects in pNameAttr.
Definition: ca_mgmt.h:408
Definition: ca_mgmt.h:646
MOC_EXTERN sbyte4 CA_MGMT_convertProtectedPKCS8KeyToKeyBlob(const ubyte *pPKCS8DER, ubyte4 pkcs8DERLen, ubyte *pPassword, ubyte4 passwordLen, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)
Extract a protected RSA private key from a PKCS&#160;#8 DER- encoded buffer, converting it into a Digicert...
Distinguished name data (names and start/end dates) to support certificate generation.
Definition: ca_mgmt.h:424
Certificate context (information required to manage a DER-encoded X.509 certificate).
Definition: ca_mgmt.h:181
MOC_EXTERN MSTATUS CA_MGMT_keyBlobToPEM(const ubyte *pKeyBlob, ubyte4 keyBlobLength, ubyte **ppRetKeyPEM, ubyte4 *pRetKeyPEMLength)
This is an old function.
extensions * otherExts
Pointer to array of version 3 extensions.
Definition: ca_mgmt.h:623
MOC_EXTERN sbyte4 CA_MGMT_generateCertificateExType(certDescriptor *pRetCertificate, ubyte4 keyType, ubyte4 keySize, const certDistinguishedName *pCertInfo, ubyte signAlgorithm, const certExtensions *pExtensions, const certDescriptor *pParentCertificate)
Generate a signed X.509 certificate and public/private key pair.
struct AsymmetricKey * pKey
Pointer to asymmetric key; if defined, use this instead of pKeyBlob.
Definition: ca_mgmt.h:213
ubyte * oid
Extension Id: an OID defined in src/asn1/oiddefs.h.
Definition: ca_mgmt.h:511
MOC_EXTERN sbyte4 CA_MGMT_returnCertificatePrints(ubyte *pCertificate, ubyte4 certLength, ubyte *pShaFingerPrint, ubyte *pMD5FingerPrint)
Generate an X.509 certificate&#39;s SHA-1 and MD5 fingerprints.
Container for a certificate&#39;s version 3 extensions.
Definition: ca_mgmt.h:560
MOC_EXTERN MSTATUS CA_MGMT_convertIpAddress(ubyte *pIpString, ubyte *pIpBytes, ubyte4 *pIpLen)
Converts an IP address represented by a string (v4 or v6) to raw bytes.
byteBoolean isCA
TRUE specifies that the basicConstraints is a CA value; FALSE otherwise.
Definition: ca_mgmt.h:576
MOC_EXTERN MSTATUS CA_MGMT_keyBlobToDER(const ubyte *pKeyBlob, ubyte4 keyBlobLength, ubyte **ppRetKeyDER, ubyte4 *pRetKeyDERLength)
This is an old function.
MOC_EXTERN MSTATUS CA_MGMT_verifyCertDate(ubyte *pCert, ubyte4 certLen)
Validate a DER-encoded X.509 certificate&#39;s start and expiration times and dates against the current t...
MOC_EXTERN sbyte4 CA_MGMT_extractCertASN1Name(const ubyte *pCertificate, ubyte4 certificateLength, sbyte4 isSubject, sbyte4 includeASN1SeqHeader, ubyte4 *pASN1NameOffset, ubyte4 *pASN1NameLen)
Get an X.509 certificate&#39;s subject or issuer DER-encoded ASN.1 name.
byteBoolean isCritical
TRUE if extension is critical; otherwise FALSE.
Definition: ca_mgmt.h:517
MOC_EXTERN sbyte4 CA_MGMT_generateNakedKey(ubyte4 keyType, ubyte4 keySize, ubyte **ppRetNewKeyBlob, ubyte4 *pRetNewKeyBlobLength)
Generate a naked key.
MOC_EXTERN sbyte4 CA_MGMT_freeNakedKey(ubyte **ppFreeKeyBlob)
Free (release) a naked key blob&#39;s memory.
const ubyte * oid
AttributeType: attribute&#39;s OID (object identifier).
Definition: ca_mgmt.h:307
MOC_EXTERN sbyte4 CA_MGMT_extractBasicConstraint(ubyte *pCertificate, ubyte4 certificateLen, intBoolean *pIsCritical, certExtensions *pCertExtensions)
Get the BasicConstraints extension out of a cert.
ubyte * pKeyBlob
Pointer to key blob value.
Definition: ca_mgmt.h:199
ubyte * pCertificate
Pointer to DER-encoded X.509 certificate.
Definition: ca_mgmt.h:187
sbyte certPathLen
Number of certificates in the certificate chain; if negative, it&#39;s omitted from the basicConstraints...
Definition: ca_mgmt.h:588
MOC_EXTERN sbyte4 CA_MGMT_decodeCertificate(ubyte *pKeyFile, ubyte4 fileSize, ubyte **ppDecodeFile, ubyte4 *pDecodedLength)
Convert PEM-encoded certificate to DER-encoded certificate.
ubyte * value
DER-encoded extension value.
Definition: ca_mgmt.h:539
MOC_EXTERN sbyte4 CA_MGMT_freeCertificate(certDescriptor *pRetCertificateDescr)
Free memory allocated by CA_MGMT_generateCertificate().
MOC_EXTERN sbyte4 CA_MGMT_convertPKCS8KeyToKeyBlob(const ubyte *pPKCS8DER, ubyte4 pkcs8DERLen, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength)
Convert unprotected RSA private key to a Digicert SoT Platform private RSA keyblob.
MOC_EXTERN sbyte4 CA_MGMT_verifyCertWithKeyBlob(certDescriptor *pCertificateDescr, sbyte4 *pIsGood)
Verify correspondence of a certDescriptor key blob and certificate&#39;s key.
ubyte4 keyBlobLength
Number of bytes in pKeyBlob.
Definition: ca_mgmt.h:205