pem_import.h File Reference

PEM file import functions. More...

#include "core/crypto.h"
#include "pkix/pem_common.h"
#include "pkix/x509_common.h"
#include "pkc/dh.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "ecc/ec.h"
#include "ecc/eddsa.h"

Go to the source code of this file.

Functions

error_t pemImportCertificate (const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen, size_t *consumed)
 Decode a PEM file containing a certificate. More...
 
error_t pemImportCrl (const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen, size_t *consumed)
 Decode a PEM file containing a certificate revocation list. More...
 
error_t pemImportCsr (const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen)
 Decode a PEM file containing a certification signing request. More...
 
error_t pemImportDhParameters (const char_t *input, size_t length, DhParameters *params)
 Decode a PEM file containing Diffie-Hellman parameters. More...
 
error_t pemImportRsaPublicKey (const char_t *input, size_t length, RsaPublicKey *publicKey)
 Decode a PEM file containing an RSA public key. More...
 
error_t pemImportRsaPrivateKey (const char_t *input, size_t length, const char_t *password, RsaPrivateKey *privateKey)
 Decode a PEM file containing an RSA private key. More...
 
error_t pemImportDsaPublicKey (const char_t *input, size_t length, DsaPublicKey *publicKey)
 Decode a PEM file containing a DSA public key. More...
 
error_t pemImportDsaPrivateKey (const char_t *input, size_t length, const char_t *password, DsaPrivateKey *privateKey)
 Decode a PEM file containing a DSA private key. More...
 
error_t pemImportEcParameters (const char_t *input, size_t length, EcDomainParameters *params)
 Decode a PEM file containing EC domain parameters. More...
 
error_t pemImportEcPublicKey (const char_t *input, size_t length, EcPublicKey *publicKey)
 Decode a PEM file containing an EC public key. More...
 
error_t pemImportEcPrivateKey (const char_t *input, size_t length, const char_t *password, EcPrivateKey *privateKey)
 Decode a PEM file containing an EC private key. More...
 
error_t pemImportEddsaPublicKey (const char_t *input, size_t length, EddsaPublicKey *publicKey)
 Decode a PEM file containing a EdDSA public key. More...
 
error_t pemImportEddsaPrivateKey (const char_t *input, size_t length, const char_t *password, EddsaPrivateKey *privateKey)
 Decode a PEM file containing a EdDSA private key. More...
 
error_t pemGetPublicKeyType (const char_t *input, size_t length, X509KeyType *keyType)
 Retrieve the type of a PEM-encoded public key. More...
 
error_t pemGetPrivateKeyType (const char_t *input, size_t length, X509KeyType *keyType)
 Retrieve the type of a PEM-encoded private key. More...
 

Detailed Description

PEM file import functions.

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 pem_import.h.

Function Documentation

◆ pemGetPrivateKeyType()

error_t pemGetPrivateKeyType ( const char_t input,
size_t  length,
X509KeyType keyType 
)

Retrieve the type of a PEM-encoded private key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]keyTypePrivate key type
Returns
Error code

Definition at line 1707 of file pem_import.c.

◆ pemGetPublicKeyType()

error_t pemGetPublicKeyType ( const char_t input,
size_t  length,
X509KeyType keyType 
)

Retrieve the type of a PEM-encoded public key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]keyTypePublic key type
Returns
Error code

Definition at line 1598 of file pem_import.c.

◆ pemImportCertificate()

error_t pemImportCertificate ( const char_t input,
size_t  inputLen,
uint8_t *  output,
size_t *  outputLen,
size_t *  consumed 
)

Decode a PEM file containing a certificate.

Parameters
[in]inputPointer to the PEM encoding
[in]inputLenLength of the PEM structure
[out]outputPointer to the DER-encoded certificate
[out]outputLenLength of the DER-encoded certificate, in bytes
[out]consumedTotal number of characters that have been consumed (optional parameter)
Returns
Error code

Definition at line 61 of file pem_import.c.

◆ pemImportCrl()

error_t pemImportCrl ( const char_t input,
size_t  inputLen,
uint8_t *  output,
size_t *  outputLen,
size_t *  consumed 
)

Decode a PEM file containing a certificate revocation list.

