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-2025 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.5.0
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(RsaPublicKey *publicKey, const char_t *input,
63  size_t length);
64 
65 error_t sshImportDsaPublicKey(DsaPublicKey *publicKey, const char_t *input,
66  size_t length);
67 
68 error_t sshImportEcdsaPublicKey(EcPublicKey *publicKey, const char_t *input,
69  size_t length);
70 
72  const char_t *input, size_t length);
73 
75  const char_t *input, size_t length);
76 
77 error_t sshImportRsaPrivateKey(RsaPrivateKey *privateKey, const char_t *input,
78  size_t length, const char_t *password);
79 
80 error_t sshImportDsaPrivateKey(DsaPrivateKey *privateKey, const char_t *input,
81  size_t length, const char_t *password);
82 
83 error_t sshImportEcdsaPrivateKey(EcPrivateKey *privateKey, const char_t *input,
84  size_t length, const char_t *password);
85 
87  const char_t *input, size_t length, const char_t *password);
88 
90  const char_t *input, size_t length, const char_t *password);
91 
93  const SshRsaHostKey *hostKey);
94 
96  const SshDsaHostKey *hostKey);
97 
99  const SshEcdsaHostKey *hostKey);
100 
101 const char_t *sshGetPublicKeyType(const char_t *input, size_t length);
102 
103 error_t sshDecodePublicKeyFile(const char_t *input, size_t inputLen,
104  uint8_t *output, size_t *outputLen);
105 
106 error_t sshDecodeSsh2PublicKeyFile(const char_t *input, size_t inputLen,
107  uint8_t *output, size_t *outputLen);
108 
109 error_t sshDecodeOpenSshPublicKeyFile(const char_t *input, size_t inputLen,
110  uint8_t *output, size_t *outputLen);
111 
112 error_t sshDecodeOpenSshPrivateKeyFile(const char_t *input, size_t inputLen,
113  uint8_t *output, size_t *outputLen);
114 
115 int_t sshSearchMarker(const char_t *s, size_t sLen, const char_t *marker,
116  size_t markerLen);
117 
118 //C++ guard
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif
X.509 common definitions.
error_t sshDecodeSsh2PublicKeyFile(const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen)
Decode SSH public key file (SSH2 format)
signed int int_t
Definition: compiler_port.h:56
DSA host key.
Definition: ssh_key_parse.h:64
error_t sshImportRsaPrivateKey(RsaPrivateKey *privateKey, const char_t *input, size_t length, const char_t *password)
Decode an SSH private key file containing an RSA private key.
error_t sshImportDsaPrivateKey(DsaPrivateKey *privateKey, const char_t *input, size_t length, const char_t *password)
Decode an SSH private key file containing a DSA private key.
SSH key parsing.
error_t sshImportEd25519PublicKey(EddsaPublicKey *publicKey, const char_t *input, size_t length)
Decode an SSH public key file containing an Ed25519 public key.
error_t sshImportEcdsaHostKey(EcPublicKey *publicKey, const SshEcdsaHostKey *hostKey)
Import a ECDSA host key.
DSA public key.
Definition: dsa.h:61
error_t sshImportEd448PrivateKey(EddsaPrivateKey *privateKey, const char_t *input, size_t length, const char_t *password)
Decode an SSH private key file containing an Ed448 private key.
error_t
Error codes.
Definition: error.h:43
EdDSA public key.
Definition: eddsa.h:64
const char_t * sshGetPublicKeyType(const char_t *input, size_t length)
Get SSH public key type.
error_t sshImportRsaHostKey(RsaPublicKey *publicKey, const SshRsaHostKey *hostKey)
Import an RSA host key.
RSA public key.
Definition: rsa.h:57
const char_t * identifier
error_t sshImportDsaHostKey(DsaPublicKey *publicKey, const SshDsaHostKey *hostKey)
Import a DSA host key.
EdDSA (Edwards-Curve Digital Signature Algorithm)
RSA public-key cryptography standard.
DSA (Digital Signature Algorithm)
EC private key.
Definition: ec.h:432
DSA private key.
Definition: dsa.h:72
error_t sshImportEcdsaPrivateKey(EcPrivateKey *privateKey, const char_t *input, size_t length, const char_t *password)
Decode an SSH private key file containing an ECDSA private key.
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:375
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:75
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)
EC public key.
Definition: ec.h:421
error_t sshImportEcdsaPublicKey(EcPublicKey *publicKey, const char_t *input, size_t length)
Decode an SSH public key file containing an ECDSA public key.
char char_t
Definition: compiler_port.h:55
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 sshImportEd448PublicKey(EddsaPublicKey *publicKey, const char_t *input, size_t length)
Decode an SSH public key file containing an Ed448 public key.
ECDSA host key.
Definition: ssh_key_parse.h:78
const char_t * curveName
RSA host key.
Definition: ssh_key_parse.h:52
SSH key type.
uint8_t s
Definition: igmp_common.h:234
X509KeyType type
error_t sshImportEd25519PrivateKey(EddsaPrivateKey *privateKey, const char_t *input, size_t length, const char_t *password)
Decode an SSH private key file containing an Ed25519 private key.
error_t sshImportDsaPublicKey(DsaPublicKey *publicKey, const char_t *input, size_t length)
Decode an SSH public key file containing a DSA public key.
X509KeyType
Public Key types.
Definition: x509_common.h:633
ECC (Elliptic Curve Cryptography)
error_t sshImportRsaPublicKey(RsaPublicKey *publicKey, const char_t *input, size_t length)
Decode an SSH public key file containing an RSA public key.