ssh_key_import.h File Reference

SSH key file import functions. More...

#include "ssh_types.h"
#include "ssh_key_parse.h"
#include "pkix/x509_common.h"
#include "pkc/rsa.h"
#include "pkc/dsa.h"
#include "ecc/ec.h"
#include "ecc/eddsa.h"

Go to the source code of this file.

Data Structures

struct  SshKeyType
 SSH key type. More...
 

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_tsshGetPublicKeyType (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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.5.0

Definition in file ssh_key_import.h.

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]inputSSH public key file to decode
[in]inputLenLength of the SSH private key file to decode
[out]outputPointer to the decoded data (optional parameter)
[out]outputLenLength of the decoded data

Definition at line 1677 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]inputSSH public key file to decode
[in]inputLenLength of the SSH public key file to decode
[out]outputPointer to the decoded data (optional parameter)
[out]outputLenLength of the decoded data

Definition at line 1602 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]inputSSH public key file to decode
[in]inputLenLength of the SSH public key file to decode
[out]outputPointer to the decoded data (optional parameter)
[out]outputLenLength 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]inputSSH public key file to decode
[in]inputLenLength of the SSH public key file to decode
[out]outputPointer to the decoded data (optional parameter)
[out]outputLenLength of the decoded data

Definition at line 1487 of file ssh_key_import.c.

◆ sshGetPublicKeyType()

const char_t* sshGetPublicKeyType ( const char_t input,
size_t  length 
)

Get SSH public key type.

Parameters
[in]inputSSH public key file
[in]lengthLength 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]publicKeyPointer to the DSA public key
[in]hostKeyPointer 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]privateKeyDSA private key resulting from the parsing process
[in]inputPointer to the SSH private key file
[in]lengthLength of the SSH private key file
[in]passwordNULL-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]publicKeyDSA public key resulting from the parsing process
[in]inputPointer to the SSH public key file
[in]lengthLength 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]publicKeyPointer to the ECDSA public key
[in]hostKeyPointer 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]privateKeyECDSA private key resulting from the parsing process
[in]inputPointer to the SSH private key file
[in]lengthLength of the SSH private key file
[in]passwordNULL-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]publicKeyECDSA public key resulting from the parsing process
[in]inputPointer to the SSH public key file
[in]lengthLength 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]privateKeyEd25519 private key resulting from the parsing process
[in]inputPointer to the SSH private key file
[in]lengthLength of the SSH private key file
[in]passwordNULL-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]publicKeyEd25519 public key resulting from the parsing process
[in]inputPointer to the SSH public key file
[in]lengthLength 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]privateKeyEd448 private key resulting from the parsing process
[in]inputPointer to the SSH private key file
[in]lengthLength of the SSH private key file
[in]passwordNULL-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]publicKeyEd448 public key resulting from the parsing process
[in]inputPointer to the SSH public key file
[in]lengthLength 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]publicKeyPointer to the RSA public key
[in]hostKeyPointer 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]privateKeyRSA private key resulting from the parsing process
[in]inputPointer to the SSH private key file
[in]lengthLength of the SSH private key file
[in]passwordNULL-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]publicKeyRSA public key resulting from the parsing process
[in]inputPointer to the SSH public key file
[in]lengthLength of the SSH public key file
Returns
Error code

Definition at line 87 of file ssh_key_import.c.

◆ sshSearchMarker()

int_t sshSearchMarker ( const char_t s,
size_t  sLen,
const char_t marker,
size_t  markerLen 
)

Search a string for a given marker.

Parameters
[in]sString to search
[in]sLenLength of the string to search
[in]markerString containing the marker to search for
[in]markerLenLength 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 1726 of file ssh_key_import.c.