SSH key file export functions. More...
#include "ssh_types.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.
| Enumerations | |
| enum | SshPublicKeyFormat { SSH_PUBLIC_KEY_FORMAT_DEFAULT = 0, SSH_PUBLIC_KEY_FORMAT_SSH2 = 1, SSH_PUBLIC_KEY_FORMAT_OPENSSH = 2 } | 
| SSH public key formats.  More... | |
| enum | SshPrivateKeyFormat { SSH_PRIVATE_KEY_FORMAT_DEFAULT = 0, SSH_PRIVATE_KEY_FORMAT_OPENSSH = 2 } | 
| SSH private key formats.  More... | |
| Functions | |
| error_t | sshExportRsaPublicKey (const RsaPublicKey *publicKey, char_t *output, size_t *written, SshPublicKeyFormat format) | 
| Export an RSA public key to SSH public key file format.  More... | |
| error_t | sshExportDsaPublicKey (const DsaPublicKey *publicKey, char_t *output, size_t *written, SshPublicKeyFormat format) | 
| Export a DSA public key to SSH public key file format.  More... | |
| error_t | sshExportEcdsaPublicKey (const EcPublicKey *publicKey, char_t *output, size_t *written, SshPublicKeyFormat format) | 
| Export an ECDSA public key to SSH public key file format.  More... | |
| error_t | sshExportEd25519PublicKey (const EddsaPublicKey *publicKey, char_t *output, size_t *written, SshPublicKeyFormat format) | 
| Export a Ed25519 public key to SSH public key file format.  More... | |
| error_t | sshExportEd448PublicKey (const EddsaPublicKey *publicKey, char_t *output, size_t *written, SshPublicKeyFormat format) | 
| Export a Ed448 public key to SSH public key file format.  More... | |
| error_t | sshExportRsaPrivateKey (const RsaPrivateKey *privateKey, char_t *output, size_t *written, SshPrivateKeyFormat format) | 
| Export an RSA private key to SSH private key file format.  More... | |
| error_t | sshExportDsaPrivateKey (const DsaPrivateKey *privateKey, char_t *output, size_t *written, SshPrivateKeyFormat format) | 
| Export a DSA private key to SSH private key file format.  More... | |
| error_t | sshExportEcdsaPrivateKey (const EcPrivateKey *privateKey, char_t *output, size_t *written, SshPrivateKeyFormat format) | 
| Export an ECDSA private key to SSH private key file format.  More... | |
| error_t | sshExportEd25519PrivateKey (const EddsaPrivateKey *privateKey, char_t *output, size_t *written, SshPrivateKeyFormat format) | 
| Export an Ed25519 private key to SSH private key file format.  More... | |
| error_t | sshExportEd448PrivateKey (const EddsaPrivateKey *privateKey, char_t *output, size_t *written, SshPrivateKeyFormat format) | 
| Export an Ed448 private key to SSH private key file format.  More... | |
| error_t | sshExportOpenSshRsaPrivateKey (const RsaPrivateKey *privateKey, char_t *output, size_t *written) | 
| Export an RSA private key to OpenSSH private key file format.  More... | |
| error_t | sshExportOpenSshDsaPrivateKey (const DsaPrivateKey *privateKey, char_t *output, size_t *written) | 
| Export a DSA private key to OpenSSH private key file format.  More... | |
| error_t | sshExportOpenSshEcdsaPrivateKey (const EcPrivateKey *privateKey, char_t *output, size_t *written) | 
| Export an ECDSA private key to OpenSSH private key file format.  More... | |
| error_t | sshExportOpenSshEd25519PrivateKey (const EddsaPrivateKey *privateKey, char_t *output, size_t *written) | 
| Export an Ed25519 private key to OpenSSH private key file format.  More... | |
| error_t | sshExportOpenSshEd448PrivateKey (const EddsaPrivateKey *privateKey, char_t *output, size_t *written) | 
| Export an Ed448 private key to OpenSSH private key file format.  More... | |
| error_t | sshEncodePublicKeyFile (const char_t *keyFormatId, const void *input, size_t inputLen, char_t *output, size_t *outputLen, SshPublicKeyFormat format) | 
| Encode SSH public key file (SSH2 or OpenSSH format)  More... | |
| error_t | sshEncodeSsh2PublicKeyFile (const void *input, size_t inputLen, char_t *output, size_t *outputLen) | 
| Encode SSH public key file (SSH2 format)  More... | |
| error_t | sshEncodeOpenSshPublicKeyFile (const char_t *keyFormatId, const void *input, size_t inputLen, char_t *output, size_t *outputLen) | 
| Encode SSH public key file (OpenSSH format)  More... | |
| error_t | sshEncodeOpenSshPrivateKeyFile (const void *input, size_t inputLen, char_t *output, size_t *outputLen) | 
| Encode SSH private key file (OpenSSH format)  More... | |
Detailed Description
SSH key file export 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_export.h.
Enumeration Type Documentation
◆ SshPrivateKeyFormat
| enum SshPrivateKeyFormat | 
SSH private key formats.
| Enumerator | |
|---|---|
| SSH_PRIVATE_KEY_FORMAT_DEFAULT | Default private key format. | 
| SSH_PRIVATE_KEY_FORMAT_OPENSSH | OpenSSH private key format. | 
Definition at line 63 of file ssh_key_export.h.
◆ SshPublicKeyFormat
| enum SshPublicKeyFormat | 
SSH public key formats.
| Enumerator | |
|---|---|
| SSH_PUBLIC_KEY_FORMAT_DEFAULT | Default public key format. | 
| SSH_PUBLIC_KEY_FORMAT_SSH2 | SSH2 public key format. | 
| SSH_PUBLIC_KEY_FORMAT_OPENSSH | OpenSSH public key format. | 
Definition at line 51 of file ssh_key_export.h.
Function Documentation
◆ sshEncodeOpenSshPrivateKeyFile()
| error_t sshEncodeOpenSshPrivateKeyFile | ( | const void * | input, | 
| size_t | inputLen, | ||
| char_t * | output, | ||
| size_t * | outputLen | ||
| ) | 
Encode SSH private key file (OpenSSH format)
- Parameters
- 
  [in] input Private key structure to encode [in] inputLen Length of the private key structure to encode [out] output SSH private key file (optional parameter) [out] outputLen Length of the SSH private key file 
