x509_common.c File Reference

X.509 common definitions. More...

#include "core/crypto.h"
#include "certificate/x509_common.h"
#include "encoding/oid.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "hash/md5.h"
#include "hash/sha1.h"
#include "hash/sha224.h"
#include "hash/sha256.h"
#include "hash/sha384.h"
#include "hash/sha512.h"
#include "debug.h"
#include "hash/sha3_224.h"
#include "hash/sha3_256.h"
#include "hash/sha3_384.h"
#include "hash/sha3_512.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t x509ReadInt (const uint8_t *data, size_t length, uint_t *value)
 Convert string to integer. More...
 
error_t x509ReadRsaPublicKey (const X509SubjectPublicKeyInfo *subjectPublicKeyInfo, RsaPublicKey *key)
 Read a RSA public key. More...
 
error_t x509ReadDsaPublicKey (const X509SubjectPublicKeyInfo *subjectPublicKeyInfo, DsaPublicKey *key)
 Read a DSA public key. More...
 
bool_t x509IsSignAlgoSupported (X509SignatureAlgo signAlgo)
 Check whether a given signature algorithm is supported. More...
 
bool_t x509IsHashAlgoSupported (X509HashAlgo hashAlgo)
 Check whether a given hash algorithm is supported. More...
 
error_t x509GetSignHashAlgo (const X509SignatureAlgoId *signAlgoId, X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
 Get the signature and hash algorithms that match the specified identifier. More...
 
const EcCurveInfox509GetCurveInfo (const uint8_t *oid, size_t length)
 Get the elliptic curve that matches the specified OID. More...
 

Variables

const uint8_t X509_COMMON_NAME_OID [3] = {0x55, 0x04, 0x03}
 
const uint8_t X509_SURNAME_OID [3] = {0x55, 0x04, 0x04}
 
const uint8_t X509_SERIAL_NUMBER_OID [3] = {0x55, 0x04, 0x05}
 
const uint8_t X509_COUNTRY_NAME_OID [3] = {0x55, 0x04, 0x06}
 
const uint8_t X509_LOCALITY_NAME_OID [3] = {0x55, 0x04, 0x07}
 
const uint8_t X509_STATE_OR_PROVINCE_NAME_OID [] = {0x55, 0x04, 0x08}
 
const uint8_t X509_ORGANIZATION_NAME_OID [3] = {0x55, 0x04, 0x0A}
 
const uint8_t X509_ORGANIZATIONAL_UNIT_NAME_OID [3] = {0x55, 0x04, 0x0B}
 
const uint8_t X509_TITLE_OID [3] = {0x55, 0x04, 0x0C}
 
const uint8_t X509_NAME_OID [3] = {0x55, 0x04, 0x29}
 
const uint8_t X509_GIVEN_NAME_OID [3] = {0x55, 0x04, 0x2A}
 
const uint8_t X509_INITIALS_OID [3] = {0x55, 0x04, 0x2B}
 
const uint8_t X509_GENERATION_QUALIFIER_OID [3] = {0x55, 0x04, 0x2C}
 
const uint8_t X509_DN_QUALIFIER_OID [3] = {0x55, 0x04, 0x2E}
 
const uint8_t X509_PSEUDONYM_OID [3] = {0x55, 0x04, 0x41}
 
const uint8_t X509_SUBJECT_DIRECTORY_ATTR_OID [3] = {0x55, 0x1D, 0x09}
 
const uint8_t X509_SUBJECT_KEY_ID_OID [3] = {0x55, 0x1D, 0x0E}
 
const uint8_t X509_KEY_USAGE_OID [3] = {0x55, 0x1D, 0x0F}
 
const uint8_t X509_SUBJECT_ALT_NAME_OID [3] = {0x55, 0x1D, 0x11}
 
const uint8_t X509_ISSUER_ALT_NAME_OID [3] = {0x55, 0x1D, 0x12}
 
const uint8_t X509_BASIC_CONSTRAINTS_OID [3] = {0x55, 0x1D, 0x13}
 
const uint8_t X509_NAME_CONSTRAINTS_OID [3] = {0x55, 0x1D, 0x1E}
 
const uint8_t X509_CRL_DISTR_POINTS_OID [3] = {0x55, 0x1D, 0x1F}
 
const uint8_t X509_CERTIFICATE_POLICIES_OID [3] = {0x55, 0x1D, 0x20}
 
const uint8_t X509_POLICY_MAPPINGS_OID [3] = {0x55, 0x1D, 0x21}
 
const uint8_t X509_AUTHORITY_KEY_ID_OID [3] = {0x55, 0x1D, 0x23}
 
const uint8_t X509_POLICY_CONSTRAINTS_OID [3] = {0x55, 0x1D, 0x24}
 
const uint8_t X509_EXTENDED_KEY_USAGE_OID [3] = {0x55, 0x1D, 0x25}
 
const uint8_t X509_FRESHEST_CRL_OID [3] = {0x55, 0x1D, 0x2E}
 
const uint8_t X509_INHIBIT_ANY_POLICY_OID [3] = {0x55, 0x1D, 0x36}
 
const uint8_t X509_NS_CERT_TYPE_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x42, 0x01, 0x01}
 
