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-2026 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.6.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 #include "pqc/mldsa.h"
43 
44 //C++ guard
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 
50 /**
51  * @brief SSH key type
52  **/
53 
54 typedef struct
55 {
58  const char_t *curveName;
59 } SshKeyType;
60 
61 
62 //SSH key file import functions
63 error_t sshImportRsaPublicKey(RsaPublicKey *publicKey, const char_t *input,
64  size_t length);
65 
66 error_t sshImportDsaPublicKey(DsaPublicKey *publicKey, const char_t *input,
67  size_t length);
68 
69 error_t sshImportEcdsaPublicKey(EcPublicKey *publicKey, const char_t *input,
70  size_t length);
71 
73  const char_t *input, size_t length);
74 
75 error_t sshImportEd448PublicKey(EddsaPublicKey *publicKey, const char_t *input,
76  size_t length);
77 
78 error_t sshImportMldsaPublicKey(MldsaPublicKey *publicKey, const char_t *input,
79  size_t length);
80 
81 error_t sshImportRsaPrivateKey(RsaPrivateKey *privateKey, const char_t *input,
82  size_t length, const char_t *password);
83 
84 error_t sshImportDsaPrivateKey(DsaPrivateKey *privateKey, const char_t *input,
85  size_t length, const char_t *password);
86 
87 error_t sshImportEcdsaPrivateKey(EcPrivateKey *privateKey, const char_t *input,
88  size_t length, const char_t *password);
89 
91  const char_t *input, size_t length, const char_t *password);
92 
94  const char_t *input, size_t length, const char_t *password);
95 
97  const SshRsaHostKey *hostKey);
98 
100  const SshDsaHostKey *hostKey);
101 
103  const SshEcdsaHostKey *hostKey);
104 
105 const char_t *sshGetPublicKeyType(const char_t *input, size_t length);
106 
107 error_t sshDecodePublicKeyFile(const char_t *input, size_t inputLen,
108  uint8_t *output, size_t *outputLen);
109 
110 error_t sshDecodeSsh2PublicKeyFile(const char_t *input, size_t inputLen,
111  uint8_t *output, size_t *outputLen);
112 
113 error_t sshDecodeOpenSshPublicKeyFile(const char_t *input, size_t inputLen,
114  uint8_t *output, size_t *outputLen);
115 
116 error_t sshDecodeOpenSshPrivateKeyFile(const char_t *input, size_t inputLen,
117  uint8_t *output, size_t *outputLen);
118 
119 int_t sshSearchMarker(const char_t *s, size_t sLen, const char_t *marker,
120  size_t markerLen);
121 
122 //C++ guard
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #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.
error_t sshImportMldsaPublicKey(MldsaPublicKey *publicKey, const char_t *input, size_t length)
Decode an SSH public key file containing an ML-DSA public 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.
ML-DSA public key.
Definition: mldsa.h:82
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)
ML-DSA (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:657
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.