x509_cert_format.h
Go to the documentation of this file.
1 /**
2  * @file x509_cert_format.h
3  * @brief X.509 certificate formatting
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _X509_CERT_FORMAT_H
32 #define _X509_CERT_FORMAT_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkix/x509_common.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //X.509 related functions
44 error_t x509FormatTbsCertificate(const PrngAlgo *prngAlgo, void *prngContext,
45  const X509SerialNumber *serialNumber, const X509SignAlgoId *signatureAlgo,
46  const X509Name *issuer, const X509Validity *validity, const X509Name *subject,
47  const X509SubjectPublicKeyInfo *subjectPublicKeyInfo, const void *publicKey,
48  const X509Extensions *extensions, const X509AuthKeyId *authKeyId,
49  uint8_t *output, size_t *written);
50 
52  size_t *written);
53 
54 error_t x509FormatSerialNumber(const PrngAlgo *prngAlgo, void *prngContext,
55  const X509SerialNumber *serialNumber, uint8_t *output, size_t *written);
56 
57 error_t x509FormatName(const X509Name *name, uint8_t *output, size_t *written);
58 
60  uint8_t *output, size_t *written);
61 
62 error_t x509FormatValidity(const X509Validity *validity, uint8_t *output,
63  size_t *written);
64 
65 error_t x509FormatTime(const DateTime *dateTime, uint8_t *output,
66  size_t *written);
67 
68 //C++ guard
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif
X.509 common definitions.
uint8_t extensions[]
Definition: ntp_common.h:207
#define PrngAlgo
Definition: crypto.h:938
Validity.
Definition: x509_common.h:715
char_t name[]
uint8_t version
Definition: coap_common.h:177
error_t x509FormatVersion(X509Version version, uint8_t *output, size_t *written)
Format Version field.
error_t x509FormatNameAttribute(const X509NameAttribute *nameAttribute, uint8_t *output, size_t *written)
Format name attribute.
error_t
Error codes.
Definition: error.h:43
Name attribute.
Definition: x509_common.h:703
X509Version
X.509 versions.
Definition: x509_common.h:465
Authority Key Identifier extension.
Definition: x509_common.h:896
General definitions for cryptographic algorithms.
Date and time representation.
Definition: date_time.h:47
error_t x509FormatSerialNumber(const PrngAlgo *prngAlgo, void *prngContext, const X509SerialNumber *serialNumber, uint8_t *output, size_t *written)
Format SerialNumber field.
Issuer or subject name.
Definition: x509_common.h:675
Subject Public Key Information extension.
Definition: x509_common.h:790
X.509 certificate extensions.
Definition: x509_common.h:1003
error_t x509FormatValidity(const X509Validity *validity, uint8_t *output, size_t *written)
Format Validity structure.
Serial number.
Definition: x509_common.h:664
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.
error_t x509FormatName(const X509Name *name, uint8_t *output, size_t *written)
Format Name structure.
Signature algorithm identifier.
Definition: x509_common.h:1040
error_t x509FormatTime(const DateTime *dateTime, uint8_t *output, size_t *written)
Format UTCTime or GeneralizedTime field.