const uint8_t X509_ANY_EXT_KEY_USAGE_OID [4] = {0x55, 0x1D, 0x25, 0x00}
 
const uint8_t X509_KP_SERVER_AUTH_OID [8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01}
 
const uint8_t X509_KP_CLIENT_AUTH_OID [8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02}
 
const uint8_t X509_KP_CODE_SIGNING_OID [8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03}
 
const uint8_t X509_KP_EMAIL_PROTECTION_OID [8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04}
 
const uint8_t X509_KP_TIME_STAMPING_OID [8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x08}
 
const uint8_t X509_KP_OCSP_SIGNING_OID [8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x09}
 

Detailed Description

X.509 common definitions.

License

Copyright (C) 2010-2018 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
1.9.0

Definition in file x509_common.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 30 of file x509_common.c.

Function Documentation

◆ x509GetCurveInfo()

const EcCurveInfo* x509GetCurveInfo ( const uint8_t *  oid,
size_t  length 
)

Get the elliptic curve that matches the specified OID.

Parameters
[in]oidObject identifier
[in]lengthOID length
Returns
Elliptic curve domain parameters

Definition at line 846 of file x509_common.c.

◆ x509GetSignHashAlgo()

error_t x509GetSignHashAlgo ( const X509SignatureAlgoId signAlgoId,
X509SignatureAlgo signAlgo,
const HashAlgo **  hashAlgo 
)

Get the signature and hash algorithms that match the specified identifier.

Parameters
[in]signAlgoIdSignature algorithm identifier
[out]signAlgoSignature algorithm
[out]hashAlgoHash algorithm
Returns
Error code

Definition at line 472 of file x509_common.c.

◆ x509IsHashAlgoSupported()

bool_t x509IsHashAlgoSupported ( X509HashAlgo  hashAlgo)

Check whether a given hash algorithm is supported.

Parameters
[in]hashAlgosignature hash
Returns
TRUE is the signature hash is supported, else FALSE

Definition at line 373 of file x509_common.c.

◆ x509IsSignAlgoSupported()

bool_t x509IsSignAlgoSupported ( X509SignatureAlgo  signAlgo)

Check whether a given signature algorithm is supported.

Parameters
[in]signAlgosignature algorithm
Returns
TRUE is the signature algorithm is supported, else FALSE

Definition at line 305 of file x509_common.c.

◆ x509ReadDsaPublicKey()

error_t x509ReadDsaPublicKey ( const X509SubjectPublicKeyInfo subjectPublicKeyInfo,
DsaPublicKey key 
)

Read a DSA public key.

Parameters
[in]subjectPublicKeyInfoPointer to the SubjectPublicKeyInfo structure
[out]keyDSA public key
Returns
Error code

Definition at line 235 of file x509_common.c.

◆ x509ReadInt()

error_t x509ReadInt ( const uint8_t *  data,
size_t  length,
uint_t value 
)

Convert string to integer.