Parameters
[in]inputPointer to the PEM encoding
[in]inputLenLength of the PEM structure
[out]outputPointer to the DER-encoded CRL
[out]outputLenLength of the DER-encoded CRL, in bytes
[out]consumedTotal number of characters that have been consumed (optional parameter)
Returns
Error code

Definition at line 92 of file pem_import.c.

◆ pemImportCsr()

error_t pemImportCsr ( const char_t input,
size_t  inputLen,
uint8_t *  output,
size_t *  outputLen 
)

Decode a PEM file containing a certification signing request.

Parameters
[in]inputPointer to the PEM encoding
[in]inputLenLength of the PEM structure
[out]outputPointer to the DER-encoded CSR
[out]outputLenLength of the DER-encoded CSR, in bytes
Returns
Error code

Definition at line 121 of file pem_import.c.

◆ pemImportDhParameters()

error_t pemImportDhParameters ( const char_t input,
size_t  length,
DhParameters params 
)

Decode a PEM file containing Diffie-Hellman parameters.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]paramsDiffie-Hellman parameters resulting from the parsing process
Returns
Error code

Definition at line 149 of file pem_import.c.

◆ pemImportDsaPrivateKey()

error_t pemImportDsaPrivateKey ( const char_t input,
size_t  length,
const char_t password,
DsaPrivateKey privateKey 
)

Decode a PEM file containing a DSA private key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
[out]privateKeyDSA private key resulting from the parsing process
Returns
Error code

Definition at line 676 of file pem_import.c.

◆ pemImportDsaPublicKey()

error_t pemImportDsaPublicKey ( const char_t input,
size_t  length,
DsaPublicKey publicKey 
)

Decode a PEM file containing a DSA public key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]publicKeyDSA public key resulting from the parsing process
Returns
Error code

Definition at line 594 of file pem_import.c.

◆ pemImportEcParameters()

error_t pemImportEcParameters ( const char_t input,
size_t  length,
EcDomainParameters params 
)

Decode a PEM file containing EC domain parameters.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]paramsEC domain parameters
Returns
Error code

Definition at line 881 of file pem_import.c.

◆ pemImportEcPrivateKey()

error_t pemImportEcPrivateKey ( const char_t input,
size_t  length,
const char_t password,
EcPrivateKey privateKey 
)

Decode a PEM file containing an EC private key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
[out]privateKeyEC private key resulting from the parsing process
Returns
Error code

Definition at line 1163 of file pem_import.c.

◆ pemImportEcPublicKey()

error_t pemImportEcPublicKey ( const char_t input,
size_t  length,
EcPublicKey publicKey 
)

Decode a PEM file containing an EC public key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]publicKeyEC public key resulting from the parsing process
Returns
Error code

Definition at line 1081 of file pem_import.c.

◆ pemImportEddsaPrivateKey()

error_t pemImportEddsaPrivateKey ( const char_t input,
size_t  length,
const char_t password,
EddsaPrivateKey privateKey 
)

Decode a PEM file containing a EdDSA private key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
[out]privateKeyEdDSA private key resulting from the parsing process
Returns
Error code

Definition at line 1450 of file pem_import.c.

◆ pemImportEddsaPublicKey()

error_t pemImportEddsaPublicKey ( const char_t input,
size_t  length,
EddsaPublicKey publicKey 
)

Decode a PEM file containing a EdDSA public key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]publicKeyEdDSA public key resulting from the parsing process
Returns
Error code

Definition at line 1368 of file pem_import.c.

◆ pemImportRsaPrivateKey()

error_t pemImportRsaPrivateKey ( const char_t input,
size_t  length,
const char_t password,
RsaPrivateKey privateKey 
)

Decode a PEM file containing an RSA private key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
[out]privateKeyRSA private key resulting from the parsing process
Returns
Error code

Definition at line 389 of file pem_import.c.

◆ pemImportRsaPublicKey()

error_t pemImportRsaPublicKey ( const char_t input,
size_t  length,
RsaPublicKey publicKey 
)

Decode a PEM file containing an RSA public key.

Parameters
[in]inputPointer to the PEM encoding
[in]lengthLength of the PEM encoding
[out]publicKeyRSA public key resulting from the parsing process
Returns
Error code

Definition at line 260 of file pem_import.c.