Definition at line 1027 of file ssh_key_export.c.
◆ sshEncodeOpenSshPublicKeyFile()
| error_t sshEncodeOpenSshPublicKeyFile | ( | const char_t * | keyFormatId, | 
| const void * | input, | ||
| size_t | inputLen, | ||
| char_t * | output, | ||
| size_t * | outputLen | ||
| ) | 
Encode SSH public key file (OpenSSH format)
- Parameters
- 
  [in] keyFormatId Key format identifier [in] input Host key structure to encode [in] inputLen Length of the host key structure to encode [out] output SSH public key file (optional parameter) [out] outputLen Length of the SSH public key file 
Definition at line 976 of file ssh_key_export.c.
◆ sshEncodePublicKeyFile()
| error_t sshEncodePublicKeyFile | ( | const char_t * | keyFormatId, | 
| const void * | input, | ||
| size_t | inputLen, | ||
| char_t * | output, | ||
| size_t * | outputLen, | ||
| SshPublicKeyFormat | format | ||
| ) | 
Encode SSH public key file (SSH2 or OpenSSH format)
- Parameters
- 
  [in] keyFormatId Key format identifier [in] input Host key structure to encode [in] inputLen Length of the host key structure to encode [out] output SSH public key file (optional parameter) [out] outputLen Length of the SSH public key file [in] format Desired output format (SSH2 or OpenSSH format) 
