pkcs8_key_parse.c File Reference

PKCS #8 key parsing. More...

#include "core/crypto.h"
#include "pkix/pkcs8_key_parse.h"
#include "pkix/x509_key_parse.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "ecc/ed25519.h"
#include "ecc/ed448.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t pkcs8ParsePrivateKeyInfo (const uint8_t *data, size_t length, Pkcs8PrivateKeyInfo *privateKeyInfo)
 Parse PrivateKeyInfo structure. More...
 
error_t pkcs8ParsePrivateKeyAlgo (const uint8_t *data, size_t length, size_t *totalLength, Pkcs8PrivateKeyInfo *privateKeyInfo)
 Parse PrivateKeyAlgorithm structure. More...
 
error_t pkcs8ParseRsaPrivateKey (const uint8_t *data, size_t length, Pkcs8RsaPrivateKey *rsaPrivateKey)
 Parse RSAPrivateKey structure. More...
 
error_t pkcs8ParseDsaPrivateKey (const uint8_t *data, size_t length, X509DsaParameters *dsaParams, Pkcs8DsaPrivateKey *dsaPrivateKey)
 Parse DSAPrivateKey structure. More...
 
error_t pkcs8ParseEcPrivateKey (const uint8_t *data, size_t length, X509EcParameters *ecParams, Pkcs8EcPrivateKey *ecPrivateKey)
 Parse ECPrivateKey structure. More...
 
error_t pkcs8ParseEddsaPrivateKey (const uint8_t *data, size_t length, Pkcs8EddsaPrivateKey *eddsaPrivateKey)
 Parse CurvePrivateKey structure. More...
 
error_t pkcs8ImportRsaPrivateKey (const Pkcs8PrivateKeyInfo *privateKeyInfo, RsaPrivateKey *privateKey)
 Import an RSA private key. More...
 
error_t pkcs8ImportDsaPrivateKey (const Pkcs8PrivateKeyInfo *privateKeyInfo, DsaPrivateKey *privateKey)
 Import an DSA private key. More...
 
error_t pkcs8ImportEcPrivateKey (const Pkcs8PrivateKeyInfo *privateKeyInfo, Mpi *privateKey)
 Import an EC private key. More...
 
error_t pkcs8ImportEddsaPrivateKey (const Pkcs8PrivateKeyInfo *privateKeyInfo, EddsaPrivateKey *privateKey)
 Import an EdDSA private key. More...
 

Detailed Description

PKCS #8 key parsing.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2019 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.6

Definition in file pkcs8_key_parse.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pkcs8_key_parse.c.

Function Documentation

◆ pkcs8ImportDsaPrivateKey()

error_t pkcs8ImportDsaPrivateKey ( const Pkcs8PrivateKeyInfo privateKeyInfo,
DsaPrivateKey privateKey 
)

Import an DSA private key.

Parameters
[in]privateKeyInfoPrivate key information
[out]privateKeyDSA private key
Returns
Error code

Definition at line 878 of file pkcs8_key_parse.c.

◆ pkcs8ImportEcPrivateKey()

error_t pkcs8ImportEcPrivateKey ( const Pkcs8PrivateKeyInfo privateKeyInfo,
Mpi privateKey 
)

Import an EC private key.

Parameters
[in]privateKeyInfoPrivate key information
[out]privateKeyEC private key
Returns
Error code

Definition at line 963 of file pkcs8_key_parse.c.

◆ pkcs8ImportEddsaPrivateKey()

error_t pkcs8ImportEddsaPrivateKey ( const Pkcs8PrivateKeyInfo privateKeyInfo,
EddsaPrivateKey privateKey 
)

Import an EdDSA private key.

Parameters
[in]privateKeyInfoPrivate key information
[out]privateKeyEdDSA private key
Returns
Error code

Definition at line 1014 of file pkcs8_key_parse.c.

◆ pkcs8ImportRsaPrivateKey()

error_t pkcs8ImportRsaPrivateKey ( const Pkcs8PrivateKeyInfo privateKeyInfo,
RsaPrivateKey privateKey 
)

Import an RSA private key.

Parameters
[in]privateKeyInfoPrivate key information
[out]privateKeyRSA private key
Returns
Error code

Definition at line 742 of file pkcs8_key_parse.c.

◆ pkcs8ParseDsaPrivateKey()

error_t pkcs8ParseDsaPrivateKey ( const uint8_t *  data,
size_t  length,
X509DsaParameters dsaParams,
Pkcs8DsaPrivateKey dsaPrivateKey 
)

Parse DSAPrivateKey structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]dsaParamsDSA domain parameters
[out]dsaPrivateKeyDSA private key
Returns
Error code

Definition at line 492 of file pkcs8_key_parse.c.

◆ pkcs8ParseEcPrivateKey()

error_t pkcs8ParseEcPrivateKey ( const uint8_t *  data,
size_t  length,
X509EcParameters ecParams,
Pkcs8EcPrivateKey ecPrivateKey 
)

Parse ECPrivateKey structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]ecParamsEC domain parameters
[out]ecPrivateKeyEC private key
Returns
Error code

Definition at line 633 of file pkcs8_key_parse.c.

◆ pkcs8ParseEddsaPrivateKey()

error_t pkcs8ParseEddsaPrivateKey ( const uint8_t *  data,
size_t  length,
Pkcs8EddsaPrivateKey eddsaPrivateKey 
)

Parse CurvePrivateKey structure.

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

Definition at line 714 of file pkcs8_key_parse.c.

◆ pkcs8ParsePrivateKeyAlgo()

error_t pkcs8ParsePrivateKeyAlgo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs8PrivateKeyInfo privateKeyInfo 
)

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

Definition at line 185 of file pkcs8_key_parse.c.

◆ pkcs8ParsePrivateKeyInfo()

error_t pkcs8ParsePrivateKeyInfo ( const uint8_t *  data,
size_t  length,
Pkcs8PrivateKeyInfo privateKeyInfo 
)

Parse PrivateKeyInfo structure.

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

Definition at line 56 of file pkcs8_key_parse.c.

◆ pkcs8ParseRsaPrivateKey()

error_t pkcs8ParseRsaPrivateKey ( const uint8_t *  data,
size_t  length,
Pkcs8RsaPrivateKey rsaPrivateKey 
)

Parse RSAPrivateKey structure.

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

Definition at line 296 of file pkcs8_key_parse.c.