diff --git a/ssh.h b/ssh.h index 19f16916..3bd90dfc 100644 --- a/ssh.h +++ b/ssh.h @@ -560,10 +560,16 @@ typedef struct key_components { key_components *key_components_new(void); void key_components_add_text(key_components *kc, const char *name, const char *value); +void key_components_add_text_pl(key_components *kc, + const char *name, ptrlen value); void key_components_add_binary(key_components *kc, const char *name, ptrlen value); void key_components_add_mp(key_components *kc, const char *name, mp_int *value); +void key_components_add_uint(key_components *kc, + const char *name, uintmax_t value); +void key_components_add_copy(key_components *kc, + const char *name, const key_component *value); void key_components_free(key_components *kc); /* diff --git a/utils/key_components.c b/utils/key_components.c index d8af240e..b072ff51 100644 --- a/utils/key_components.c +++ b/utils/key_components.c @@ -26,6 +26,12 @@ void key_components_add_text(key_components *kc, key_components_add_str(kc, name, KCT_TEXT, ptrlen_from_asciz(value)); } +void key_components_add_text_pl(key_components *kc, + const char *name, ptrlen value) +{ + key_components_add_str(kc, name, KCT_TEXT, value); +} + void key_components_add_binary(key_components *kc, const char *name, ptrlen value) { @@ -42,6 +48,29 @@ void key_components_add_mp(key_components *kc, kc->components[n].mp = mp_copy(value); } +void key_components_add_uint(key_components *kc, + const char *name, uintmax_t value) +{ + mp_int *mpvalue = mp_from_integer(value); + key_components_add_mp(kc, name, mpvalue); + mp_free(mpvalue); +} + +void key_components_add_copy(key_components *kc, + const char *name, const key_component *value) +{ + switch (value->type) { + case KCT_TEXT: + case KCT_BINARY: + key_components_add_str(kc, name, value->type, + ptrlen_from_strbuf(value->str)); + break; + case KCT_MPINT: + key_components_add_mp(kc, name, value->mp); + break; + } +} + void key_components_free(key_components *kc) { for (size_t i = 0; i < kc->ncomponents; i++) {