x509_cert_ext_parse.c File Reference

X.509 extension parsing. More...

#include "core/crypto.h"
#include "pkix/x509_cert_parse.h"
#include "pkix/x509_cert_ext_parse.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t x509ParseCertExtensions (const uint8_t *data, size_t length, size_t *totalLength, X509Extensions *extensions, bool_t ignoreUnknown)
 Parse X.509 certificate extensions. More...
 
error_t x509ParseExtension (const uint8_t *data, size_t length, size_t *totalLength, X509Extension *extension)
 Parse X.509 certificate extension. More...
 
error_t x509ParseBasicConstraints (bool_t critical, const uint8_t *data, size_t length, X509BasicConstraints *basicConstraints)
 Parse BasicConstraints extension. More...
 
error_t x509ParseNameConstraints (bool_t critical, const uint8_t *data, size_t length, X509NameConstraints *nameConstraints)
 Parse NameConstraints extension. More...
 
error_t x509ParsePolicyConstraints (bool_t critical, const uint8_t *data, size_t length)
 Parse PolicyConstraints extension. More...
 
error_t x509ParsePolicyMappings (bool_t critical, const uint8_t *data, size_t length)
 Parse PolicyMappings extension. More...
 
error_t x509ParseInhibitAnyPolicy (bool_t critical, const uint8_t *data, size_t length)
 Parse InhibitAnyPolicy extension. More...
 
error_t x509ParseKeyUsage (bool_t critical, const uint8_t *data, size_t length, X509KeyUsage *keyUsage)
 Parse KeyUsage extension. More...
 
error_t x509ParseExtendedKeyUsage (bool_t critical, const uint8_t *data, size_t length, X509ExtendedKeyUsage *extKeyUsage)
 Parse ExtendedKeyUsage extension. More...
 
error_t x509ParseSubjectAltName (bool_t critical, const uint8_t *data, size_t length, X509SubjectAltName *subjectAltName)
 Parse SubjectAltName extension. More...
 
error_t x509ParseSubjectKeyId (bool_t critical, const uint8_t *data, size_t length, X509SubjectKeyId *subjectKeyId)
 Parse SubjectKeyIdentifier extension. More...
 
error_t x509ParseAuthKeyId (bool_t critical, const uint8_t *data, size_t length, X509AuthKeyId *authKeyId)
 Parse AuthorityKeyIdentifier extension. More...
 
error_t x509ParseCrlDistrPoints (bool_t critical, const uint8_t *data, size_t length, X509CrlDistrPoints *crlDistrPoints)
 Parse CRLDistributionPoints extension. More...
 
error_t x509ParseDistrPoint (const uint8_t *data, size_t length, size_t *totalLength, X509DistrPoint *distrPoint)
 Parse DistributionPoint field. More...
 
error_t x509ParseDistrPointName (const uint8_t *data, size_t length, X509DistrPointName *distrPointName)
 Parse DistributionPointName field. More...
 
error_t x509ParseRelativeName (const uint8_t *data, size_t length, X509NameAttribute *relativeName)
 Parse nameRelativeToCRLIssuer field. More...
 
error_t x509ParseReasonFlags (const uint8_t *data, size_t length, uint16_t *reasonFlags)
 Parse ReasonFlags field. More...
 
error_t x509ParseAuthInfoAccess (bool_t critical, const uint8_t *data, size_t length, X509AuthInfoAccess *authInfoAccess)
 Parse AuthorityInformationAccess extension. More...
 
error_t x509ParseAccessDescription (const uint8_t *data, size_t length, size_t *totalLength, X509AccessDescription *accessDescription)
 Parse AccessDescription field. More...
 
error_t x509ParsePkixOcspNoCheck (bool_t critical, const uint8_t *data, size_t length, X509PkixOcspNoCheck *pkixOcspNoCheck)
 Parse PkixOcspNoCheck extension. More...
 
error_t x509ParseNsCertType (bool_t critical, const uint8_t *data, size_t length, X509NsCertType *nsCertType)
 Parse NetscapeCertType extension. More...
 
__weak_func 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. More...
 
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. More...
 

Detailed Description

X.509 extension parsing.

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_ext_parse.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file x509_cert_ext_parse.c.

Function Documentation

◆ x509CheckDuplicateExtension()

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.

Parameters
[in]oidExtension identifier
[in]oidLenLength of the extension identifier
[in]dataPointer to the extension list
[in]lengthLength of the extension list
Returns
Error code

Definition at line 1555 of file x509_cert_ext_parse.c.

◆ x509ParseAccessDescription()

error_t x509ParseAccessDescription ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509AccessDescription accessDescription 
)

Parse AccessDescription field.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]accessDescriptionInformation resulting from the parsing process
Returns
Error code

Definition at line 1373 of file x509_cert_ext_parse.c.

◆ x509ParseAuthInfoAccess()

error_t x509ParseAuthInfoAccess ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509AuthInfoAccess authInfoAccess 
)

Parse AuthorityInformationAccess extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]authInfoAccessInformation resulting from the parsing process
Returns
Error code

Definition at line 1302 of file x509_cert_ext_parse.c.

◆ x509ParseAuthKeyId()

error_t x509ParseAuthKeyId ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509AuthKeyId authKeyId 
)

Parse AuthorityKeyIdentifier extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]authKeyIdInformation resulting from the parsing process
Returns
Error code

Definition at line 939 of file x509_cert_ext_parse.c.

◆ x509ParseBasicConstraints()

error_t x509ParseBasicConstraints ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509BasicConstraints basicConstraints 
)

Parse BasicConstraints extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]basicConstraintsInformation resulting from the parsing process
Returns
Error code

Definition at line 354 of file x509_cert_ext_parse.c.

◆ x509ParseCertExtensions()

