X.509 certificate generation. More...
#include "core/crypto.h"
#include "pkix/x509_cert_create.h"
#include "pkix/x509_key_format.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "ecc/ecdsa.h"
#include "ecc/eddsa.h"
#include "ecc/ed25519.h"
#include "ecc/ed448.h"
#include "hash/sha1.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Functions | |
error_t | x509CreateCertificate (const PrngAlgo *prngAlgo, void *prngContext, const X509CertRequestInfo *certReqInfo, const void *subjectPublicKey, const X509CertificateInfo *issuerCertInfo, const X509SerialNumber *serialNumber, const X509Validity *validity, const X509SignatureAlgoId *signatureAlgo, const void *signerPrivateKey, uint8_t *output, size_t *written) |
Generate a X.509 certificate. More... | |
error_t | x509FormatTbsCertificate (const PrngAlgo *prngAlgo, void *prngContext, const X509SerialNumber *serialNumber, const X509SignatureAlgoId *signatureAlgo, const X509Name *issuer, const X509Validity *validity, const X509Name *subject, const X509SubjectPublicKeyInfo *subjectPublicKeyInfo, const void *publicKey, const X509Extensions *extensions, const X509AuthorityKeyId *authKeyId, uint8_t *output, size_t *written) |
Format TBSCertificate structure. More... | |
error_t | x509FormatVersion (X509Version version, uint8_t *output, size_t *written) |
Format Version field. More... | |
error_t | x509FormatSerialNumber (const PrngAlgo *prngAlgo, void *prngContext, const X509SerialNumber *serialNumber, uint8_t *output, size_t *written) |
Format SerialNumber field. More... | |
error_t | x509FormatName (const X509Name *name, uint8_t *output, size_t *written) |
Format Name structure. More... | |
error_t | x509FormatNameAttribute (uint_t type, const uint8_t *oid, size_t oidLen, const char_t *value, size_t valueLen, uint8_t *output, size_t *written) |
Format Name attribute. More... | |
error_t | x509FormatValidity (const X509Validity *validity, uint8_t *output, size_t *written) |
Format Validity structure. More... | |
error_t | x509FormatTime (const DateTime *dateTime, uint8_t *output, size_t *written) |
Format UTCTime or GeneralizedTime field. More... | |
error_t | x509FormatExtensions (const X509Extensions *extensions, const X509SubjectKeyId *subjectKeyId, const X509AuthorityKeyId *authKeyId, uint8_t *output, size_t *written) |
Format Extensions structure. More... | |
error_t | x509FormatBasicConstraints (const X509BasicConstraints *basicConstraints, uint8_t *output, size_t *written) |
Format BasicConstraints extension. More... | |
error_t | x509FormatKeyUsage (const X509KeyUsage *keyUsage, uint8_t *output, size_t *written) |
Format KeyUsage extension. More... | |
error_t | x509FormatSubjectAltName (const X509SubjectAltName *subjectAltName, uint8_t *output, size_t *written) |
Format SubjectAltName extension. More... | |
error_t | x509FormatSubjectKeyId (const X509SubjectKeyId *subjectKeyId, uint8_t *output, size_t *written) |
Format SubjectKeyIdentifier extension. More... | |
error_t | x509FormatAuthorityKeyId (const X509AuthorityKeyId *authKeyId, uint8_t *output, size_t *written) |
Format AuthorityKeyIdentifier extension. More... | |
error_t | x509FormatNsCertType (const X509NsCertType *nsCertType, uint8_t *output, size_t *written) |
Format NetscapeCertType extension. More... | |
error_t | x509FormatSignatureAlgo (const X509SignatureAlgoId *signatureAlgo, uint8_t *output, size_t *written) |
Format SignatureAlgorithm structure. More... | |
error_t | x509FormatSignatureValue (const PrngAlgo *prngAlgo, void *prngContext, const uint8_t *tbsCert, size_t tbsCertLen, const X509SignatureAlgoId *signatureAlgoId, const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey, uint8_t *output, size_t *written) |
Format SignatureValue field. More... | |
error_t | x509GenerateSignature (const PrngAlgo *prngAlgo, void *prngContext, const uint8_t *tbsCert, size_t tbsCertLen, const X509SignatureAlgoId *signatureAlgoId, const X509SubjectPublicKeyInfo *publicKeyInfo, const void *privateKey, uint8_t *output, size_t *written) |
Certificate signature generation. More... | |
X.509 certificate generation.
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneCrypto Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Definition in file x509_cert_create.c.
#define TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Definition at line 32 of file x509_cert_create.c.
error_t x509CreateCertificate | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const X509CertRequestInfo * | certReqInfo, | ||
const void * | subjectPublicKey, | ||
const X509CertificateInfo * | issuerCertInfo, | ||
const X509SerialNumber * | serialNumber, | ||
const X509Validity * | validity, | ||
const X509SignatureAlgoId * | signatureAlgo, | ||
const void * | signerPrivateKey, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Generate a X.509 certificate.
[in] | prngAlgo | PRNG algorithm |
[in] | prngContext | Pointer to the PRNG context |
[in] | certReqInfo | Certificate request information |
[in] | subjectPublicKey | Subject's public key (optional parameter) |
[in] | issuerCertInfo | Issuer's certificate (optional parameter) |
[in] | serialNumber | Serial number (optional parameter) |
[in] | validity | Validity period |
[in] | signatureAlgo | Signature algorithm |
[in] | signerPrivateKey | Pointer to the issuer's private key |
[out] | output | Buffer where to store the X.509 certificate |
[out] | written | Length of the resulting X.509 certificate |
Definition at line 69 of file x509_cert_create.c.
error_t x509FormatAuthorityKeyId | ( | const X509AuthorityKeyId * | authKeyId, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format AuthorityKeyIdentifier extension.
[in] | authKeyId | Value of the extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1495 of file x509_cert_create.c.
error_t x509FormatBasicConstraints | ( | const X509BasicConstraints * | basicConstraints, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format BasicConstraints extension.
[in] | basicConstraints | Value of the extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 965 of file x509_cert_create.c.
error_t x509FormatExtensions | ( | const X509Extensions * | extensions, |
const X509SubjectKeyId * | subjectKeyId, | ||
const X509AuthorityKeyId * | authKeyId, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format Extensions structure.
[in] | extensions | Pointer to the X.509 extensions |
[in] | subjectKeyId | SubjectKeyIdentifier extension |
[in] | authKeyId | AuthorityKeyIdentifier extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 844 of file x509_cert_create.c.
error_t x509FormatKeyUsage | ( | const X509KeyUsage * | keyUsage, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format KeyUsage extension.
[in] | keyUsage | Value of the extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1128 of file x509_cert_create.c.
Format Name structure.
[in] | name | Information about the name to be encoded |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 468 of file x509_cert_create.c.
error_t x509FormatNameAttribute | ( | uint_t | type, |
const uint8_t * | oid, | ||
size_t | oidLen, | ||
const char_t * | value, | ||
size_t | valueLen, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format Name attribute.
[in] | type | ASN.1 string type |
[in] | oid | Attribute OID |
[in] | oidLen | Length of the attribute OID, in bytes |
[in] | value | Attribute value |
[in] | valueLen | Length of the attribute value, in bytes |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 625 of file x509_cert_create.c.
error_t x509FormatNsCertType | ( | const X509NsCertType * | nsCertType, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format NetscapeCertType extension.
[in] | nsCertType | Value of the extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1605 of file x509_cert_create.c.
error_t x509FormatSerialNumber | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const X509SerialNumber * | serialNumber, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SerialNumber field.
[in] | prngAlgo | PRNG algorithm |
[in] | prngContext | Pointer to the PRNG context |
[in] | serialNumber | Pointer to the serial number (optional parameter) |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 408 of file x509_cert_create.c.
error_t x509FormatSignatureAlgo | ( | const X509SignatureAlgoId * | signatureAlgo, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SignatureAlgorithm structure.
[in] | signatureAlgo | Pointer to the SignatureAlgorithm structure |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1714 of file x509_cert_create.c.
error_t x509FormatSignatureValue | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const uint8_t * | tbsCert, | ||
size_t | tbsCertLen, | ||
const X509SignatureAlgoId * | signatureAlgoId, | ||
const X509SubjectPublicKeyInfo * | publicKeyInfo, | ||
const void * | privateKey, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SignatureValue field.
[in] | prngAlgo | PRNG algorithm |
[in] | prngContext | Pointer to the PRNG context |
[in] | tbsCert | Pointer to the TBSCertificate to be signed |
[in] | tbsCertLen | Length of the TBSCertificate, in bytes |
[in] | signatureAlgoId | Signature algorithm identifier |
[in] | publicKeyInfo | Signer's public key information |
[in] | privateKey | Signer's private key |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1868 of file x509_cert_create.c.
error_t x509FormatSubjectAltName | ( | const X509SubjectAltName * | subjectAltName, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SubjectAltName extension.
[in] | subjectAltName | Value of the extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1274 of file x509_cert_create.c.
error_t x509FormatSubjectKeyId | ( | const X509SubjectKeyId * | subjectKeyId, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SubjectKeyIdentifier extension.
[in] | subjectKeyId | Value of the extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 1398 of file x509_cert_create.c.
error_t x509FormatTbsCertificate | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const X509SerialNumber * | serialNumber, | ||
const X509SignatureAlgoId * | signatureAlgo, | ||
const X509Name * | issuer, | ||
const X509Validity * | validity, | ||
const X509Name * | subject, | ||
const X509SubjectPublicKeyInfo * | subjectPublicKeyInfo, | ||
const void * | publicKey, | ||
const X509Extensions * | extensions, | ||
const X509AuthorityKeyId * | authKeyId, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format TBSCertificate structure.
[in] | prngAlgo | PRNG algorithm |
[in] | prngContext | Pointer to the PRNG context |
[in] | serialNumber | Serial number |
[in] | signatureAlgo | Signature algorithm |
[in] | issuer | Issuer's name |
[in] | validity | Validity period |
[in] | subject | Subject's name |
[in] | subjectPublicKeyInfo | Subject's public key information |
[in] | publicKey | Subject's public key |
[in] | extensions | X.509 certificates extensions |
[in] | authKeyId | AuthorityKeyIdentifier extension |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 228 of file x509_cert_create.c.
Format UTCTime or GeneralizedTime field.
[in] | dateTime | Date to be encoded |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 778 of file x509_cert_create.c.
error_t x509FormatValidity | ( | const X509Validity * | validity, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format Validity structure.
[in] | validity | Validity period |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 715 of file x509_cert_create.c.
error_t x509FormatVersion | ( | X509Version | version, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format Version field.
[in] | version | Version number |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 364 of file x509_cert_create.c.
error_t x509GenerateSignature | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const uint8_t * | tbsCert, | ||
size_t | tbsCertLen, | ||
const X509SignatureAlgoId * | signatureAlgoId, | ||
const X509SubjectPublicKeyInfo * | publicKeyInfo, | ||
const void * | privateKey, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Certificate signature generation.
[in] | prngAlgo | PRNG algorithm |
[in] | prngContext | Pointer to the PRNG context |
[in] | tbsCert | Pointer to the TBSCertificate to be signed |
[in] | tbsCertLen | Length of the TBSCertificate, in bytes |
[in] | signatureAlgoId | Signature algorithm identifier |
[in] | publicKeyInfo | Signer's public key information |
[in] | privateKey | Signer's private key |
[out] | output | Resulting signature |
[out] | written | Length of the resulting signature |
Definition at line 1924 of file x509_cert_create.c.