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-18 12:10:57 +0300
committerSimon Tatham <anakin@pobox.com>2022-04-24 10:39:04 +0300
commit68514ac8a1fd6b588dedd6c88cd3003b88947783 (patch)
tree17dbdec8f689f9ac8c73a6b00d48588e7102b623 /ssh.h
parentcf36b9215f972ef883ed6d10062e1cad0255e470 (diff)
Refactor the key-components mechanism a bit.
Having recently pulled it out into its own file, I think it could also do with a bit of tidying. In this rework: - the substructure for a single component now has a globally visible struct tag, so you can make a variable pointing at it, saving verbiage in every piece of code looping over a key_components - the 'is_mp_int' flag has been replaced with a type enum, so that more types can be added without further upheaval - the printing loop in cmdgen.c for puttygen --dump has factored out the initial 'name=' prefix on each line so that it isn't repeated per component type - the storage format for text components is now a strbuf rather than a plain char *, which I think is generally more useful.
Diffstat (limited to 'ssh.h')
-rw-r--r--ssh.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/ssh.h b/ssh.h
index cb26b74b..e0c45091 100644
--- a/ssh.h
+++ b/ssh.h
@@ -542,16 +542,20 @@ struct eddsa_key {
WeierstrassPoint *ecdsa_public(mp_int *private_key, const ssh_keyalg *alg);
EdwardsPoint *eddsa_public(mp_int *private_key, const ssh_keyalg *alg);
+typedef enum KeyComponentType {
+ KCT_TEXT, KCT_MPINT
+} KeyComponentType;
+typedef struct key_component {
+ char *name;
+ KeyComponentType type;
+ union {
+ strbuf *str; /* used for KCT_TEXT */
+ mp_int *mp; /* used for KCT_MPINT */
+ };
+} key_component;
typedef struct key_components {
size_t ncomponents, componentsize;
- struct {
- char *name;
- bool is_mp_int;
- union {
- char *text;
- mp_int *mp;
- };
- } *components;
+ key_component *components;
} key_components;
key_components *key_components_new(void);
void key_components_add_text(key_components *kc,