x509_cert_ext_parse.h
Go to the documentation of this file.
1 /**
2  * @file x509_cert_ext_parse.h
3  * @brief X.509 extension 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_EXT_PARSE_H
32 #define _X509_CERT_EXT_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 x509ParseCertExtensions(const uint8_t *data, size_t length,
45  size_t *totalLength, X509Extensions *extensions, bool_t ignoreUnknown);
46 
47 error_t x509ParseExtension(const uint8_t *data, size_t length,
48  size_t *totalLength, X509Extension *extension);
49 
51  size_t length, X509BasicConstraints *basicConstraints);
52 
54  size_t length, X509NameConstraints *nameConstraints);
55 
57  size_t length);
58 
60  size_t length);
61 
63  size_t length);
64 
66  size_t length, X509KeyUsage *keyUsage);
67 
69  size_t length, X509ExtendedKeyUsage *extKeyUsage);
70 
72  size_t length, X509SubjectAltName *subjectAltName);
73 
75  size_t length, X509SubjectKeyId *subjectKeyId);
76 
78  size_t length, X509AuthKeyId *authKeyId);
79 
81  size_t length, X509CrlDistrPoints *crlDistrPoints);
82 
83 error_t x509ParseDistrPoint(const uint8_t *data, size_t length,
84  size_t *totalLength, X509DistrPoint *distrPoint);
85 
86 error_t x509ParseDistrPointName(const uint8_t *data, size_t length,
87  X509DistrPointName *distrPointName);
88 
89 error_t x509ParseRelativeName(const uint8_t *data, size_t length,
90  X509NameAttribute *relativeName);
91 
92 error_t x509ParseReasonFlags(const uint8_t *data, size_t length,
93  uint16_t *reasonFlags);
94 
96  size_t length, X509AuthInfoAccess *authInfoAccess);
97 
98 error_t x509ParseAccessDescription(const uint8_t *data, size_t length,
99  size_t *totalLength, X509AccessDescription *accessDescription);
100 
102  size_t length, X509PkixOcspNoCheck *pkixOcspNoCheck);
103 
105  size_t length, X509NsCertType *nsCertType);
106 
108  size_t oidLen, bool_t critical, const uint8_t *data, size_t dataLen,
110 
111 error_t x509CheckDuplicateExtension(const uint8_t *oid, size_t oidLen,
112  const uint8_t *data, size_t length);
113 
114 //C++ guard
115 #ifdef __cplusplus
116 }
117 #endif
118 
119 #endif
X.509 common definitions.
uint8_t extensions[]
Definition: ntp_common.h:207
error_t x509ParseBasicConstraints(bool_t critical, const uint8_t *data, size_t length, X509BasicConstraints *basicConstraints)
Parse BasicConstraints extension.
int bool_t
Definition: compiler_port.h:53
error_t x509ParseSubjectAltName(bool_t critical, const uint8_t *data, size_t length, X509SubjectAltName *subjectAltName)
Parse SubjectAltName extension.
error_t x509ParseAuthKeyId(bool_t critical, const uint8_t *data, size_t length, X509AuthKeyId *authKeyId)
Parse AuthorityKeyIdentifier extension.
uint8_t data[]
Definition: ethernet.h:222
error_t x509ParseExtension(const uint8_t *data, size_t length, size_t *totalLength, X509Extension *extension)
Parse X.509 certificate extension.
uint16_t totalLength
Definition: ipv4.h:322
error_t x509ParseDistrPointName(const uint8_t *data, size_t length, X509DistrPointName *distrPointName)
Parse DistributionPointName field.
Subject Key Identifier extension.
Definition: x509_common.h:884
error_t x509ParseKeyUsage(bool_t critical, const uint8_t *data, size_t length, X509KeyUsage *keyUsage)
Parse KeyUsage extension.
uint8_t oid[]
Definition: lldp_tlv.h:300
Distribution Point Name structure.
Definition: x509_common.h:907
Authority Information Access extension.
Definition: x509_common.h:956
error_t
Error codes.
Definition: error.h:43
Name attribute.
Definition: x509_common.h:703
Extended Key Usage extension.
Definition: x509_common.h:848
Distribution Point structure.
Definition: x509_common.h:919
error_t x509ParseReasonFlags(const uint8_t *data, size_t length, uint16_t *reasonFlags)
Parse ReasonFlags field.
X.509 certificate extension.
Definition: x509_common.h:991
Authority Key Identifier extension.
Definition: x509_common.h:896
General definitions for cryptographic algorithms.
PKIX OCSP No Check extension.
Definition: x509_common.h:969
error_t x509ParseUnknownCertExtension(const uint8_t *oid, size_t oidLen, bool_t critical, const uint8_t *data, size_t dataLen, X509Extensions *extensions)
Parse unknown X.509 certificate extension.
error_t x509ParseNsCertType(bool_t critical, const uint8_t *data, size_t length, X509NsCertType *nsCertType)
Parse NetscapeCertType extension.
uint8_t length
Definition: tcp.h:368
error_t x509ParsePkixOcspNoCheck(bool_t critical, const uint8_t *data, size_t length, X509PkixOcspNoCheck *pkixOcspNoCheck)
Parse PkixOcspNoCheck extension.
Subject Alternative Name extension.
Definition: x509_common.h:871
error_t x509ParseNameConstraints(bool_t critical, const uint8_t *data, size_t length, X509NameConstraints *nameConstraints)
Parse NameConstraints extension.
uint32_t dataLen
Definition: sftp_common.h:229
Access Description extension.
Definition: x509_common.h:945
error_t x509ParseCertExtensions(const uint8_t *data, size_t length, size_t *totalLength, X509Extensions *extensions, bool_t ignoreUnknown)
Parse X.509 certificate extensions.
Netscape certificate type.
Definition: x509_common.h:980
error_t x509ParseInhibitAnyPolicy(bool_t critical, const uint8_t *data, size_t length)
Parse InhibitAnyPolicy extension.
error_t x509ParseCrlDistrPoints(bool_t critical, const uint8_t *data, size_t length, X509CrlDistrPoints *crlDistrPoints)
Parse CRLDistributionPoints extension.
error_t x509ParseRelativeName(const uint8_t *data, size_t length, X509NameAttribute *relativeName)
Parse nameRelativeToCRLIssuer field.
error_t x509ParsePolicyConstraints(bool_t critical, const uint8_t *data, size_t length)
Parse PolicyConstraints extension.
error_t x509ParseSubjectKeyId(bool_t critical, const uint8_t *data, size_t length, X509SubjectKeyId *subjectKeyId)
Parse SubjectKeyIdentifier extension.
uint8_t oidLen
Definition: lldp_tlv.h:299
Basic Constraints extension.
Definition: x509_common.h:813
uint8_t critical
Definition: ike.h:1281
error_t x509ParseAccessDescription(const uint8_t *data, size_t length, size_t *totalLength, X509AccessDescription *accessDescription)
Parse AccessDescription field.
Name Constraints extension.
Definition: x509_common.h:825
X.509 certificate extensions.
Definition: x509_common.h:1003
error_t x509ParseAuthInfoAccess(bool_t critical, const uint8_t *data, size_t length, X509AuthInfoAccess *authInfoAccess)
Parse AuthorityInformationAccess extension.
CRL Distribution Points extension.
Definition: x509_common.h:932
error_t x509ParseDistrPoint(const uint8_t *data, size_t length, size_t *totalLength, X509DistrPoint *distrPoint)
Parse DistributionPoint field.
error_t x509ParseExtendedKeyUsage(bool_t critical, const uint8_t *data, size_t length, X509ExtendedKeyUsage *extKeyUsage)
Parse ExtendedKeyUsage extension.
error_t x509ParsePolicyMappings(bool_t critical, const uint8_t *data, size_t length)
Parse PolicyMappings extension.
error_t x509CheckDuplicateExtension(const uint8_t *oid, size_t oidLen, const uint8_t *data, size_t length)
Check whether the specified extension is a duplicate.
Key Usage extension.
Definition: x509_common.h:837