pkcs8_key_parse.h File Reference

PKCS #8 key parsing. More...

#include "core/crypto.h"
#include "pkix/x509_common.h"

Go to the source code of this file.

Data Structures

struct  Pkcs8RsaPrivateKey
 RSA private key. More...
 
struct  Pkcs8DsaPrivateKey
 DSA private key. More...
 
struct  Pkcs8EcPrivateKey
 EC private key. More...
 
struct  Pkcs8EddsaPrivateKey
 EdDSA private key. More...
 
struct  Pkcs8EddsaPublicKey
 EdDSA public key. More...
 
struct  Pkcs8PrivateKeyInfo
 Private key information. More...
 
struct  Pkcs8EncryptedPrivateKeyInfo
 Encrypted private key information. More...
 

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, X509DsaPublicKey *dsaPublicKey)
 Parse DSAPrivateKey structure. More...
 
error_t pkcs8ParseEcPrivateKey (const uint8_t *data, size_t length, X509EcParameters *ecParams, Pkcs8EcPrivateKey *ecPrivateKey, X509EcPublicKey *ecPublicKey)
 Parse ECPrivateKey structure. More...
 
error_t pkcs8ParseEcPublicKey (const uint8_t *data, size_t length, X509EcPublicKey *ecPublicKey)
 Parse publicKey structure. More...
 
error_t pkcs8ParseEddsaPrivateKey (const uint8_t *data, size_t length, Pkcs8EddsaPrivateKey *eddsaPrivateKey)
 Parse CurvePrivateKey structure. More...
 
error_t pkcs8ParseEddsaPublicKey (const uint8_t *data, size_t length, Pkcs8EddsaPublicKey *eddsaPublicKey)
 Parse publicKey structure. More...
 
error_t pkcs8ParseEncryptedPrivateKeyInfo (const uint8_t *data, size_t length, Pkcs8EncryptedPrivateKeyInfo *encryptedPrivateKeyInfo)
 Parse EncryptedPrivateKeyInfo structure. More...
 
error_t pkcs8ParseEncryptionAlgoId (const uint8_t *data, size_t length, size_t *totalLength, X509AlgoId *encryptionAlgoId)
 Parse EncryptionAlgorithmIdentifier structure. More...
 
error_t pkcs8ImportRsaPrivateKey (RsaPrivateKey *privateKey, const Pkcs8PrivateKeyInfo *privateKeyInfo)
 Import an RSA private key. More...
 
error_t pkcs8ImportDsaPrivateKey (DsaPrivateKey *privateKey, const Pkcs8PrivateKeyInfo *privateKeyInfo)
 Import a DSA private key. More...
 
error_t pkcs8ImportEcPrivateKey (EcPrivateKey *privateKey, const Pkcs8PrivateKeyInfo *privateKeyInfo)
 Import an EC private key. More...
 
error_t pkcs8ImportEddsaPrivateKey (EddsaPrivateKey *privateKey, const Pkcs8PrivateKeyInfo *privateKeyInfo)
 Import an EdDSA private key. More...
 

Detailed Description

PKCS #8 key parsing.

License

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

Copyright (C) 2010-2025 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.5.0

Definition in file pkcs8_key_parse.h.

Function Documentation

◆ pkcs8ImportDsaPrivateKey()

error_t pkcs8ImportDsaPrivateKey ( DsaPrivateKey privateKey,
const Pkcs8PrivateKeyInfo privateKeyInfo 
)

Import a DSA private key.

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

Definition at line 1112 of file pkcs8_key_parse.c.

◆ pkcs8ImportEcPrivateKey()

error_t pkcs8ImportEcPrivateKey ( EcPrivateKey privateKey,
const Pkcs8PrivateKeyInfo privateKeyInfo 
)

Import an EC private key.

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

Definition at line 1207 of file pkcs8_key_parse.c.

◆ pkcs8ImportEddsaPrivateKey()

error_t pkcs8ImportEddsaPrivateKey ( EddsaPrivateKey privateKey,
const Pkcs8PrivateKeyInfo privateKeyInfo 
)

Import an EdDSA private key.

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

Definition at line 1304 of file pkcs8_key_parse.c.

◆ pkcs8ImportRsaPrivateKey()

error_t pkcs8ImportRsaPrivateKey ( RsaPrivateKey privateKey,
const Pkcs8PrivateKeyInfo privateKeyInfo 
)

Import an RSA private key.

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

Definition at line 976 of file pkcs8_key_parse.c.

◆ pkcs8ParseDsaPrivateKey()

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

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
[out]dsaPublicKeyDSA public key
Returns
Error code

Definition at line 536 of file pkcs8_key_parse.c.

◆ pkcs8ParseEcPrivateKey()

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

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
[out]ecPublicKeyEC public key
Returns
Error code

Definition at line 683 of file pkcs8_key_parse.c.

◆ pkcs8ParseEcPublicKey()

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

Parse publicKey structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]ecPublicKeyEC public key
Returns
Error code

Definition at line 779 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]eddsaPrivateKeyEdDSA private key
Returns
Error code

Definition at line 820 of file pkcs8_key_parse.c.

◆ pkcs8ParseEddsaPublicKey()

error_t pkcs8ParseEddsaPublicKey ( const uint8_t *  data,
size_t  length,
Pkcs8EddsaPublicKey eddsaPublicKey 
)

Parse publicKey structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]eddsaPublicKeyEdDSA public key
Returns
Error code

Definition at line 849 of file pkcs8_key_parse.c.

◆ pkcs8ParseEncryptedPrivateKeyInfo()

error_t pkcs8ParseEncryptedPrivateKeyInfo ( const uint8_t *  data,
size_t  length,
Pkcs8EncryptedPrivateKeyInfo encryptedPrivateKeyInfo 
)

Parse EncryptedPrivateKeyInfo structure.

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

Definition at line 874 of file pkcs8_key_parse.c.

◆ pkcs8ParseEncryptionAlgoId()

error_t pkcs8ParseEncryptionAlgoId ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509AlgoId encryptionAlgoId 
)

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

Definition at line 926 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 230 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 55 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 339 of file pkcs8_key_parse.c.