pem_export.c File Reference

PEM file export functions. More...

#include "core/crypto.h"
#include "pkix/pem_export.h"
#include "pkix/pkcs8_key_format.h"
#include "pkix/x509_cert_create.h"
#include "pkix/x509_key_format.h"
#include "encoding/asn1.h"
#include "mpi/mpi.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t pemExportCertificate (const uint8_t *cert, size_t certLen, char_t *output, size_t *written)
 Export an X.509 certificate to PEM format. More...
 
error_t pemExportCrl (const uint8_t *crl, size_t crlLen, char_t *output, size_t *written)
 Export a certificate revocation list to PEM format. More...
 
error_t pemExportCsr (const uint8_t *csr, size_t csrLen, char_t *output, size_t *written)
 Export a certification signing request to PEM format. More...
 
error_t pemExportRsaPublicKey (const RsaPublicKey *publicKey, char_t *output, size_t *written)
 Export an RSA public key to PEM format. More...
 
error_t pemExportRsaPrivateKey (const RsaPrivateKey *privateKey, char_t *output, size_t *written)
 Export an RSA private key to PEM format. More...
 
error_t pemExportRsaPssPublicKey (const RsaPublicKey *publicKey, char_t *output, size_t *written)
 Export an RSA-PSS public key to PEM format. More...
 
error_t pemExportRsaPssPrivateKey (const RsaPrivateKey *privateKey, char_t *output, size_t *written)
 Export an RSA-PSS private key to PEM format. More...
 
error_t pemExportDsaPublicKey (const DsaPublicKey *publicKey, char_t *output, size_t *written)
 Export a DSA public key to PEM format. More...
 
error_t pemExportDsaPrivateKey (const DsaPrivateKey *privateKey, char_t *output, size_t *written)
 Export a DSA private key to PEM format. More...
 
error_t pemExportEcParameters (const EcCurveInfo *curveInfo, char_t *output, size_t *written)
 Export EC domain parameters to PEM format. More...
 
error_t pemExportEcPublicKey (const EcCurveInfo *curveInfo, const EcPublicKey *publicKey, char_t *output, size_t *written)
 Export an EC public key to PEM format. More...
 
error_t pemExportEcPrivateKey (const EcCurveInfo *curveInfo, const EcPrivateKey *privateKey, const EcPublicKey *publicKey, char_t *output, size_t *written)
 Export an EC private key to PEM format. More...
 
error_t pemExportEddsaPublicKey (const EcCurveInfo *curveInfo, const EddsaPublicKey *publicKey, char_t *output, size_t *written)
 Export an EdDSA public key to PEM format. More...
 
error_t pemExportEddsaPrivateKey (const EcCurveInfo *curveInfo, const EddsaPrivateKey *privateKey, char_t *output, size_t *written)
 Export an EdDSA private key to PEM format. More...
 

Detailed Description

PEM file export 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_export.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pem_export.c.

Function Documentation

◆ pemExportCertificate()

error_t pemExportCertificate ( const uint8_t *  cert,
size_t  certLen,
char_t output,
size_t *  written 
)

Export an X.509 certificate to PEM format.

Parameters
[in]certPointer to the DER-encoded certificate
[in]certLenLength of the DER-encoded certificate, in bytes
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 57 of file pem_export.c.

◆ pemExportCrl()

error_t pemExportCrl ( const uint8_t *  crl,
size_t  crlLen,
char_t output,
size_t *  written 
)

Export a certificate revocation list to PEM format.

Parameters
[in]crlPointer to the DER-encoded CRL
[in]crlLenLength of the DER-encoded CRL, in bytes
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 90 of file pem_export.c.

◆ pemExportCsr()

error_t pemExportCsr ( const uint8_t *  csr,
size_t  csrLen,
char_t output,
size_t *  written 
)

Export a certification signing request to PEM format.