error_t x509ParseCertExtensions ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509Extensions extensions,
bool_t  ignoreUnknown 
)

Parse X.509 certificate extensions.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]extensionsInformation resulting from the parsing process
[in]ignoreUnknownIgnore unknown extensions
Returns
Error code

Definition at line 56 of file x509_cert_ext_parse.c.

◆ x509ParseCrlDistrPoints()

error_t x509ParseCrlDistrPoints ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509CrlDistrPoints crlDistrPoints 
)

Parse CRLDistributionPoints extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]crlDistrPointsInformation resulting from the parsing process
Returns
Error code

Definition at line 1001 of file x509_cert_ext_parse.c.

◆ x509ParseDistrPoint()

error_t x509ParseDistrPoint ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509DistrPoint distrPoint 
)

Parse DistributionPoint field.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]distrPointInformation resulting from the parsing process
Returns
Error code

Definition at line 1072 of file x509_cert_ext_parse.c.

◆ x509ParseDistrPointName()

error_t x509ParseDistrPointName ( const uint8_t *  data,
size_t  length,
X509DistrPointName distrPointName 
)

Parse DistributionPointName field.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]distrPointNameInformation resulting from the parsing process
Returns
Error code

Definition at line 1155 of file x509_cert_ext_parse.c.

◆ x509ParseExtendedKeyUsage()

error_t x509ParseExtendedKeyUsage ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509ExtendedKeyUsage extKeyUsage 
)

Parse ExtendedKeyUsage extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]extKeyUsageInformation resulting from the parsing process
Returns
Error code

Definition at line 699 of file x509_cert_ext_parse.c.

◆ x509ParseExtension()

error_t x509ParseExtension ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509Extension extension 
)

Parse X.509 certificate extension.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]extensionInformation resulting from the parsing process
Returns
Error code

Definition at line 267 of file x509_cert_ext_parse.c.

◆ x509ParseInhibitAnyPolicy()

error_t x509ParseInhibitAnyPolicy ( bool_t  critical,
const uint8_t *  data,
size_t  length 
)

Parse InhibitAnyPolicy extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
Returns
Error code

Definition at line 610 of file x509_cert_ext_parse.c.

◆ x509ParseKeyUsage()

error_t x509ParseKeyUsage ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509KeyUsage keyUsage 
)

Parse KeyUsage extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]keyUsageInformation resulting from the parsing process
Returns
Error code

Definition at line 630 of file x509_cert_ext_parse.c.

◆ x509ParseNameConstraints()

error_t x509ParseNameConstraints ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509NameConstraints nameConstraints 
)

Parse NameConstraints extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]nameConstraintsInformation resulting from the parsing process
Returns
Error code

Definition at line 445 of file x509_cert_ext_parse.c.

◆ x509ParseNsCertType()

error_t x509ParseNsCertType ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509NsCertType nsCertType 
)

Parse NetscapeCertType extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]nsCertTypeInformation resulting from the parsing process
Returns
Error code

Definition at line 1478 of file x509_cert_ext_parse.c.

◆ x509ParsePkixOcspNoCheck()

error_t x509ParsePkixOcspNoCheck ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509PkixOcspNoCheck pkixOcspNoCheck 
)

Parse PkixOcspNoCheck extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]pkixOcspNoCheckInformation resulting from the parsing process
Returns
Error code

Definition at line 1436 of file x509_cert_ext_parse.c.

◆ x509ParsePolicyConstraints()

error_t x509ParsePolicyConstraints ( bool_t  critical,
const uint8_t *  data,
size_t  length 
)

Parse PolicyConstraints extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
Returns
Error code

Definition at line 545 of file x509_cert_ext_parse.c.

◆ x509ParsePolicyMappings()

error_t x509ParsePolicyMappings ( bool_t  critical,
const uint8_t *  data,
size_t  length 
)

Parse PolicyMappings extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
Returns
Error code

Definition at line 578 of file x509_cert_ext_parse.c.

◆ x509ParseReasonFlags()

error_t x509ParseReasonFlags ( const uint8_t *  data,
size_t  length,
uint16_t *  reasonFlags 
)

Parse ReasonFlags field.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]reasonFlagsInformation resulting from the parsing process
Returns
Error code

Definition at line 1261 of file x509_cert_ext_parse.c.

◆ x509ParseRelativeName()

error_t x509ParseRelativeName ( const uint8_t *  data,
size_t  length,
X509NameAttribute relativeName 
)

Parse nameRelativeToCRLIssuer field.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]relativeNameInformation resulting from the parsing process
Returns
Error code

Definition at line 1205 of file x509_cert_ext_parse.c.

◆ x509ParseSubjectAltName()

error_t x509ParseSubjectAltName ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509SubjectAltName subjectAltName 
)

Parse SubjectAltName extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]subjectAltNameInformation resulting from the parsing process
Returns
Error code

Definition at line 862 of file x509_cert_ext_parse.c.

◆ x509ParseSubjectKeyId()

error_t x509ParseSubjectKeyId ( bool_t  critical,
const uint8_t *  data,
size_t  length,
X509SubjectKeyId subjectKeyId 
)

Parse SubjectKeyIdentifier extension.

Parameters
[in]criticalCritical extension flag
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]subjectKeyIdInformation resulting from the parsing process
Returns
Error code

Definition at line 902 of file x509_cert_ext_parse.c.

◆ x509ParseUnknownCertExtension()

__weak_func 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.

Parameters
[in]oidExtension identifier
[in]oidLenLength of the extension identifier
[in]criticalCritical extension flag
[in]dataExtension value
[in]dataLenLength of the extension value
[out]extensionsInformation resulting from the parsing process
Returns
Error code

Definition at line 1537 of file x509_cert_ext_parse.c.