Parameters
[in]dataString containing the representation of an integral number
[in]lengthLength of the string
[out]valueOn success, the function returns the converted integral number
Returns
Error code

Definition at line 152 of file x509_common.c.

◆ x509ReadRsaPublicKey()

error_t x509ReadRsaPublicKey ( const X509SubjectPublicKeyInfo subjectPublicKeyInfo,
RsaPublicKey key 
)

Read a RSA public key.

Parameters
[in]subjectPublicKeyInfoPointer to the SubjectPublicKeyInfo structure
[out]keyRSA public key
Returns
Error code

Definition at line 184 of file x509_common.c.

Variable Documentation

◆ X509_ANY_EXT_KEY_USAGE_OID

const uint8_t X509_ANY_EXT_KEY_USAGE_OID[4] = {0x55, 0x1D, 0x25, 0x00}

Definition at line 129 of file x509_common.c.

◆ X509_AUTHORITY_KEY_ID_OID

const uint8_t X509_AUTHORITY_KEY_ID_OID[3] = {0x55, 0x1D, 0x23}

Definition at line 115 of file x509_common.c.

◆ X509_BASIC_CONSTRAINTS_OID

const uint8_t X509_BASIC_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x13}

Definition at line 105 of file x509_common.c.

◆ X509_CERTIFICATE_POLICIES_OID

const uint8_t X509_CERTIFICATE_POLICIES_OID[3] = {0x55, 0x1D, 0x20}

Definition at line 111 of file x509_common.c.

◆ X509_COMMON_NAME_OID

const uint8_t X509_COMMON_NAME_OID[3] = {0x55, 0x04, 0x03}

Definition at line 64 of file x509_common.c.

◆ X509_COUNTRY_NAME_OID

const uint8_t X509_COUNTRY_NAME_OID[3] = {0x55, 0x04, 0x06}

Definition at line 70 of file x509_common.c.

◆ X509_CRL_DISTR_POINTS_OID

const uint8_t X509_CRL_DISTR_POINTS_OID[3] = {0x55, 0x1D, 0x1F}

Definition at line 109 of file x509_common.c.

◆ X509_DN_QUALIFIER_OID

const uint8_t X509_DN_QUALIFIER_OID[3] = {0x55, 0x04, 0x2E}

Definition at line 90 of file x509_common.c.

◆ X509_EXTENDED_KEY_USAGE_OID

const uint8_t X509_EXTENDED_KEY_USAGE_OID[3] = {0x55, 0x1D, 0x25}

Definition at line 119 of file x509_common.c.

◆ X509_FRESHEST_CRL_OID

const uint8_t X509_FRESHEST_CRL_OID[3] = {0x55, 0x1D, 0x2E}

Definition at line 121 of file x509_common.c.

◆ X509_GENERATION_QUALIFIER_OID

const uint8_t X509_GENERATION_QUALIFIER_OID[3] = {0x55, 0x04, 0x2C}

Definition at line 88 of file x509_common.c.

◆ X509_GIVEN_NAME_OID

const uint8_t X509_GIVEN_NAME_OID[3] = {0x55, 0x04, 0x2A}

Definition at line 84 of file x509_common.c.

◆ X509_INHIBIT_ANY_POLICY_OID

const uint8_t X509_INHIBIT_ANY_POLICY_OID[3] = {0x55, 0x1D, 0x36}

Definition at line 123 of file x509_common.c.

◆ X509_INITIALS_OID

const uint8_t X509_INITIALS_OID[3] = {0x55, 0x04, 0x2B}

Definition at line 86 of file x509_common.c.

◆ X509_ISSUER_ALT_NAME_OID

const uint8_t X509_ISSUER_ALT_NAME_OID[3] = {0x55, 0x1D, 0x12}

Definition at line 103 of file x509_common.c.

◆ X509_KEY_USAGE_OID

const uint8_t X509_KEY_USAGE_OID[3] = {0x55, 0x1D, 0x0F}

Definition at line 99 of file x509_common.c.

◆ X509_KP_CLIENT_AUTH_OID

const uint8_t X509_KP_CLIENT_AUTH_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02}