Definition at line 885 of file ssh_key_export.c.
◆ sshEncodeSsh2PublicKeyFile()
| error_t sshEncodeSsh2PublicKeyFile | ( | const void * | input, | 
| size_t | inputLen, | ||
| char_t * | output, | ||
| size_t * | outputLen | ||
| ) | 
Encode SSH public key file (SSH2 format)
- Parameters
- 
  [in] input Host key structure to encode [in] inputLen Length of the host key structure to encode [out] output SSH public key file (optional parameter) [out] outputLen Length of the SSH public key file 
Definition at line 922 of file ssh_key_export.c.
◆ sshExportDsaPrivateKey()
| error_t sshExportDsaPrivateKey | ( | const DsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPrivateKeyFormat | format | ||
| ) | 
Export a DSA private key to SSH private key file format.
- Parameters
- 
  [in] privateKey DSA private key [out] output Buffer where to store the SSH private key file [out] written Length of the resulting SSH private key file [in] format Desired output format (OpenSSH format only) 
- Returns
- Error code
Definition at line 336 of file ssh_key_export.c.
◆ sshExportDsaPublicKey()
| error_t sshExportDsaPublicKey | ( | const DsaPublicKey * | publicKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPublicKeyFormat | format | ||
| ) | 
Export a DSA public key to SSH public key file format.
- Parameters
- 
  [in] publicKey DSA public key [out] output Buffer where to store the SSH public key file (optional parameter) [out] written Length of the resulting SSH public key file [in] format Desired output format (SSH2 or OpenSSH format) 
- Returns
- Error code
Definition at line 100 of file ssh_key_export.c.
◆ sshExportEcdsaPrivateKey()
| error_t sshExportEcdsaPrivateKey | ( | const EcPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPrivateKeyFormat | format | ||
| ) | 
Export an ECDSA private key to SSH private key file format.
- Parameters
- 
  [in] privateKey ECDSA private key [out] output Buffer where to store the SSH private key file [out] written Length of the resulting SSH private key file [in] format Desired output format (OpenSSH format only) 
- Returns
- Error code
Definition at line 368 of file ssh_key_export.c.
◆ sshExportEcdsaPublicKey()
| error_t sshExportEcdsaPublicKey | ( | const EcPublicKey * | publicKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPublicKeyFormat | format | ||
| ) | 
Export an ECDSA public key to SSH public key file format.
- Parameters
- 
  [in] publicKey ECDSA public key [out] output Buffer where to store the SSH public key file (optional parameter) [out] written Length of the resulting SSH public key file [in] format Desired output format (SSH2 or OpenSSH format) 
- Returns
- Error code
Definition at line 144 of file ssh_key_export.c.
◆ sshExportEd25519PrivateKey()
| error_t sshExportEd25519PrivateKey | ( | const EddsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPrivateKeyFormat | format | ||
| ) | 
Export an Ed25519 private key to SSH private key file format.
- Parameters
- 
  [in] privateKey Ed25519 private key [out] output Buffer where to store the SSH private key file [out] written Length of the resulting SSH private key file [in] format Desired output format (OpenSSH format only) 
- Returns
- Error code
Definition at line 400 of file ssh_key_export.c.
◆ sshExportEd25519PublicKey()
| error_t sshExportEd25519PublicKey | ( | const EddsaPublicKey * | publicKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPublicKeyFormat | format | ||
| ) | 
Export a Ed25519 public key to SSH public key file format.
- Parameters
- 
  [in] publicKey Ed25519 public key [out] output Buffer where to store the SSH public key file (optional parameter) [out] written Length of the resulting SSH public key file [in] format Desired output format (SSH2 or OpenSSH format) 
- Returns
- Error code
Definition at line 215 of file ssh_key_export.c.
◆ sshExportEd448PrivateKey()
| error_t sshExportEd448PrivateKey | ( | const EddsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPrivateKeyFormat | format | ||
| ) | 
Export an Ed448 private key to SSH private key file format.
- Parameters
- 
  [in] privateKey Ed448 private key [out] output Buffer where to store the SSH private key file [out] written Length of the resulting SSH private key file [in] format Desired output format (OpenSSH format only) 
