SSH key file import functions. More...
#include "ssh/ssh.h"#include "ssh/ssh_key_import.h"#include "ssh/ssh_key_parse.h"#include "ssh/ssh_key_decrypt.h"#include "ssh/ssh_misc.h"#include "encoding/base64.h"#include "pkix/pem_key_import.h"#include "ecc/ec_misc.h"#include "debug.h"Go to the source code of this file.
| Macros | |
| #define | TRACE_LEVEL SSH_TRACE_LEVEL | 
| Functions | |
| error_t | sshImportRsaPublicKey (RsaPublicKey *publicKey, const char_t *input, size_t length) | 
| Decode an SSH public key file containing an RSA public key.  More... | |
| error_t | sshImportDsaPublicKey (DsaPublicKey *publicKey, const char_t *input, size_t length) | 
| Decode an SSH public key file containing a DSA public key.  More... | |
| error_t | sshImportEcdsaPublicKey (EcPublicKey *publicKey, const char_t *input, size_t length) | 
| Decode an SSH public key file containing an ECDSA public key.  More... | |
| error_t | sshImportEd25519PublicKey (EddsaPublicKey *publicKey, const char_t *input, size_t length) | 
| Decode an SSH public key file containing an Ed25519 public key.  More... | |
| error_t | sshImportEd448PublicKey (EddsaPublicKey *publicKey, const char_t *input, size_t length) | 
| Decode an SSH public key file containing an Ed448 public key.  More... | |
| 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.  More... | |
| 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.  More... | |
| 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.  More... | |
| 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.  More... | |
| 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.  More... | |
| error_t | sshImportRsaHostKey (RsaPublicKey *publicKey, const SshRsaHostKey *hostKey) | 
| Import an RSA host key.  More... | |
| error_t | sshImportDsaHostKey (DsaPublicKey *publicKey, const SshDsaHostKey *hostKey) | 
| Import a DSA host key.  More... | |
| error_t | sshImportEcdsaHostKey (EcPublicKey *publicKey, const SshEcdsaHostKey *hostKey) | 
| Import a ECDSA host key.  More... | |
| const char_t * | sshGetPublicKeyType (const char_t *input, size_t length) | 
| Get SSH public key type.  More... | |
| 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)  More... | |
| error_t | sshDecodeSsh2PublicKeyFile (const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen) | 
| Decode SSH public key file (SSH2 format)  More... | |
| error_t | sshDecodeOpenSshPublicKeyFile (const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen) | 
| Decode SSH public key file (OpenSSH format)  More... | |
| error_t | sshDecodeOpenSshPrivateKeyFile (const char_t *input, size_t inputLen, uint8_t *output, size_t *outputLen) | 
| Decode SSH private key file (OpenSSH format)  More... | |
| int_t | sshSearchMarker (const char_t *s, size_t sLen, const char_t *marker, size_t markerLen) | 
| Search a string for a given marker.  More... | |
Detailed Description
SSH key file import functions.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2019-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneSSH Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file ssh_key_import.c.
Macro Definition Documentation
◆ TRACE_LEVEL
| #define TRACE_LEVEL SSH_TRACE_LEVEL | 
Definition at line 32 of file ssh_key_import.c.
Function Documentation
◆ sshDecodeOpenSshPrivateKeyFile()
| error_t sshDecodeOpenSshPrivateKeyFile | ( | const char_t * | input, | 
| size_t | inputLen, | ||
| uint8_t * | output, | ||
| size_t * | outputLen | ||
| ) | 
Decode SSH private key file (OpenSSH format)
- Parameters
- 
  [in] input SSH public key file to decode [in] inputLen Length of the SSH private key file to decode [out] output Pointer to the decoded data (optional parameter) [out] outputLen Length of the decoded data 
Definition at line 1683 of file ssh_key_import.c.
◆ sshDecodeOpenSshPublicKeyFile()
| error_t sshDecodeOpenSshPublicKeyFile | ( | const char_t * | input, | 
| size_t | inputLen, | ||
| uint8_t * | output, | ||
| size_t * | outputLen | ||
| ) | 
Decode SSH public key file (OpenSSH format)
- Parameters
- 
  [in] input SSH public key file to decode [in] inputLen Length of the SSH public key file to decode [out] output Pointer to the decoded data (optional parameter) [out] outputLen Length of the decoded data 
Definition at line 1608 of file ssh_key_import.c.
◆ sshDecodePublicKeyFile()
| 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)
- Parameters
- 
  [in] input SSH public key file to decode [in] inputLen Length of the SSH public key file to decode [out] output Pointer to the decoded data (optional parameter) [out] outputLen Length of the decoded data 
Definition at line 1459 of file ssh_key_import.c.
◆ sshDecodeSsh2PublicKeyFile()
| error_t sshDecodeSsh2PublicKeyFile | ( | const char_t * | input, | 
| size_t | inputLen, | ||
| uint8_t * | output, | ||
| size_t * | outputLen | ||
| ) | 
Decode SSH public key file (SSH2 format)
- Parameters
- 
  [in] input SSH public key file to decode [in] inputLen Length of the SSH public key file to decode [out] output Pointer to the decoded data (optional parameter) [out] outputLen Length of the decoded data 
Definition at line 1487 of file ssh_key_import.c.
◆ sshGetPublicKeyType()
Get SSH public key type.
- Parameters
- 
  [in] input SSH public key file [in] length Length of the SSH public key file 
