pem_export.h
Go to the documentation of this file.
1 /**
2  * @file pem_export.h
3  * @brief PEM file export functions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCrypto Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _PEM_EXPORT_H
32 #define _PEM_EXPORT_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkc/dh.h"
37 #include "pkc/rsa.h"
38 #include "pkc/dsa.h"
39 #include "ecc/ec.h"
40 #include "ecc/eddsa.h"
41 
42 //C++ guard
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 //PEM related functions
48 error_t pemExportCertificate(const uint8_t *cert, size_t certLen,
49  char_t *output, size_t *written);
50 
51 error_t pemExportCrl(const uint8_t *crl, size_t crlLen,
52  char_t *output, size_t *written);
53 
54 error_t pemExportCsr(const uint8_t *csr, size_t csrLen,
55  char_t *output, size_t *written);
56 
58  char_t *output, size_t *written);
59 
61  char_t *output, size_t *written);
62 
64  char_t *output, size_t *written);
65 
67  char_t *output, size_t *written);
68 
70  char_t *output, size_t *written);
71 
73  char_t *output, size_t *written);
74 
76  char_t *output, size_t *written);
77 
79  const EcPoint *publicKey, char_t *output, size_t *written);
80 
82  const Mpi *privateKey, const EcPoint *publicKey, char_t *output,
83  size_t *written);
84 
86  const EddsaPublicKey *publicKey, char_t *output, size_t *written);
87 
89  const EddsaPrivateKey *privateKey, char_t *output, size_t *written);
90 
91 error_t pemEncodeFile(const void *input, size_t inputLen, const char_t *label,
92  char_t *output, size_t *outputLen);
93 
94 //C++ guard
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif
error_t pemExportDsaPublicKey(const DsaPublicKey *publicKey, char_t *output, size_t *written)
Export a DSA public key to PEM format.
Definition: pem_export.c:470
error_t pemExportCsr(const uint8_t *csr, size_t csrLen, char_t *output, size_t *written)
Export a certification signing request to PEM format.
Definition: pem_export.c:124
Arbitrary precision integer.
Definition: mpi.h:69
error_t pemExportEcPublicKey(const EcCurveInfo *curveInfo, const EcPoint *publicKey, char_t *output, size_t *written)
Export an EC public key to PEM format.
Definition: pem_export.c:685
error_t pemExportRsaPrivateKey(const RsaPrivateKey *privateKey, char_t *output, size_t *written)
Export an RSA private key to PEM format.
Definition: pem_export.c:209
error_t pemExportCertificate(const uint8_t *cert, size_t certLen, char_t *output, size_t *written)
Export an X.509 certificate to PEM format.
Definition: pem_export.c:58
error_t pemExportEddsaPrivateKey(const EcCurveInfo *curveInfo, const EddsaPrivateKey *privateKey, char_t *output, size_t *written)
Export an EdDSA private key to PEM format.
Definition: pem_export.c:904
Elliptic curve parameters.
Definition: ec_curves.h:292
Diffie-Hellman key exchange.
DSA public key.
Definition: dsa.h:60
error_t pemExportDsaPrivateKey(const DsaPrivateKey *privateKey, char_t *output, size_t *written)
Export a DSA private key to PEM format.
Definition: pem_export.c:523
error_t
Error codes.
Definition: error.h:42
EdDSA public key.
Definition: eddsa.h:48
RSA public key.
Definition: rsa.h:48
EdDSA (Edwards-Curve Digital Signature Algorithm)
General definitions for cryptographic algorithms.
RSA public-key cryptography standard.
DSA (Digital Signature Algorithm)
DSA private key.
Definition: dsa.h:73
Elliptic curve point.
Definition: ec.h:51
error_t pemExportRsaPublicKey(const RsaPublicKey *publicKey, char_t *output, size_t *written)
Export an RSA public key to PEM format.
Definition: pem_export.c:156
EdDSA private key.
Definition: eddsa.h:58
char char_t
Definition: compiler_port.h:43
RSA private key.
Definition: rsa.h:59
error_t pemExportEddsaPublicKey(const EcCurveInfo *curveInfo, const EddsaPublicKey *publicKey, char_t *output, size_t *written)
Export an EdDSA public key to PEM format.
Definition: pem_export.c:850
error_t pemExportRsaPssPrivateKey(const RsaPrivateKey *privateKey, char_t *output, size_t *written)
Export an RSA-PSS private key to PEM format.
Definition: pem_export.c:366
error_t pemExportCrl(const uint8_t *crl, size_t crlLen, char_t *output, size_t *written)
Export a certificate revocation list to PEM format.
Definition: pem_export.c:91
error_t pemExportRsaPssPublicKey(const RsaPublicKey *publicKey, char_t *output, size_t *written)
Export an RSA-PSS public key to PEM format.
Definition: pem_export.c:313
error_t pemExportEcParameters(const EcCurveInfo *curveInfo, char_t *output, size_t *written)
Export EC domain parameters to PEM format.
Definition: pem_export.c:633
ECC (Elliptic Curve Cryptography)
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.
Definition: pem_export.c:1009
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.
Definition: pem_export.c:742