mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-12 00:33:53 -05:00
Utility function ssh_key_clone().
This makes a second independent copy of an existing ssh_key, for situations where one piece of code is going to want to keep it after its current owner frees it. In order to have it work on an arbitrary ssh_key, whether public-only or a full public+private key pair, I've had to add an ssh_key query method to ask whether a private key is known. I'm surprised I haven't found a need for that before! But I suppose in most situations in an SSH client you statically know which kind of key you're dealing with.
This commit is contained in:
6
ssh.h
6
ssh.h
@ -841,6 +841,7 @@ struct ssh_keyalg {
|
||||
void (*public_blob)(ssh_key *key, BinarySink *);
|
||||
void (*private_blob)(ssh_key *key, BinarySink *);
|
||||
void (*openssh_blob) (ssh_key *key, BinarySink *);
|
||||
bool (*has_private) (ssh_key *key);
|
||||
char *(*cache_str) (ssh_key *key);
|
||||
key_components *(*components) (ssh_key *key);
|
||||
|
||||
@ -878,6 +879,8 @@ static inline void ssh_key_private_blob(ssh_key *key, BinarySink *bs)
|
||||
{ key->vt->private_blob(key, bs); }
|
||||
static inline void ssh_key_openssh_blob(ssh_key *key, BinarySink *bs)
|
||||
{ key->vt->openssh_blob(key, bs); }
|
||||
static inline bool ssh_key_has_private(ssh_key *key)
|
||||
{ return key->vt->has_private(key); }
|
||||
static inline char *ssh_key_cache_str(ssh_key *key)
|
||||
{ return key->vt->cache_str(key); }
|
||||
static inline key_components *ssh_key_components(ssh_key *key)
|
||||
@ -902,6 +905,9 @@ static inline const char *ssh_keyalg_alternate_ssh_id(
|
||||
unsigned nullkey_supported_flags(const ssh_keyalg *self);
|
||||
const char *nullkey_alternate_ssh_id(const ssh_keyalg *self, unsigned flags);
|
||||
|
||||
/* Utility functions implemented centrally */
|
||||
ssh_key *ssh_key_clone(ssh_key *key);
|
||||
|
||||
/*
|
||||
* SSH2 ECDH key exchange vtable
|
||||
*/
|
||||
|
Reference in New Issue
Block a user