ssh_key_decrypt.h
Go to the documentation of this file.
1 /**
2  * @file ssh_key_decrypt.h
3  * @brief SSH private key decryption
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 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.4.4
29  **/
30 
31 #ifndef _SSH_KEY_DECRYPT_H
32 #define _SSH_KEY_DECRYPT_H
33 
34 //Dependencies
35 #include "ssh.h"
36 #include "ssh_key_parse.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief KDF options
46  **/
47 
48 typedef struct
49 {
51  uint32_t rounds;
53 
54 
55 //SSH private key decryption related functions
56 error_t sshDecryptPrivateKey(const char_t *input, size_t inputLen,
57  const char_t *password, char_t *output, size_t *outputLen);
58 
60  const char_t *password, const uint8_t *ciphertext, uint8_t *plaintext,
61  size_t length);
62 
63 error_t sshParseKdfOptions(const uint8_t *data, size_t length,
64  SshKdfOptions *kdfOptions);
65 
66 error_t sshKdf(const char *password, size_t passwordLen, const uint8_t *salt,
67  size_t saltLen, uint_t rounds, uint8_t *key, size_t keyLen);
68 
69 error_t sshKdfHash(uint8_t *password, uint8_t *salt, uint8_t *output);
70 
71 //C++ guard
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif
Binary string.
Definition: ssh_types.h:67
uint8_t data[]
Definition: ethernet.h:222
error_t sshDecryptOpenSshPrivateKey(const SshPrivateKeyHeader *privateKeyHeader, const char_t *password, const uint8_t *ciphertext, uint8_t *plaintext, size_t length)
OpenSSH private key decryption.
SSH key parsing.
Private key header (OpenSSH format)
error_t sshDecryptPrivateKey(const char_t *input, size_t inputLen, const char_t *password, char_t *output, size_t *outputLen)
SSH private key decryption.
KDF options.
error_t
Error codes.
Definition: error.h:43
error_t sshParseKdfOptions(const uint8_t *data, size_t length, SshKdfOptions *kdfOptions)
Parse KDF options.
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.
error_t sshKdfHash(uint8_t *password, uint8_t *salt, uint8_t *output)
KDF hash function.
uint8_t length
Definition: tcp.h:368
char char_t
Definition: compiler_port.h:48
SshBinaryString salt
unsigned int uint_t
Definition: compiler_port.h:50
Secure Shell (SSH)