Definition at line 133 of file x509_common.c.

◆ X509_KP_CODE_SIGNING_OID

const uint8_t X509_KP_CODE_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03}

Definition at line 135 of file x509_common.c.

◆ X509_KP_EMAIL_PROTECTION_OID

const uint8_t X509_KP_EMAIL_PROTECTION_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04}

Definition at line 137 of file x509_common.c.

◆ X509_KP_OCSP_SIGNING_OID

const uint8_t X509_KP_OCSP_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x09}

Definition at line 141 of file x509_common.c.

◆ X509_KP_SERVER_AUTH_OID

const uint8_t X509_KP_SERVER_AUTH_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01}

Definition at line 131 of file x509_common.c.

◆ X509_KP_TIME_STAMPING_OID

const uint8_t X509_KP_TIME_STAMPING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x08}

Definition at line 139 of file x509_common.c.

◆ X509_LOCALITY_NAME_OID

const uint8_t X509_LOCALITY_NAME_OID[3] = {0x55, 0x04, 0x07}

Definition at line 72 of file x509_common.c.

◆ X509_NAME_CONSTRAINTS_OID

const uint8_t X509_NAME_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x1E}

Definition at line 107 of file x509_common.c.

◆ X509_NAME_OID

const uint8_t X509_NAME_OID[3] = {0x55, 0x04, 0x29}

Definition at line 82 of file x509_common.c.

◆ X509_NS_CERT_TYPE_OID

const uint8_t X509_NS_CERT_TYPE_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x42, 0x01, 0x01}

Definition at line 126 of file x509_common.c.

◆ X509_ORGANIZATION_NAME_OID

const uint8_t X509_ORGANIZATION_NAME_OID[3] = {0x55, 0x04, 0x0A}

Definition at line 76 of file x509_common.c.

◆ X509_ORGANIZATIONAL_UNIT_NAME_OID

const uint8_t X509_ORGANIZATIONAL_UNIT_NAME_OID[3] = {0x55, 0x04, 0x0B}

Definition at line 78 of file x509_common.c.

◆ X509_POLICY_CONSTRAINTS_OID

const uint8_t X509_POLICY_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x24}

Definition at line 117 of file x509_common.c.

◆ X509_POLICY_MAPPINGS_OID

const uint8_t X509_POLICY_MAPPINGS_OID[3] = {0x55, 0x1D, 0x21}

Definition at line 113 of file x509_common.c.

◆ X509_PSEUDONYM_OID

const uint8_t X509_PSEUDONYM_OID[3] = {0x55, 0x04, 0x41}

Definition at line 92 of file x509_common.c.

◆ X509_SERIAL_NUMBER_OID

const uint8_t X509_SERIAL_NUMBER_OID[3] = {0x55, 0x04, 0x05}

Definition at line 68 of file x509_common.c.

◆ X509_STATE_OR_PROVINCE_NAME_OID

const uint8_t X509_STATE_OR_PROVINCE_NAME_OID[] = {0x55, 0x04, 0x08}

Definition at line 74 of file x509_common.c.

◆ X509_SUBJECT_ALT_NAME_OID

const uint8_t X509_SUBJECT_ALT_NAME_OID[3] = {0x55, 0x1D, 0x11}

Definition at line 101 of file x509_common.c.

◆ X509_SUBJECT_DIRECTORY_ATTR_OID

const uint8_t X509_SUBJECT_DIRECTORY_ATTR_OID[3] = {0x55, 0x1D, 0x09}

Definition at line 95 of file x509_common.c.

◆ X509_SUBJECT_KEY_ID_OID

const uint8_t X509_SUBJECT_KEY_ID_OID[3] = {0x55, 0x1D, 0x0E}

Definition at line 97 of file x509_common.c.

◆ X509_SURNAME_OID

const uint8_t X509_SURNAME_OID[3] = {0x55, 0x04, 0x04}

Definition at line 66 of file x509_common.c.

◆ X509_TITLE_OID

const uint8_t X509_TITLE_OID[3] = {0x55, 0x04, 0x0C}

Definition at line 80 of file x509_common.c.