x509_key_parse.c File Reference

Parsing of ASN.1 encoded keys. More...

#include "core/crypto.h"
#include "pkix/x509_key_parse.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "ecc/eddsa.h"
#include "hash/sha1.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t x509ParseSubjectPublicKeyInfo (const uint8_t *data, size_t length, size_t *totalLength, X509SubjectPublicKeyInfo *publicKeyInfo)
 Parse SubjectPublicKeyInfo structure. More...
 
error_t x509ParseAlgoId (const uint8_t *data, size_t length, size_t *totalLength, X509SubjectPublicKeyInfo *publicKeyInfo)
 Parse AlgorithmIdentifier structure. More...
 
error_t x509ParseRsaPublicKey (const uint8_t *data, size_t length, X509RsaPublicKey *rsaPublicKey)
 Parse RSAPublicKey structure. More...
 
error_t x509ParseDsaPublicKey (const uint8_t *data, size_t length, X509DsaPublicKey *dsaPublicKey)
 Parse DSAPublicKey structure. More...
 
error_t x509ParseDsaParameters (const uint8_t *data, size_t length, X509DsaParameters *dsaParams)
 Parse DSA domain parameters. More...
 
error_t x509ParseEcPublicKey (const uint8_t *data, size_t length, X509EcPublicKey *ecPublicKey)
 Parse ECPublicKey structure. More...
 
error_t x509ParseEcParameters (const uint8_t *data, size_t length, X509EcParameters *ecParams)
 Parse ECParameters structure. More...
 
error_t x509ImportRsaPublicKey (const X509SubjectPublicKeyInfo *publicKeyInfo, RsaPublicKey *publicKey)
 Import an RSA public key. More...
 
error_t x509ImportDsaPublicKey (const X509SubjectPublicKeyInfo *publicKeyInfo, DsaPublicKey *publicKey)
 Import a DSA public key. More...
 
error_t x509ImportEcPublicKey (const X509SubjectPublicKeyInfo *publicKeyInfo, EcPublicKey *publicKey)
 Import an EC public key. More...
 
error_t x509ImportEcParameters (const X509EcParameters *ecParams, EcDomainParameters *params)
 Import EC domain parameters. More...
 
error_t x509ImportEddsaPublicKey (const X509SubjectPublicKeyInfo *publicKeyInfo, EddsaPublicKey *publicKey)
 Import an EdDSA public key. More...
 

Detailed Description

Parsing of ASN.1 encoded keys.

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

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file x509_key_parse.c.

Function Documentation

◆ x509ImportDsaPublicKey()

error_t x509ImportDsaPublicKey ( const X509SubjectPublicKeyInfo publicKeyInfo,
DsaPublicKey publicKey 
)

Import a DSA public key.

Parameters
[in]publicKeyInfoPublic key information
[out]publicKeyDSA public key
Returns
Error code

Definition at line 633 of file x509_key_parse.c.

◆ x509ImportEcParameters()

error_t x509ImportEcParameters ( const X509EcParameters ecParams,
EcDomainParameters params 
)

Import EC domain parameters.

Parameters
[in]ecParamsPointer to the ECParameters structure
[out]paramsEC domain parameters
Returns
Error code

Definition at line 802 of file x509_key_parse.c.

◆ x509ImportEcPublicKey()

error_t x509ImportEcPublicKey ( const X509SubjectPublicKeyInfo publicKeyInfo,
EcPublicKey publicKey 
)

Import an EC public key.

Parameters
[in]publicKeyInfoPublic key information
[out]publicKeyEC public key
Returns
Error code

Definition at line 718 of file x509_key_parse.c.

◆ x509ImportEddsaPublicKey()

error_t x509ImportEddsaPublicKey ( const X509SubjectPublicKeyInfo publicKeyInfo,
EddsaPublicKey publicKey 
)

Import an EdDSA public key.

Parameters
[in]publicKeyInfoPublic key information
[out]publicKeyEdDSA public key
Returns
Error code

Definition at line 839 of file x509_key_parse.c.

◆ x509ImportRsaPublicKey()

error_t x509ImportRsaPublicKey ( const X509SubjectPublicKeyInfo publicKeyInfo,
RsaPublicKey publicKey 
)

Import an RSA public key.

Parameters
[in]publicKeyInfoPublic key information
[out]publicKeyRSA public key
Returns
Error code

Definition at line 563 of file x509_key_parse.c.

◆ x509ParseAlgoId()

error_t x509ParseAlgoId ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509SubjectPublicKeyInfo publicKeyInfo 
)

Parse AlgorithmIdentifier structure.

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]publicKeyInfoInformation resulting from the parsing process
Returns
Error code

Definition at line 197 of file x509_key_parse.c.

◆ x509ParseDsaParameters()

error_t x509ParseDsaParameters ( const uint8_t *  data,
size_t  length,
X509DsaParameters dsaParams 
)

Parse DSA domain parameters.

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

Definition at line 415 of file x509_key_parse.c.

◆ x509ParseDsaPublicKey()

error_t x509ParseDsaPublicKey ( const uint8_t *  data,
size_t  length,
X509DsaPublicKey dsaPublicKey 
)

Parse DSAPublicKey structure.

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

Definition at line 377 of file x509_key_parse.c.

◆ x509ParseEcParameters()

error_t x509ParseEcParameters ( const uint8_t *  data,
size_t  length,
X509EcParameters ecParams 
)

Parse ECParameters structure.

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

Definition at line 530 of file x509_key_parse.c.

◆ x509ParseEcPublicKey()

error_t x509ParseEcPublicKey ( const uint8_t *  data,
size_t  length,
X509EcPublicKey ecPublicKey 
)

Parse ECPublicKey structure.

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

Definition at line 503 of file x509_key_parse.c.

◆ x509ParseRsaPublicKey()

error_t x509ParseRsaPublicKey ( const uint8_t *  data,
size_t  length,
X509RsaPublicKey rsaPublicKey 
)

Parse RSAPublicKey structure.

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

Definition at line 309 of file x509_key_parse.c.

◆ x509ParseSubjectPublicKeyInfo()

error_t x509ParseSubjectPublicKeyInfo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509SubjectPublicKeyInfo publicKeyInfo 
)

Parse SubjectPublicKeyInfo structure.

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]publicKeyInfoInformation resulting from the parsing process
Returns
Error code

Definition at line 56 of file x509_key_parse.c.