diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-10-28 02:37:24 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-10-28 03:46:57 +0200 |
commit | 591fed94e66a016acf87f4b7cd416ce812f2abe8 (patch) | |
tree | 03a5ee7575f669585607ae1502d7c05e8292f9f1 /ssh-ed25519.c | |
parent | upstream: factor out sshkey_equal_public() (diff) | |
download | openssh-591fed94e66a016acf87f4b7cd416ce812f2abe8.tar.xz openssh-591fed94e66a016acf87f4b7cd416ce812f2abe8.zip |
upstream: factor out public key serialization
feedback/ok markus@
OpenBSD-Commit-ID: a3570c4b97290c5662890aea7328d87f55939033
Diffstat (limited to 'ssh-ed25519.c')
-rw-r--r-- | ssh-ed25519.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ssh-ed25519.c b/ssh-ed25519.c index 712cc4022..72c850000 100644 --- a/ssh-ed25519.c +++ b/ssh-ed25519.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-ed25519.c,v 1.12 2022/10/28 00:36:31 djm Exp $ */ +/* $OpenBSD: ssh-ed25519.c,v 1.13 2022/10/28 00:37:24 djm Exp $ */ /* * Copyright (c) 2013 Markus Friedl <markus@openbsd.org> * @@ -51,6 +51,21 @@ ssh_ed25519_equal(const struct sshkey *a, const struct sshkey *b) return 1; } +static int +ssh_ed25519_serialize_public(const struct sshkey *key, struct sshbuf *b, + const char *typename, enum sshkey_serialize_rep opts) +{ + int r; + + if (key->ed25519_pk == NULL) + return SSH_ERR_INVALID_ARGUMENT; + if ((r = sshbuf_put_cstring(b, typename)) != 0 || + (r = sshbuf_put_string(b, key->ed25519_pk, ED25519_PK_SZ)) != 0) + return r; + + return 0; +} + int ssh_ed25519_sign(const struct sshkey *key, u_char **sigp, size_t *lenp, const u_char *data, size_t datalen, u_int compat) @@ -184,6 +199,7 @@ const struct sshkey_impl_funcs sshkey_ed25519_funcs = { /* .alloc = */ NULL, /* .cleanup = */ ssh_ed25519_cleanup, /* .equal = */ ssh_ed25519_equal, + /* .ssh_serialize_public = */ ssh_ed25519_serialize_public, }; const struct sshkey_impl sshkey_ed25519_impl = { |