pem_import.h
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-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_IMPORT_H
32 #define _PEM_IMPORT_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkix/x509_common.h"
37 #include "pkc/dh.h"
38 #include "pkc/rsa.h"
39 #include "pkc/dsa.h"
40 #include "ecc/ec.h"
41 #include "ecc/eddsa.h"
42 
43 //C++ guard
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 //PEM format decoding functions
49 error_t pemImportCertificate(const char_t *input, size_t inputLen,
50  uint8_t *output, size_t *outputLen, size_t *consumed);
51 
52 error_t pemImportCrl(const char_t *input, size_t inputLen,
53  uint8_t *output, size_t *outputLen, size_t *consumed);
54 
55 error_t pemImportCsr(const char_t *input, size_t inputLen,
56  uint8_t *output, size_t *outputLen);
57 
58 error_t pemImportDhParameters(const char_t *input, size_t length,
59  DhParameters *params);
60 
61 error_t pemImportRsaPublicKey(const char_t *input, size_t length,
62  RsaPublicKey *publicKey);
63 
64 error_t pemImportRsaPrivateKey(const char_t *input, size_t length,
65  RsaPrivateKey *privateKey);
66 
67 error_t pemImportDsaPublicKey(const char_t *input, size_t length,
68  DsaPublicKey *publicKey);
69 
70 error_t pemImportDsaPrivateKey(const char_t *input, size_t length,
71  DsaPrivateKey *privateKey);
72 
73 error_t pemImportEcParameters(const char_t *input, size_t length,
74  EcDomainParameters *params);
75 
76 error_t pemImportEcPublicKey(const char_t *input, size_t length,
77  EcPoint *publicKey);
78 
79 error_t pemImportEcPrivateKey(const char_t *input, size_t length,
80  Mpi *privateKey);
81 
82 error_t pemImportEddsaPublicKey(const char_t *input, size_t length,
83  EddsaPublicKey *publicKey);
84 
85 error_t pemImportEddsaPrivateKey(const char_t *input, size_t length,
86  EddsaPrivateKey *privateKey);
87 
88 error_t pemGetPublicKeyType(const char_t *input, size_t length,
89  X509KeyType *keyType);
90 
91 error_t pemGetPrivateKeyType(const char_t *input, size_t length,
92  X509KeyType *keyType);
93 
94 error_t pemDecodeFile(const char_t *input, size_t inputLen, const char_t *label,
95  uint8_t *output, size_t *outputLen, size_t *consumed);
96 
97 int_t pemFindTag(const char_t *input, size_t inputLen, const char_t *tag1,
98  const char_t *tag2, const char_t *tag3);
99 
100 //C++ guard
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif
X.509 common definitions.
uint8_t length
Definition: dtls_misc.h:149
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:258
error_t pemImportDsaPrivateKey(const char_t *input, size_t length, DsaPrivateKey *privateKey)
Decode a PEM file containing a DSA private key.
Definition: pem_import.c:585
Arbitrary precision integer.
Definition: mpi.h:69
signed int int_t
Definition: compiler_port.h:44
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:120
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:506
error_t pemDecodeFile(const char_t *input, size_t inputLen, const char_t *label, uint8_t *output, size_t *outputLen, size_t *consumed)
Convert PEM container to ASN.1 format.
Definition: pem_import.c:1468
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:1264
EC domain parameters.
Definition: ec.h:63
error_t pemImportEcPublicKey(const char_t *input, size_t length, EcPoint *publicKey)
Decode a PEM file containing an EC public key.
Definition: pem_import.c:904
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:709
DSA public key.
Definition: dsa.h:60
error_t
Error codes.
Definition: error.h:42
EdDSA public key.
Definition: eddsa.h:48
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:1107
RSA public key.
Definition: rsa.h:48
EdDSA (Edwards-Curve Digital Signature Algorithm)
error_t pemImportRsaPrivateKey(const char_t *input, size_t length, RsaPrivateKey *privateKey)
Decode a PEM file containing an RSA private key.
Definition: pem_import.c:382
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:91
DSA (Digital Signature Algorithm)
DSA private key.
Definition: dsa.h:73
Elliptic curve point.
Definition: ec.h:51
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:60
EdDSA private key.
Definition: eddsa.h:58
char char_t
Definition: compiler_port.h:43
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:1356
error_t pemImportDhParameters(const char_t *input, size_t length, DhParameters *params)
Decode a PEM file containing Diffie-Hellman parameters.
Definition: pem_import.c:148
int_t pemFindTag(const char_t *input, size_t inputLen, const char_t *tag1, const char_t *tag2, const char_t *tag3)
Search a string for a given tag.
Definition: pem_import.c:1534
RSA private key.
Definition: rsa.h:59
error_t pemImportEcPrivateKey(const char_t *input, size_t length, Mpi *privateKey)
Decode a PEM file containing an EC private key.
Definition: pem_import.c:983
error_t pemImportEddsaPrivateKey(const char_t *input, size_t length, EddsaPrivateKey *privateKey)
Decode a PEM file containing a EdDSA private key.
Definition: pem_import.c:1186
Diffie-Hellman parameters.
Definition: dh.h:48
X509KeyType
Public Key types.
Definition: x509_common.h:503
ECC (Elliptic Curve Cryptography)