ssh_key_decrypt.h File Reference

SSH private key decryption. More...

#include "ssh.h"
#include "ssh_key_parse.h"

Go to the source code of this file.

Data Structures

struct  SshKdfOptions
 KDF options. More...
 

Functions

error_t sshDecryptPrivateKey (const char_t *input, size_t inputLen, const char_t *password, char_t *output, size_t *outputLen)
 SSH private key decryption. More...
 
error_t sshDecryptOpenSshPrivateKey (const SshPrivateKeyHeader *privateKeyHeader, const char_t *password, const uint8_t *ciphertext, uint8_t *plaintext, size_t length)
 OpenSSH private key decryption. More...
 
error_t sshParseKdfOptions (const uint8_t *data, size_t length, SshKdfOptions *kdfOptions)
 Parse KDF options. More...
 
error_t sshKdf (const char *password, size_t passwordLen, const uint8_t *salt, size_t saltLen, uint_t rounds, uint8_t *key, size_t keyLen)
 Key derivation function. More...
 
error_t sshKdfHash (uint8_t *password, uint8_t *salt, uint8_t *output)
 KDF hash function. More...
 

Detailed Description

SSH private key decryption.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2024 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.4.4

Definition in file ssh_key_decrypt.h.

Function Documentation

◆ sshDecryptOpenSshPrivateKey()

error_t sshDecryptOpenSshPrivateKey ( const SshPrivateKeyHeader privateKeyHeader,
const char_t password,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  length 
)

OpenSSH private key decryption.

Parameters
[in]privateKeyHeaderPrivate key header
[in]passwordNULL-terminated string containing the password
[in]ciphertextPointer to the ciphertext data
[out]plaintextPointer to the plaintext data
[in]lengthTotal number of data bytes to be decrypted
Returns
Error code

Definition at line 193 of file ssh_key_decrypt.c.

◆ sshDecryptPrivateKey()

error_t sshDecryptPrivateKey ( const char_t input,
size_t  inputLen,
const char_t password,
char_t output,
size_t *  outputLen 
)

SSH private key decryption.

Parameters
[in]inputPointer to the encrypted private key (PEM or OpenSSH format)
[in]inputLenLength of the encrypted private key
[in]passwordNULL-terminated string containing the password
[out]outputPointer to decrypted private key
[out]outputLenLength of the decrypted private key
Returns
Error code

Definition at line 61 of file ssh_key_decrypt.c.

◆ sshKdf()

error_t sshKdf ( const char *  password,
size_t  passwordLen,
const uint8_t *  salt,
size_t  saltLen,
uint_t  rounds,
uint8_t *  key,
size_t  keyLen 
)

Key derivation function.

Parameters
[in]passwordPassword
[in]passwordLenLength password
[in]saltSalt
[in]saltLenLength of the salt
[in]roundsIteration count
[out]keyDerived key
[in]keyLenIntended length of the derived key
Returns
Error code

Definition at line 353 of file ssh_key_decrypt.c.

◆ sshKdfHash()

error_t sshKdfHash ( uint8_t *  password,
uint8_t *  salt,
uint8_t *  output 
)

KDF hash function.

Parameters
[in]passwordPassword
[in]saltSalt
[out]outputDigest value
Returns
Error code

Definition at line 473 of file ssh_key_decrypt.c.

◆ sshParseKdfOptions()

error_t sshParseKdfOptions ( const uint8_t *  data,
size_t  length,
SshKdfOptions kdfOptions 
)

Parse KDF options.

Parameters
[in]dataPointer to the KDF options
[in]lengthLength of the KDF options, in bytes
[out]kdfOptionsInformation resulting from the parsing process

Definition at line 314 of file ssh_key_decrypt.c.