pem_key_export.c File Reference

PEM key file export functions. More...

#include "core/crypto.h"
#include "pkix/pem_key_export.h"
#include "pkix/pkcs8_key_format.h"
#include "pkix/x509_key_format.h"
#include "encoding/asn1.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t pemExportRsaPublicKey (const RsaPublicKey *publicKey, char_t *output, size_t *written, PemPublicKeyFormat format)
 Export an RSA public key to PEM format. More...
 
error_t pemExportRsaPrivateKey (const RsaPrivateKey *privateKey, char_t *output, size_t *written, PemPrivateKeyFormat format)
 Export an RSA private key to PEM format. More...
 
error_t pemExportRsaPssPublicKey (const RsaPublicKey *publicKey, char_t *output, size_t *written, PemPublicKeyFormat format)
 Export an RSA-PSS public key to PEM format. More...
 
error_t pemExportRsaPssPrivateKey (const RsaPrivateKey *privateKey, char_t *output, size_t *written, PemPrivateKeyFormat format)
 Export an RSA-PSS private key to PEM format. More...
 
error_t pemExportDsaPublicKey (const DsaPublicKey *publicKey, char_t *output, size_t *written, PemPublicKeyFormat format)
 Export a DSA public key to PEM format. More...
 
error_t pemExportDsaPrivateKey (const DsaPrivateKey *privateKey, char_t *output, size_t *written, PemPrivateKeyFormat format)
 Export a DSA private key to PEM format. More...
 
error_t pemExportEcPublicKey (const EcPublicKey *publicKey, char_t *output, size_t *written, PemPublicKeyFormat format)
 Export an EC public key to PEM format. More...
 
error_t pemExportEcPrivateKey (const EcPrivateKey *privateKey, char_t *output, size_t *written, PemPrivateKeyFormat format)
 Export an EC private key to PEM format. More...
 
error_t pemExportEddsaPublicKey (const EddsaPublicKey *publicKey, char_t *output, size_t *written, PemPublicKeyFormat format)
 Export an EdDSA public key to PEM format. More...
 
error_t pemExportEddsaPrivateKey (const EddsaPrivateKey *privateKey, char_t *output, size_t *written, PemPrivateKeyFormat format)
 Export an EdDSA private key to PEM format. More...
 

Detailed Description

PEM key file export functions.

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.2

Definition in file pem_key_export.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pem_key_export.c.

Function Documentation

◆ pemExportDsaPrivateKey()

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

Export a DSA private key to PEM format.

Parameters
[in]privateKeyDSA private key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (PKCS #8 format only)
Returns
Error code

Definition at line 482 of file pem_key_export.c.

◆ pemExportDsaPublicKey()

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

Export a DSA public key to PEM format.

Parameters
[in]publicKeyDSA public key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (RFC 7468 format only)
Returns
Error code

Definition at line 421 of file pem_key_export.c.

◆ pemExportEcPrivateKey()

error_t pemExportEcPrivateKey ( const EcPrivateKey privateKey,
char_t output,
size_t *  written,
PemPrivateKeyFormat  format 
)

Export an EC private key to PEM format.

Parameters
[in]privateKeyEC private key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (RFC 5915 or PKCS #8 format)
Returns
Error code

Definition at line 659 of file pem_key_export.c.

◆ pemExportEcPublicKey()

error_t pemExportEcPublicKey ( const EcPublicKey publicKey,
char_t output,
size_t *  written,
PemPublicKeyFormat  format 
)

Export an EC public key to PEM format.

Parameters
[in]publicKeyEC public key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (RFC 7468 format only)
Returns
Error code

Definition at line 592 of file pem_key_export.c.

◆ pemExportEddsaPrivateKey()

error_t pemExportEddsaPrivateKey ( const EddsaPrivateKey privateKey,
char_t output,
size_t *  written,
PemPrivateKeyFormat  format 
)

Export an EdDSA private key to PEM format.

Parameters
[in]privateKeyEdDSA private key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (PKCS #8 v1 or v2 format)
Returns
Error code

Definition at line 855 of file pem_key_export.c.

◆ pemExportEddsaPublicKey()

error_t pemExportEddsaPublicKey ( const EddsaPublicKey publicKey,
char_t output,
size_t *  written,
PemPublicKeyFormat  format 
)

Export an EdDSA public key to PEM format.

Parameters
[in]publicKeyEdDSA public key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (RFC 7468 format only)
Returns
Error code

Definition at line 790 of file pem_key_export.c.

◆ pemExportRsaPrivateKey()

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

Export an RSA private key to PEM format.

Parameters
[in]privateKeyRSA private key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (PKCS #1 or PKCS #8 format)
Returns
Error code

Definition at line 129 of file pem_key_export.c.

◆ pemExportRsaPssPrivateKey()

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

Export an RSA-PSS private key to PEM format.

Parameters
[in]privateKeyRSA-PSS private key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (PKCS #8 format only)
Returns
Error code

Definition at line 312 of file pem_key_export.c.

◆ pemExportRsaPssPublicKey()

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

Export an RSA-PSS public key to PEM format.

Parameters
[in]publicKeyRSA-PSS public key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (RFC 7468 format only)
Returns
Error code

Definition at line 251 of file pem_key_export.c.

◆ pemExportRsaPublicKey()

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

Export an RSA public key to PEM format.

Parameters
[in]publicKeyRSA public key
[out]outputBuffer where to store the PEM string (optional parameter)
[out]writtenLength of the resulting PEM string
[in]formatDesired output format (PKCS #1 or RFC 7468 format)
Returns
Error code

Definition at line 55 of file pem_key_export.c.