- Returns
- SSH public key type
Definition at line 1331 of file ssh_key_import.c.
◆ sshImportDsaHostKey()
| error_t sshImportDsaHostKey | ( | DsaPublicKey * | publicKey, | 
| const SshDsaHostKey * | hostKey | ||
| ) | 
Import a DSA host key.
- Parameters
- 
  [out] publicKey Pointer to the DSA public key [in] hostKey Pointer to the host key structure 
- Returns
- Error code
Definition at line 1233 of file ssh_key_import.c.
◆ sshImportDsaPrivateKey()
| 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.
- Parameters
- 
  [out] privateKey DSA private key resulting from the parsing process [in] input Pointer to the SSH private key file [in] length Length of the SSH private key file [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted 
- Returns
- Error code
Definition at line 688 of file ssh_key_import.c.
◆ sshImportDsaPublicKey()
| error_t sshImportDsaPublicKey | ( | DsaPublicKey * | publicKey, | 
| const char_t * | input, | ||
| size_t | length | ||
| ) | 
Decode an SSH public key file containing a DSA public key.
- Parameters
- 
  [out] publicKey DSA public key resulting from the parsing process [in] input Pointer to the SSH public key file [in] length Length of the SSH public key file 
- Returns
- Error code
Definition at line 170 of file ssh_key_import.c.
◆ sshImportEcdsaHostKey()
| error_t sshImportEcdsaHostKey | ( | EcPublicKey * | publicKey, | 
| const SshEcdsaHostKey * | hostKey | ||
| ) | 
Import a ECDSA host key.
- Parameters
- 
  [out] publicKey Pointer to the ECDSA public key [in] hostKey Pointer to the host key structure 
- Returns
- Error code
Definition at line 1291 of file ssh_key_import.c.
◆ sshImportEcdsaPrivateKey()
| 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.
- Parameters
- 
  [out] privateKey ECDSA private key resulting from the parsing process [in] input Pointer to the SSH private key file [in] length Length of the SSH private key file [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted 
- Returns
- Error code
Definition at line 828 of file ssh_key_import.c.
◆ sshImportEcdsaPublicKey()
| error_t sshImportEcdsaPublicKey | ( | EcPublicKey * | publicKey, | 
| const char_t * | input, | ||
| size_t | length | ||
| ) | 
Decode an SSH public key file containing an ECDSA public key.
- Parameters
- 
  [out] publicKey ECDSA public key resulting from the parsing process [in] input Pointer to the SSH public key file [in] length Length of the SSH public key file 
- Returns
- Error code
Definition at line 253 of file ssh_key_import.c.
◆ sshImportEd25519PrivateKey()
| 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.
- Parameters
- 
  [out] privateKey Ed25519 private key resulting from the parsing process [in] input Pointer to the SSH private key file [in] length Length of the SSH private key file [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted 
- Returns
- Error code
Definition at line 960 of file ssh_key_import.c.
◆ sshImportEd25519PublicKey()
| error_t sshImportEd25519PublicKey | ( | EddsaPublicKey * | publicKey, | 
| const char_t * | input, | ||
| size_t | length | ||
| ) | 
Decode an SSH public key file containing an Ed25519 public key.
- Parameters
- 
  [out] publicKey Ed25519 public key resulting from the parsing process [in] input Pointer to the SSH public key file [in] length Length of the SSH public key file 
- Returns
- Error code
Definition at line 336 of file ssh_key_import.c.
◆ sshImportEd448PrivateKey()
| 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.
- Parameters
- 
  [out] privateKey Ed448 private key resulting from the parsing process [in] input Pointer to the SSH private key file [in] length Length of the SSH private key file [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted 
- Returns
- Error code
Definition at line 1076 of file ssh_key_import.c.
◆ sshImportEd448PublicKey()
| error_t sshImportEd448PublicKey | ( | EddsaPublicKey * | publicKey, | 
| const char_t * | input, | ||
| size_t | length | ||
| ) | 
Decode an SSH public key file containing an Ed448 public key.
- Parameters
- 
  [out] publicKey Ed448 public key resulting from the parsing process [in] input Pointer to the SSH public key file [in] length Length of the SSH public key file 
- Returns
- Error code
Definition at line 420 of file ssh_key_import.c.
◆ sshImportRsaHostKey()
| error_t sshImportRsaHostKey | ( | RsaPublicKey * | publicKey, | 
| const SshRsaHostKey * | hostKey | ||
| ) | 
Import an RSA host key.
- Parameters
- 
  [out] publicKey Pointer to the RSA public key [in] hostKey Pointer to the host key structure 
- Returns
- Error code
Definition at line 1189 of file ssh_key_import.c.
◆ sshImportRsaPrivateKey()
| 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.
- Parameters
- 
  [out] privateKey RSA private key resulting from the parsing process [in] input Pointer to the SSH private key file [in] length Length of the SSH private key file [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted 
- Returns
- Error code
Definition at line 506 of file ssh_key_import.c.
◆ sshImportRsaPublicKey()
| error_t sshImportRsaPublicKey | ( | RsaPublicKey * | publicKey, | 
| const char_t * | input, | ||
| size_t | length | ||
| ) | 
Decode an SSH public key file containing an RSA public key.
- Parameters
- 
  [out] publicKey RSA public key resulting from the parsing process [in] input Pointer to the SSH public key file [in] length Length of the SSH public key file 
- Returns
- Error code
Definition at line 87 of file ssh_key_import.c.
◆ sshSearchMarker()
Search a string for a given marker.
- Parameters
- 
  [in] s String to search [in] sLen Length of the string to search [in] marker String containing the marker to search for [in] markerLen Length of the marker 
- Returns
- The index of the first occurrence of the marker in the string, or -1 if the marker does not appear in the string
Definition at line 1732 of file ssh_key_import.c.
