Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ssh.h
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2022-04-20 15:51:28 +0300
committerSimon Tatham <anakin@pobox.com>2022-04-24 10:39:04 +0300
commitc2f1a563a50bd611aaf330142e828dfb1b43f18e (patch)
treebab9e52b21ea1bfc21e146b5f78244b14c2c1973 /ssh.h
parent180d1b78de90f2e3fd93939664322185ebbabc00 (diff)
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.
Diffstat (limited to 'ssh.h')
-rw-r--r--ssh.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/ssh.h b/ssh.h
index 3bd90dfc..b703945f 100644
--- a/ssh.h
+++ b/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
*/