- Returns
- Error code
Definition at line 432 of file ssh_key_export.c.
◆ sshExportEd448PublicKey()
| error_t sshExportEd448PublicKey | ( | const EddsaPublicKey * | publicKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPublicKeyFormat | format | ||
| ) | 
Export a Ed448 public key to SSH public key file format.
- Parameters
- 
  [in] publicKey Ed448 public key [out] output Buffer where to store the SSH public key file (optional parameter) [out] written Length of the resulting SSH public key file [in] format Desired output format (SSH2 or OpenSSH format) 
- Returns
- Error code
Definition at line 260 of file ssh_key_export.c.
◆ sshExportOpenSshDsaPrivateKey()
| error_t sshExportOpenSshDsaPrivateKey | ( | const DsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written | ||
| ) | 
Export a DSA private key to OpenSSH private key file format.
- Parameters
- 
  [in] privateKey DSA private key [out] output Buffer where to store the OpenSSH private key file [out] written Length of the resulting OpenSSH private key file 
- Returns
- Error code
Definition at line 550 of file ssh_key_export.c.
◆ sshExportOpenSshEcdsaPrivateKey()
| error_t sshExportOpenSshEcdsaPrivateKey | ( | const EcPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written | ||
| ) | 
Export an ECDSA private key to OpenSSH private key file format.
- Parameters
- 
  [in] privateKey ECDSA private key [out] output Buffer where to store the OpenSSH private key file [out] written Length of the resulting OpenSSH private key file 
- Returns
- Error code
Definition at line 637 of file ssh_key_export.c.
◆ sshExportOpenSshEd25519PrivateKey()
| error_t sshExportOpenSshEd25519PrivateKey | ( | const EddsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written | ||
| ) | 
Export an Ed25519 private key to OpenSSH private key file format.
- Parameters
- 
  [in] privateKey Ed25519 private key [out] output Buffer where to store the OpenSSH private key file [out] written Length of the resulting OpenSSH private key file 
- Returns
- Error code
Definition at line 719 of file ssh_key_export.c.
◆ sshExportOpenSshEd448PrivateKey()
| error_t sshExportOpenSshEd448PrivateKey | ( | const EddsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written | ||
| ) | 
Export an Ed448 private key to OpenSSH private key file format.
- Parameters
- 
  [in] privateKey Ed448 private key [out] output Buffer where to store the OpenSSH private key file [out] written Length of the resulting OpenSSH private key file 
- Returns
- Error code
Definition at line 801 of file ssh_key_export.c.
◆ sshExportOpenSshRsaPrivateKey()
| error_t sshExportOpenSshRsaPrivateKey | ( | const RsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written | ||
| ) | 
Export an RSA private key to OpenSSH private key file format.
- Parameters
- 
  [in] privateKey RSA private key [out] output Buffer where to store the OpenSSH private key file [out] written Length of the resulting OpenSSH private key file 
- Returns
- Error code
Definition at line 463 of file ssh_key_export.c.
◆ sshExportRsaPrivateKey()
| error_t sshExportRsaPrivateKey | ( | const RsaPrivateKey * | privateKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPrivateKeyFormat | format | ||
| ) | 
Export an RSA private key to SSH private key file format.
- Parameters
- 
  [in] privateKey RSA private key [out] output Buffer where to store the SSH private key file [out] written Length of the resulting SSH private key file [in] format Desired output format (OpenSSH format only) 
- Returns
- Error code
Definition at line 304 of file ssh_key_export.c.
◆ sshExportRsaPublicKey()
| error_t sshExportRsaPublicKey | ( | const RsaPublicKey * | publicKey, | 
| char_t * | output, | ||
| size_t * | written, | ||
| SshPublicKeyFormat | format | ||
| ) | 
Export an RSA public key to SSH public key file format.
- Parameters
- 
  [in] publicKey RSA public key [out] output Buffer where to store the SSH public key file (optional parameter) [out] written Length of the resulting SSH public key file [in] format Desired output format (SSH2 or OpenSSH format) 
- Returns
- Error code
Definition at line 56 of file ssh_key_export.c.
