![]() |
TrustCore SDK NanoCert API reference
version 7.0
|
Header file for ASN.1 Certificate Encoding methods. More...
Go to the source code of this file.
Functions | |
MOC_EXTERN MSTATUS | ASN1CERT_AddExtensions (DER_ITEMPTR pExtensionTag, const certExtensions *pExtensions, DER_ITEMPTR *ppExtsItem) |
Writes the extensions to a certificate in the process of being generated. More... | |
MOC_EXTERN MSTATUS | ASN1CERT_generateCertificate (MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey *pCertKey, const certDistinguishedName *pSubjectInfo, const AsymmetricKey *pSignKey, const ASN1_ITEM *pIssuerInfo, CStream cs, ubyte signAlgo, const certExtensions *pExtensions, RNGFun rngFun, void *rngFunArg, ubyte **ppRetCertificate, ubyte4 *pRetCertLength) |
Generate a certificate with the given input key, signing key, name, issuer, and extensions. More... | |
MOC_EXTERN MSTATUS | ASN1CERT_generateCertificateEx (MOC_ASYM(hwAccelDescr hwAccelCtx) const AsymmetricKey *pCertKey, const certDistinguishedName *pSubjectInfo, const AsymmetricKey *pSignKey, const ASN1_ITEM *pIssuerInfo, CStream cs, const ubyte *serialNumber, ubyte4 serialNumberLen, ubyte signAlgo, const certExtensions *pExtensions, RNGFun rngFun, void *rngFunArg, ubyte **ppRetCertificate, ubyte4 *pRetCertLength) |
Generate a certificate with the given input key, signing key, name, issuer, and extensions. More... | |
MOC_EXTERN MSTATUS | ASN1CERT_generateSelfSignedCertificate (MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey *pCertKey, const certDistinguishedName *pSubjectInfo, ubyte signAlgo, const certExtensions *pExtensions, RNGFun rngFun, void *rngFunArg, ubyte **ppRetCertificate, ubyte4 *pRetCertLength) |
Generate a self-signed certificate with the given key, name, and extensions. More... | |
MOC_EXTERN MSTATUS | ASN1CERT_Sign (MOC_ASYM(hwAccelDescr hwAccelCtx) DER_ITEMPTR pSignedHead, const AsymmetricKey *pSignKey, ubyte signAlgo, RNGFun rngFun, void *rngFunArg, ubyte **ppRetDEREncoding, ubyte4 *pRetDEREncodingLen) |
Signs a certificate with a given asymmetric key. More... | |
MOC_EXTERN MSTATUS | ASN1CERT_StoreDistinguishedName (DER_ITEMPTR pRoot, const certDistinguishedName *pCertInfo) |
Writes the distinguished name components to a certificate in the process of being generated. More... | |
MOC_EXTERN MSTATUS | ASN1CERT_storePublicKeyInfo (MOC_ASYM(hwAccelDescr hwAccelCtx) const AsymmetricKey *pPublicKey, DER_ITEMPTR pCertificate) |
Writes the public key information to a certificate in the process of being generated. More... | |
Header file for ASN.1 Certificate Encoding methods.
MOC_EXTERN MSTATUS ASN1CERT_AddExtensions | ( | DER_ITEMPTR | pExtensionTag, |
const certExtensions * | pExtensions, | ||
DER_ITEMPTR * | ppExtsItem | ||
) |
Writes the extensions to a certificate in the process of being generated. This method should be used as a substep in certificate generation and should not be used on an already generated certificate. This method will NOT overwrite previously existing extensions.
pExtensionTag | Pointer to the item (ie place) in the certificate for where the extensions should be added. |
pExtensions | Pointer to the certificate extensions data structure. The definition of this structure can be found in ca_mgmt.h. |
ppExtsItem | Contents will be set to the location of the new extensions item within the certificate. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS ASN1CERT_generateCertificate | ( | MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey * | pCertKey, |
const certDistinguishedName * | pSubjectInfo, | ||
const AsymmetricKey * | pSignKey, | ||
const ASN1_ITEM * | pIssuerInfo, | ||
CStream | cs, | ||
ubyte | signAlgo, | ||
const certExtensions * | pExtensions, | ||
RNGFun | rngFun, | ||
void * | rngFunArg, | ||
ubyte ** | ppRetCertificate, | ||
ubyte4 * | pRetCertLength | ||
) |
Generate a certificate with the given input key, signing key, name, issuer, and extensions. The certificate will be in DER form. Memory will be allocated for the buffer holding the generated certificate. Please be sure to free this buffer when done with it.
pCertKey | The input key to associate with the certificate. |
pSubjectInfo | Pointer to the certificate distinguished name structure. The definition of this structure can be found in ca_mgmt.h. |
pSignKey | The signing key. The signing algorithm will coincide with the key type. |
pIssuerInfo | Optional. Pointer to the issuer of the certificate in ASN1_ITEM form. Please see parseasn1.h for a description of this form. This may be ommitted for self signed certificates. |
cs | Content stream to be used for the pIssuerInfo. This is required if pIssuerInfo is non-null. |
signAlgo | If needed, the hashing algorithm to be used in the signature algorithm. This is one of the hash enum's found in crypto.h, for example ht_sha256 . Pass ht_none if the signing algorithm is EdDSA. |
pExtensions | Pointer to the certificate extensions data structure. The definition of this structure can be found in ca_mgmt.h. |
rngFun | If needed by the signing algorithm, function pointer to a method that will output random data. Please see the RNGFun definition in random.h. |
rngFunArg | Optional argument, such as a random context, that may be needed by the rngFun. |
ppRetCertificate | Pointer to the location of the newly allocated buffer holding the generated certificate. This will be a DER form certicicate. |
pRetCertLength | The length of the generated certificate in bytes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS ASN1CERT_generateCertificateEx | ( | MOC_ASYM(hwAccelDescr hwAccelCtx) const AsymmetricKey * | pCertKey, |
const certDistinguishedName * | pSubjectInfo, | ||
const AsymmetricKey * | pSignKey, | ||
const ASN1_ITEM * | pIssuerInfo, | ||
CStream | cs, | ||
const ubyte * | serialNumber, | ||
ubyte4 | serialNumberLen, | ||
ubyte | signAlgo, | ||
const certExtensions * | pExtensions, | ||
RNGFun | rngFun, | ||
void * | rngFunArg, | ||
ubyte ** | ppRetCertificate, | ||
ubyte4 * | pRetCertLength | ||
) |
Generate a certificate with the given input key, signing key, name, issuer, and extensions. The certificate will be in DER form. Memory will be allocated for the buffer holding the generated certificate. Please be sure to free this buffer when done with it.
pCertKey | The input key to associate with the certificate. |
pSubjectInfo | Pointer to the certificate distinguished name structure. The definition of this structure can be found in ca_mgmt.h. |
pSignKey | The signing key. The signing algorithm will coincide with the key type. |
pIssuerInfo | Optional. Pointer to the issuer of the certificate in ASN1_ITEM form. Please see parseasn1.h for a description of this form. This may be ommitted for self signed certificates. |
cs | Content stream to be used for the pIssuerInfo. This is required if pIssuerInfo is non-null. |
serialNumber | Optional. Serial number to be used in the certificate. If not provided then it will be generated by a SHA1 hashing of the public key. |
serialNumberLen | The length of the serial number in bytes. |
signAlgo | If needed, the hashing algorithm to be used in the signature algorithm. This is one of the hash enum's found in crypto.h, for example ht_sha256 . Pass ht_none if the signing algorithm is EdDSA. |
pExtensions | Pointer to the certificate extensions data structure. The definition of this structure can be found in ca_mgmt.h. |
rngFun | If needed by the signing algorithm, function pointer to a method that will output random data. Please see the RNGFun definition in random.h. |
rngFunArg | Optional argument, such as a random context, that may be needed by the rngFun. |
ppRetCertificate | Pointer to the location of the newly allocated buffer holding the generated certificate. This will be a DER form certicicate. |
pRetCertLength | The length of the generated certificate in bytes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS ASN1CERT_generateSelfSignedCertificate | ( | MOC_ASYM(hwAccelDescr hwAccelCtx) AsymmetricKey * | pCertKey, |
const certDistinguishedName * | pSubjectInfo, | ||
ubyte | signAlgo, | ||
const certExtensions * | pExtensions, | ||
RNGFun | rngFun, | ||
void * | rngFunArg, | ||
ubyte ** | ppRetCertificate, | ||
ubyte4 * | pRetCertLength | ||
) |
Generate a self-signed certificate with the given key, name, and extensions. The certificate will be in DER form. Memory will be allocated for the buffer holding the generated certificate. Please be sure to free this buffer when done with it.
pCertKey | The input key to associate with the certificate and the signing key. The signing algorithm will coincide with the key type. |
pSubjectInfo | Pointer to the certificate distinguished name structure. The definition of this structure can be found in ca_mgmt.h. |
signAlgo | If needed, the hashing algorithm to be used in the signature algorithm. This is one of the hash enum's found in crypto.h, for example ht_sha256 . Pass ht_none if the signing algorithm is EdDSA. |
pExtensions | Pointer to the certificate extensions data structure. The definition of this structure can be found in ca_mgmt.h. |
rngFun | If needed by the signing algorithm, function pointer to a method that will output random data. Please see the RNGFun definition in random.h. |
rngFunArg | Optional argument, such as a random context, that may be needed by the rngFun. |
ppRetCertificate | Pointer to the location of the newly allocated buffer holding the generated certificate. This will be a DER form certicicate. |
pRetCertLength | The length of the generated certificate in bytes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS ASN1CERT_Sign | ( | MOC_ASYM(hwAccelDescr hwAccelCtx) DER_ITEMPTR | pSignedHead, |
const AsymmetricKey * | pSignKey, | ||
ubyte | signAlgo, | ||
RNGFun | rngFun, | ||
void * | rngFunArg, | ||
ubyte ** | ppRetDEREncoding, | ||
ubyte4 * | pRetDEREncodingLen | ||
) |
Signs a certificate with a given asymmetric key. The input certificate is a DER_ITEMPTR
pointing to the root of what will be the signed certificate. The output will be the full signed certificate in DER form. Memory will be allocated for the buffer holding output certificate. Please be sure to free this buffer when done with it.
pSignedHead | Pointer to the root of what will be the signed certificate. |
pSignKey | The signing key. The signing algorithm will coincide with the key type. |
signAlgo | If needed, the hashing algorithm to be used in the signature algorithm. This is one of the hash enum's found in crypto.h, for example ht_sha256 . Pass ht_none if the signing algorithm is EdDSA. |
rngFun | If needed by the signing algorithm, function pointer to a method that will output random data. Please see the RNGFun definition in random.h. |
rngFunArg | Optional argument, such as a random context, that may be needed by the rngFun. |
ppRetDEREncoding | Pointer to the location of the newly allocated buffer holding the signed certificate. This will be a DER form certicicate. |
pRetDEREncodingLen | The length of the signed certificate in bytes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS ASN1CERT_StoreDistinguishedName | ( | DER_ITEMPTR | pRoot, |
const certDistinguishedName * | pCertInfo | ||
) |
Writes all the distinguished name components to a certificate in the process of being generated. This method should be used as a substep in certificate generation and should not be used on an already generated certificate. This method will NOT overwrite previously existing distinguished name components.
pRoot | Pointer to the root of the certificate. This is the root of the certificate before it is signed and before it has any distinguished name components. |
pCertInfo | The certificate distinguished name structure. The definition of this structure can be found in ca_mgmt.h. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS ASN1CERT_storePublicKeyInfo | ( | MOC_ASYM(hwAccelDescr hwAccelCtx) const AsymmetricKey * | pPublicKey, |
DER_ITEMPTR | pCertificate | ||
) |
Writes the public key information to a certificate in the process of being generated. This method should be used as a substep in certificate generation and should not be used on an already generated certificate. This method will NOT overwrite previously existing public key information.
pPublicKey | Pointer to the public key to be written. |
pCertificate | Pointer to the certificate to which we are generating. This is the root of the certificate before it is signed and before it has any public key information. |
OK
(0) if successful, otherwise a negative number error code from merrors.h.