Go to the documentation of this file.
1 /**
2  * @file pem_import.h
3  * @brief PEM file import functions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 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
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 (
28  * @version 2.4.2
29  **/
31 #ifndef _PEM_IMPORT_H
32 #define _PEM_IMPORT_H
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkix/pem_common.h"
37 #include "pkix/x509_common.h"
38 #include "pkc/dh.h"
39 #include "pkc/rsa.h"
40 #include "pkc/dsa.h"
41 #include "ecc/ec.h"
42 #include "ecc/eddsa.h"
44 //C++ guard
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
49 //PEM related functions
50 error_t pemImportCertificate(const char_t *input, size_t inputLen,
51  uint8_t *output, size_t *outputLen, size_t *consumed);
53 error_t pemImportCrl(const char_t *input, size_t inputLen,
54  uint8_t *output, size_t *outputLen, size_t *consumed);
56 error_t pemImportCsr(const char_t *input, size_t inputLen,
57  uint8_t *output, size_t *outputLen);
59 error_t pemImportDhParameters(const char_t *input, size_t length,
60  DhParameters *params);
62 error_t pemImportRsaPublicKey(const char_t *input, size_t length,
63  RsaPublicKey *publicKey);
65 error_t pemImportRsaPrivateKey(const char_t *input, size_t length,
66  const char_t *password, RsaPrivateKey *privateKey);
68 error_t pemImportDsaPublicKey(const char_t *input, size_t length,
69  DsaPublicKey *publicKey);
71 error_t pemImportDsaPrivateKey(const char_t *input, size_t length,
72  const char_t *password, DsaPrivateKey *privateKey);
74 error_t pemImportEcParameters(const char_t *input, size_t length,
75  EcDomainParameters *params);
77 error_t pemImportEcPublicKey(const char_t *input, size_t length,
78  EcPublicKey *publicKey);
80 error_t pemImportEcPrivateKey(const char_t *input, size_t length,
81  const char_t *password, EcPrivateKey *privateKey);
83 error_t pemImportEddsaPublicKey(const char_t *input, size_t length,
84  EddsaPublicKey *publicKey);
86 error_t pemImportEddsaPrivateKey(const char_t *input, size_t length,
87  const char_t *password, EddsaPrivateKey *privateKey);
89 error_t pemGetPublicKeyType(const char_t *input, size_t length,
90  X509KeyType *keyType);
92 error_t pemGetPrivateKeyType(const char_t *input, size_t length,
93  X509KeyType *keyType);
95 //C++ guard
96 #ifdef __cplusplus
97 }
98 #endif
100 #endif
X.509 common definitions.
error_t pemImportRsaPublicKey(const char_t *input, size_t length, RsaPublicKey *publicKey)
Decode a PEM file containing an RSA public key.
Definition: pem_import.c:260
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.
Definition: pem_import.c:121
error_t pemImportDsaPublicKey(const char_t *input, size_t length, DsaPublicKey *publicKey)
Decode a PEM file containing a DSA public key.
Definition: pem_import.c:594
PEM common definitions.
error_t pemGetPublicKeyType(const char_t *input, size_t length, X509KeyType *keyType)
Retrieve the type of a PEM-encoded public key.
Definition: pem_import.c:1598
EC domain parameters.
Definition: ec.h:76
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.
Definition: pem_import.c:1163
Diffie-Hellman key exchange.
error_t pemImportEcParameters(const char_t *input, size_t length, EcDomainParameters *params)
Decode a PEM file containing EC domain parameters.
Definition: pem_import.c:881
DSA public key.
Definition: dsa.h:61
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.
Definition: pem_import.c:1450
Error codes.
Definition: error.h:43
error_t pemImportEcPublicKey(const char_t *input, size_t length, EcPublicKey *publicKey)
Decode a PEM file containing an EC public key.
Definition: pem_import.c:1081
EdDSA public key.
Definition: eddsa.h:49
error_t pemImportEddsaPublicKey(const char_t *input, size_t length, EddsaPublicKey *publicKey)
Decode a PEM file containing a EdDSA public key.
Definition: pem_import.c:1368
RSA public key.
Definition: rsa.h:57
EdDSA (Edwards-Curve Digital Signature Algorithm)
General definitions for cryptographic algorithms.
RSA public-key cryptography standard.
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.
Definition: pem_import.c:92
DSA (Digital Signature Algorithm)
EC private key.
Definition: ec.h:104
DSA private key.
Definition: dsa.h:72
uint8_t length
Definition: tcp.h:368
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.
Definition: pem_import.c:61
EdDSA private key.
Definition: eddsa.h:59
EC public key.
Definition: ec.h:94
char char_t
Definition: compiler_port.h:48
error_t pemGetPrivateKeyType(const char_t *input, size_t length, X509KeyType *keyType)
Retrieve the type of a PEM-encoded private key.
Definition: pem_import.c:1707
error_t pemImportDhParameters(const char_t *input, size_t length, DhParameters *params)
Decode a PEM file containing Diffie-Hellman parameters.
Definition: pem_import.c:149
RSA private key.
Definition: rsa.h:68
Diffie-Hellman parameters.
Definition: dh.h:49
Public Key types.
Definition: x509_common.h:578
ECC (Elliptic Curve Cryptography)
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.
Definition: pem_import.c:676
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.
Definition: pem_import.c:389