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 "encoding/base64.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 EcPoint *publicKey, char_t *output, size_t *written)
 Export an EC public key to PEM format. More...
 
error_t pemExportEcPrivateKey (const EcCurveInfo *curveInfo, const Mpi *privateKey, const EcPoint *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...
 
error_t pemEncodeFile (const void *input, size_t inputLen, const char_t *label, char_t *output, size_t *outputLen)
 Convert ASN.1 data to PEM encoding. More...
 

Detailed Description

PEM file export functions.

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

◆ pemEncodeFile()

error_t pemEncodeFile ( const void *  input,
size_t  inputLen,
const char_t label,
char_t output,
size_t *  outputLen 
)

Convert ASN.1 data to PEM encoding.

Parameters
[in]inputASN.1 data to encode
[in]inputLenLength of the ASN.1 data to encode
[in]labelLabel indicating the type of data
[out]outputPEM container (optional parameter)
[out]outputLenLength of the PEM container

Definition at line 1009 of file pem_export.c.

◆ 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 58 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 91 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 124 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 523 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 470 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 633 of file pem_export.c.

◆ pemExportEcPrivateKey()

error_t pemExportEcPrivateKey ( const EcCurveInfo curveInfo,
const Mpi privateKey,
const EcPoint 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 742 of file pem_export.c.

◆ pemExportEcPublicKey()

error_t pemExportEcPublicKey ( const EcCurveInfo curveInfo,
const EcPoint 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 685 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 904 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 850 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 209 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 366 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 313 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 156 of file pem_export.c.