x509_cert_parse.h
Go to the documentation of this file.
1 /**
2  * @file x509_cert_parse.h
3  * @brief X.509 certificate parsing
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_PARSE_H
32 #define _X509_CERT_PARSE_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 x509ParseCertificate(const uint8_t *data, size_t length,
45  X509CertInfo *certInfo);
46 
47 error_t x509ParseCertificateEx(const uint8_t *data, size_t length,
48  X509CertInfo *certInfo, bool_t ignoreUnknown);
49 
50 error_t x509ParseTbsCertificate(const uint8_t *data, size_t length,
51  size_t *totalLength, X509TbsCertificate *tbsCert, bool_t ignoreUnknown);
52 
53 error_t x509ParseVersion(const uint8_t *data, size_t length,
54  size_t *totalLength, X509Version *version);
55 
56 error_t x509ParseSerialNumber(const uint8_t *data, size_t length,
57  size_t *totalLength, X509SerialNumber *serialNumber);
58 
59 error_t x509ParseIssuerUniqueId(const uint8_t *data, size_t length,
60  size_t *totalLength);
61 
62 error_t x509ParseSubjectUniqueId(const uint8_t *data, size_t length,
63  size_t *totalLength);
64 
65 error_t x509ParseName(const uint8_t *data, size_t length,
66  size_t *totalLength, X509Name *name);
67 
68 error_t x509ParseNameAttribute(const uint8_t *data, size_t length,
69  size_t *totalLength, X509NameAttribute *nameAttribute);
70 
71 error_t x509ParseGeneralNames(const uint8_t *data, size_t length,
72  X509GeneralName *generalNames, uint_t maxGeneralNames,
73  uint_t *numGeneralNames);
74 
75 error_t x509ParseGeneralName(const uint8_t *data, size_t length,
76  size_t *totalLength, X509GeneralName *generalName);
77 
78 error_t x509ParseGeneralSubtrees(const uint8_t *data, size_t length);
79 
80 error_t x509ParseGeneralSubtree(const uint8_t *data, size_t length,
81  size_t *totalLength, X509GeneralName *generalName);
82 
83 error_t x509ParseValidity(const uint8_t *data, size_t length,
84  size_t *totalLength, X509Validity *validity);
85 
86 error_t x509ParseTime(const uint8_t *data, size_t length,
87  size_t *totalLength, DateTime *dateTime);
88 
89 error_t x509ParseInt(const uint8_t *data, size_t length, uint_t *value);
90 
91 //C++ guard
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif
X.509 common definitions.
error_t x509ParseVersion(const uint8_t *data, size_t length, size_t *totalLength, X509Version *version)
Parse Version field.
int bool_t
Definition: compiler_port.h:53
TBSCertificate structure.
Definition: x509_common.h:1053
Validity.
Definition: x509_common.h:715
error_t x509ParseTime(const uint8_t *data, size_t length, size_t *totalLength, DateTime *dateTime)
Parse UTCTime or GeneralizedTime field.
error_t x509ParseIssuerUniqueId(const uint8_t *data, size_t length, size_t *totalLength)
Parse IssuerUniqueID structure.
uint8_t data[]
Definition: ethernet.h:222
error_t x509ParseCertificateEx(const uint8_t *data, size_t length, X509CertInfo *certInfo, bool_t ignoreUnknown)
Parse a X.509 certificate.
char_t name[]
uint16_t totalLength
Definition: ipv4.h:322
uint8_t version
Definition: coap_common.h:177
error_t x509ParseTbsCertificate(const uint8_t *data, size_t length, size_t *totalLength, X509TbsCertificate *tbsCert, bool_t ignoreUnknown)
Parse TBSCertificate structure.
error_t x509ParseCertificate(const uint8_t *data, size_t length, X509CertInfo *certInfo)
Parse a X.509 certificate.
General name.
Definition: x509_common.h:859
X.509 certificate.
Definition: x509_common.h:1071
error_t
Error codes.
Definition: error.h:43
Name attribute.
Definition: x509_common.h:703
error_t x509ParseGeneralNames(const uint8_t *data, size_t length, X509GeneralName *generalNames, uint_t maxGeneralNames, uint_t *numGeneralNames)
Parse GeneralNames field.
X509Version
X.509 versions.
Definition: x509_common.h:465
error_t x509ParseSerialNumber(const uint8_t *data, size_t length, size_t *totalLength, X509SerialNumber *serialNumber)
Parse SerialNumber field.
error_t x509ParseGeneralSubtree(const uint8_t *data, size_t length, size_t *totalLength, X509GeneralName *generalName)
Parse GeneralSubtree field.
error_t x509ParseSubjectUniqueId(const uint8_t *data, size_t length, size_t *totalLength)
Parse SubjectUniqueID structure.
General definitions for cryptographic algorithms.
error_t x509ParseGeneralSubtrees(const uint8_t *data, size_t length)
Parse GeneralSubtrees field.
Date and time representation.
Definition: date_time.h:47
error_t x509ParseName(const uint8_t *data, size_t length, size_t *totalLength, X509Name *name)
Parse Name structure.
uint8_t length
Definition: tcp.h:368
error_t x509ParseNameAttribute(const uint8_t *data, size_t length, size_t *totalLength, X509NameAttribute *nameAttribute)
Parse name attribute.
error_t x509ParseValidity(const uint8_t *data, size_t length, size_t *totalLength, X509Validity *validity)
Parse Validity structure.
Issuer or subject name.
Definition: x509_common.h:675
uint8_t value[]
Definition: tcp.h:369
error_t x509ParseGeneralName(const uint8_t *data, size_t length, size_t *totalLength, X509GeneralName *generalName)
Parse GeneralName field.
Serial number.
Definition: x509_common.h:664
unsigned int uint_t
Definition: compiler_port.h:50
error_t x509ParseInt(const uint8_t *data, size_t length, uint_t *value)
Convert string to integer.