Parameters
[in]csrPointer to the DER-encoded CSR
[in]csrLenLength of the DER-encoded CSR, in bytes
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 123 of file pem_export.c.

◆ pemExportDsaPrivateKey()

error_t pemExportDsaPrivateKey ( const DsaPrivateKey privateKey,
char_t output,
size_t *  written 
)

Export a DSA private key to PEM format.

Parameters
[in]privateKeyDSA private key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 522 of file pem_export.c.

◆ pemExportDsaPublicKey()

error_t pemExportDsaPublicKey ( const DsaPublicKey publicKey,
char_t output,
size_t *  written 
)

Export a DSA public key to PEM format.

Parameters
[in]publicKeyDSA public key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 469 of file pem_export.c.

◆ pemExportEcParameters()

error_t pemExportEcParameters ( const EcCurveInfo curveInfo,
char_t output,
size_t *  written 
)

Export EC domain parameters to PEM format.

Parameters
[in]curveInfoElliptic curve parameters
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 627 of file pem_export.c.

◆ pemExportEcPrivateKey()

error_t pemExportEcPrivateKey ( const EcCurveInfo curveInfo,
const EcPrivateKey privateKey,
const EcPublicKey publicKey,
char_t output,
size_t *  written 
)

Export an EC private key to PEM format.

Parameters
[in]curveInfoElliptic curve parameters
[in]privateKeyEC private key
[in]publicKeyEC public key (optional parameter)
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 736 of file pem_export.c.

◆ pemExportEcPublicKey()

error_t pemExportEcPublicKey ( const EcCurveInfo curveInfo,
const EcPublicKey publicKey,
char_t output,
size_t *  written 
)

Export an EC public key to PEM format.

Parameters
[in]curveInfoElliptic curve parameters
[in]publicKeyEC public key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 679 of file pem_export.c.

◆ pemExportEddsaPrivateKey()

error_t pemExportEddsaPrivateKey ( const EcCurveInfo curveInfo,
const EddsaPrivateKey privateKey,
char_t output,
size_t *  written 
)

Export an EdDSA private key to PEM format.

Parameters
[in]curveInfoElliptic curve parameters
[in]privateKeyEdDSA private key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 898 of file pem_export.c.

◆ pemExportEddsaPublicKey()

error_t pemExportEddsaPublicKey ( const EcCurveInfo curveInfo,
const EddsaPublicKey publicKey,
char_t output,
size_t *  written 
)

Export an EdDSA public key to PEM format.

Parameters
[in]curveInfoElliptic curve parameters
[in]publicKeyEdDSA public key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 844 of file pem_export.c.

◆ pemExportRsaPrivateKey()

error_t pemExportRsaPrivateKey ( const RsaPrivateKey privateKey,
char_t output,
size_t *  written 
)

Export an RSA private key to PEM format.

Parameters
[in]privateKeyRSA private key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 208 of file pem_export.c.

◆ pemExportRsaPssPrivateKey()

error_t pemExportRsaPssPrivateKey ( const RsaPrivateKey privateKey,
char_t output,
size_t *  written 
)

Export an RSA-PSS private key to PEM format.

Parameters
[in]privateKeyRSA-PSS private key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 365 of file pem_export.c.

◆ pemExportRsaPssPublicKey()

error_t pemExportRsaPssPublicKey ( const RsaPublicKey publicKey,
char_t output,
size_t *  written 
)

Export an RSA-PSS public key to PEM format.

Parameters
[in]publicKeyRSA-PSS public key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 312 of file pem_export.c.

◆ pemExportRsaPublicKey()

error_t pemExportRsaPublicKey ( const RsaPublicKey publicKey,
char_t output,
size_t *  written 
)

Export an RSA public key to PEM format.

Parameters
[in]publicKeyRSA public key
[out]outputBuffer where to store the PEM encoding
[out]writtenLength of the resulting PEM encoding
Returns
Error code

Definition at line 155 of file pem_export.c.