x509_cert_format.c File Reference

X.509 certificate formatting. More...

#include "core/crypto.h"
#include "pkix/x509_cert_format.h"
#include "pkix/x509_cert_ext_format.h"
#include "pkix/x509_key_format.h"
#include "pkix/x509_sign_format.h"
#include "encoding/asn1.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 x509FormatTbsCertificate (const PrngAlgo *prngAlgo, void *prngContext, const X509SerialNumber *serialNumber, const X509SignAlgoId *signatureAlgo, const X509Name *issuer, const X509Validity *validity, const X509Name *subject, const X509SubjectPublicKeyInfo *subjectPublicKeyInfo, const void *publicKey, const X509Extensions *extensions, const X509AuthKeyId *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 (const X509NameAttribute *nameAttribute, 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...
 

Detailed Description

X.509 certificate formatting.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file x509_cert_format.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file x509_cert_format.c.

Function Documentation

◆ x509FormatName()

error_t x509FormatName ( const X509Name name,
uint8_t *  output,
size_t *  written 
)

Format Name structure.

Parameters
[in]nameInformation about the name to be encoded
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 306 of file x509_cert_format.c.

◆ x509FormatNameAttribute()

error_t x509FormatNameAttribute ( const X509NameAttribute nameAttribute,
uint8_t *  output,
size_t *  written 
)

Format name attribute.

Parameters
[in]nameAttributeName attribute
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 510 of file x509_cert_format.c.

◆ x509FormatSerialNumber()

error_t x509FormatSerialNumber ( const PrngAlgo prngAlgo,
void *  prngContext,
const X509SerialNumber serialNumber,
uint8_t *  output,
size_t *  written 
)

Format SerialNumber field.

Parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]serialNumberPointer to the serial number (optional parameter)
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 246 of file x509_cert_format.c.

◆ x509FormatTbsCertificate()

error_t x509FormatTbsCertificate ( const PrngAlgo prngAlgo,
void *  prngContext,
const X509SerialNumber serialNumber,
const X509SignAlgoId signatureAlgo,
const X509Name issuer,
const X509Validity validity,
const X509Name subject,
const X509SubjectPublicKeyInfo subjectPublicKeyInfo,
const void *  publicKey,
const X509Extensions extensions,
const X509AuthKeyId authKeyId,
uint8_t *  output,
size_t *  written 
)

Format TBSCertificate structure.

Parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]serialNumberSerial number
[in]signatureAlgoSignature algorithm
[in]issuerIssuer's name
[in]validityValidity period
[in]subjectSubject's name
[in]subjectPublicKeyInfoSubject's public key information
[in]publicKeySubject's public key
[in]extensionsX.509 certificates extensions
[in]authKeyIdAuthorityKeyIdentifier extension
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 66 of file x509_cert_format.c.

◆ x509FormatTime()

error_t x509FormatTime ( const DateTime dateTime,
uint8_t *  output,
size_t *  written 
)

Format UTCTime or GeneralizedTime field.

Parameters
[in]dateTimeDate to be encoded
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 663 of file x509_cert_format.c.

◆ x509FormatValidity()

error_t x509FormatValidity ( const X509Validity validity,
uint8_t *  output,
size_t *  written 
)

Format Validity structure.

Parameters
[in]validityValidity period
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 600 of file x509_cert_format.c.

◆ x509FormatVersion()

error_t x509FormatVersion ( X509Version  version,
uint8_t *  output,
size_t *  written 
)

Format Version field.

Parameters
[in]versionVersion number
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 202 of file x509_cert_format.c.