1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Rewrite SSH key loading and saving using marshal.h.

All the functions that read and write public and private keys to a
FILE * are now small wrappers on top of an underlying set of functions
that read data in the same format from a BinarySource, or write it to
a strbuf. This sets me up to deal with key files in contexts other
than on disk.
This commit is contained in:
Simon Tatham 2020-01-06 19:57:09 +00:00
parent ef843e9638
commit 9cc586e605
2 changed files with 370 additions and 288 deletions

18
ssh.h
View File

@ -1165,19 +1165,33 @@ extern void base64_encode(FILE *fp, const unsigned char *data, int datalen,
extern ssh2_userkey ssh2_wrong_passphrase; extern ssh2_userkey ssh2_wrong_passphrase;
#define SSH2_WRONG_PASSPHRASE (&ssh2_wrong_passphrase) #define SSH2_WRONG_PASSPHRASE (&ssh2_wrong_passphrase)
bool ppk_encrypted_s(BinarySource *src, char **comment);
bool ppk_encrypted_f(const Filename *filename, char **comment); bool ppk_encrypted_f(const Filename *filename, char **comment);
bool rsa1_encrypted_s(BinarySource *src, char **comment);
bool rsa1_encrypted_f(const Filename *filename, char **comment); bool rsa1_encrypted_f(const Filename *filename, char **comment);
ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase,
const char **errorstr);
ssh2_userkey *ppk_load_f(const Filename *filename, const char *passphrase, ssh2_userkey *ppk_load_f(const Filename *filename, const char *passphrase,
const char **errorstr); const char **errorstr);
int rsa1_load_s(BinarySource *src, RSAKey *key,
const char *passphrase, const char **errorstr);
int rsa1_load_f(const Filename *filename, RSAKey *key, int rsa1_load_f(const Filename *filename, RSAKey *key,
const char *passphrase, const char **errorstr); const char *passphrase, const char **errorstr);
bool ppk_save_f(const Filename *filename, ssh2_userkey *key, char *passphrase); strbuf *ppk_save_sb(ssh2_userkey *key, const char *passphrase);
bool rsa1_save_f(const Filename *filename, RSAKey *key, char *passphrase); bool ppk_save_f(const Filename *filename, ssh2_userkey *key,
const char *passphrase);
strbuf *rsa1_save_sb(RSAKey *key, const char *passphrase);
bool rsa1_save_f(const Filename *filename, RSAKey *key,
const char *passphrase);
bool ppk_loadpub_s(BinarySource *src, char **algorithm, BinarySink *bs,
char **commentptr, const char **errorstr);
bool ppk_loadpub_f(const Filename *filename, char **algorithm, BinarySink *bs, bool ppk_loadpub_f(const Filename *filename, char **algorithm, BinarySink *bs,
char **commentptr, const char **errorstr); char **commentptr, const char **errorstr);
int rsa1_loadpub_s(BinarySource *src, BinarySink *bs,
char **commentptr, const char **errorstr);
int rsa1_loadpub_f(const Filename *filename, BinarySink *bs, int rsa1_loadpub_f(const Filename *filename, BinarySink *bs,
char **commentptr, const char **errorstr); char **commentptr, const char **errorstr);

640
sshpubk.c

File diff suppressed because it is too large Load Diff