ssh_key_import.h
Go to the documentation of this file.
1 /**
2  * @file ssh_key_import.h
3  * @brief SSH key file import functions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSH 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 2.4.4
29  **/
30 
31 #ifndef _SSH_KEY_IMPORT_H
32 #define _SSH_KEY_IMPORT_H
33 
34 //Dependencies
35 #include "ssh_types.h"
36 #include "ssh_key_parse.h"
37 #include "pkix/x509_common.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 
49 /**
50  * @brief SSH key type
51  **/
52 
53 typedef struct
54 {
57  const char_t *curveName;
58 } SshKeyType;
59 
60 
61 //SSH key file import functions
62 error_t sshImportRsaPublicKey(const char_t *input, size_t length,
63  RsaPublicKey *publicKey);
64 
65 error_t sshImportDsaPublicKey(const char_t *input, size_t length,
66  DsaPublicKey *publicKey);
67 
68 error_t sshImportEcdsaPublicKey(const char_t *input, size_t length,
69  EcDomainParameters *params, EcPublicKey *publicKey);
70 
71 error_t sshImportEd25519PublicKey(const char_t *input, size_t length,
72  EddsaPublicKey *publicKey);
73 
74 error_t sshImportEd448PublicKey(const char_t *input, size_t length,
75  EddsaPublicKey *publicKey);
76 
77 error_t sshImportRsaPrivateKey(const char_t *input, size_t length,
78  const char_t *password, RsaPrivateKey *privateKey);
79 
80 error_t sshImportDsaPrivateKey(const char_t *input, size_t length,
81  const char_t *password, DsaPrivateKey *privateKey);
82 
83 error_t sshImportEcdsaPrivateKey(const char_t *input, size_t length,
84  const char_t *password, EcPrivateKey *privateKey);
85 
86 error_t sshImportEd25519PrivateKey(const char_t *input, size_t length,
87  const char_t *password, EddsaPrivateKey *privateKey);
88 
89 error_t sshImportEd448PrivateKey(const char_t *input, size_t length,
90  const char_t *password, EddsaPrivateKey *privateKey);
91 
93  RsaPublicKey *publicKey);
94 
96  DsaPublicKey *publicKey);
97 
99  EcDomainParameters *params, EcPublicKey *publicKey);
100 
102  EddsaPublicKey *publicKey);
103 
105  EddsaPublicKey *publicKey);
106 
107 const char_t *sshGetPublicKeyType(const char_t *input, size_t length);
108 
109 error_t sshDecodePublicKeyFile(const char_t *input, size_t inputLen,
110  uint8_t *output, size_t *outputLen);
111 
112 error_t sshDecodeSsh2PublicKeyFile(const char_t *input, size_t inputLen,
113  uint8_t *output, size_t *outputLen);
114 
115 error_t sshDecodeOpenSshPublicKeyFile(const char_t *input, size_t inputLen,
116  uint8_t *output, size_t *outputLen);
117 
118 error_t sshDecodeOpenSshPrivateKeyFile(const char_t *input, size_t inputLen,
119  uint8_t *output, size_t *outputLen);
120 
121 int_t sshSearchMarker(const char_t *s, size_t sLen, const char_t *marker,
122  size_t markerLen);
123 
124 //C++ guard
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif
X.509 common definitions.
error_t sshImportRsaPrivateKey(const char_t *input, size_t length, const char_t *password, RsaPrivateKey *privateKey)
Decode an SSH private key file containing an RSA private key.
error_t sshDecodeSsh2PublicKeyFile(const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen)
Decode SSH public key file (SSH2 format)
error_t sshImportDsaHostKey(const SshDsaHostKey *hostKey, DsaPublicKey *publicKey)
Import a DSA host key.
error_t sshImportDsaPrivateKey(const char_t *input, size_t length, const char_t *password, DsaPrivateKey *privateKey)
Decode an SSH private key file containing a DSA private key.
signed int int_t
Definition: compiler_port.h:49
DSA host key.
Definition: ssh_key_parse.h:64
error_t sshImportEd448HostKey(const SshEddsaHostKey *hostKey, EddsaPublicKey *publicKey)
Import an Ed448 host key.
error_t sshImportEcdsaPublicKey(const char_t *input, size_t length, EcDomainParameters *params, EcPublicKey *publicKey)
Decode an SSH public key file containing an ECDSA public key.
error_t sshImportRsaPublicKey(const char_t *input, size_t length, RsaPublicKey *publicKey)
Decode an SSH public key file containing an RSA public key.
SSH key parsing.
EC domain parameters.
Definition: ec.h:76
error_t sshImportEd448PublicKey(const char_t *input, size_t length, EddsaPublicKey *publicKey)
Decode an SSH public key file containing an Ed448 public key.
DSA public key.
Definition: dsa.h:61
error_t
Error codes.
Definition: error.h:43
EdDSA public key.
Definition: eddsa.h:49
const char_t * sshGetPublicKeyType(const char_t *input, size_t length)
Get SSH public key type.
RSA public key.
Definition: rsa.h:57
const char_t * identifier
error_t sshImportEcdsaHostKey(const SshEcdsaHostKey *hostKey, EcDomainParameters *params, EcPublicKey *publicKey)
Import a ECDSA host key.
EdDSA (Edwards-Curve Digital Signature Algorithm)
RSA public-key cryptography standard.
DSA (Digital Signature Algorithm)
EC private key.
Definition: ec.h:104
DSA private key.
Definition: dsa.h:72
EdDSA host key.
Definition: ssh_key_parse.h:90
int_t sshSearchMarker(const char_t *s, size_t sLen, const char_t *marker, size_t markerLen)
Search a string for a given marker.
uint8_t length
Definition: tcp.h:368
error_t sshDecodeOpenSshPrivateKeyFile(const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen)
Decode SSH private key file (OpenSSH format)
EdDSA private key.
Definition: eddsa.h:59
error_t sshDecodePublicKeyFile(const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen)
Decode SSH public key file (SSH2 or OpenSSH format)
error_t sshImportEd25519PrivateKey(const char_t *input, size_t length, const char_t *password, EddsaPrivateKey *privateKey)
Decode an SSH private key file containing an Ed25519 private key.
EC public key.
Definition: ec.h:94
char char_t
Definition: compiler_port.h:48
error_t sshDecodeOpenSshPublicKeyFile(const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen)
Decode SSH public key file (OpenSSH format)
SSH data type representations.
RSA private key.
Definition: rsa.h:68
error_t sshImportEd448PrivateKey(const char_t *input, size_t length, const char_t *password, EddsaPrivateKey *privateKey)
Decode an SSH private key file containing an Ed448 private key.
error_t sshImportEd25519HostKey(const SshEddsaHostKey *hostKey, EddsaPublicKey *publicKey)
Import an Ed25519 host key.
ECDSA host key.
Definition: ssh_key_parse.h:78
const char_t * curveName
error_t sshImportDsaPublicKey(const char_t *input, size_t length, DsaPublicKey *publicKey)
Decode an SSH public key file containing a DSA public key.
error_t sshImportRsaHostKey(const SshRsaHostKey *hostKey, RsaPublicKey *publicKey)
Import an RSA host key.
RSA host key.
Definition: ssh_key_parse.h:52
SSH key type.
uint8_t s
Definition: igmp_common.h:234
X509KeyType type
error_t sshImportEcdsaPrivateKey(const char_t *input, size_t length, const char_t *password, EcPrivateKey *privateKey)
Decode an SSH private key file containing an ECDSA private key.
X509KeyType
Public Key types.
Definition: x509_common.h:585
ECC (Elliptic Curve Cryptography)
error_t sshImportEd25519PublicKey(const char_t *input, size_t length, EddsaPublicKey *publicKey)
Decode an SSH public key file containing an Ed25519 public key.