diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2022-10-28 00:41:18 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2022-10-28 00:41:18 +0000 |
commit | 6d036b2fd286d8622714c278a27dce6522aef0a5 (patch) | |
tree | 399837737c59d55ef6b9ea3437a9d04f45587926 /usr.bin/ssh/ssh-ed25519.c | |
parent | 57cce289b3d22dfc8a13ea33eb0c5716904a4216 (diff) |
refactor sshkey_from_private()
feedback/ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh-ed25519.c')
-rw-r--r-- | usr.bin/ssh/ssh-ed25519.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-ed25519.c b/usr.bin/ssh/ssh-ed25519.c index bbf164c8c42..db1dc96f379 100644 --- a/usr.bin/ssh/ssh-ed25519.c +++ b/usr.bin/ssh/ssh-ed25519.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-ed25519.c,v 1.14 2022/10/28 00:39:29 djm Exp $ */ +/* $OpenBSD: ssh-ed25519.c,v 1.15 2022/10/28 00:41:17 djm Exp $ */ /* * Copyright (c) 2013 Markus Friedl <markus@openbsd.org> * @@ -73,6 +73,17 @@ ssh_ed25519_generate(struct sshkey *k, int bits) return 0; } +static int +ssh_ed25519_copy_public(const struct sshkey *from, struct sshkey *to) +{ + if (from->ed25519_pk == NULL) + return 0; /* XXX SSH_ERR_INTERNAL_ERROR ? */ + if ((to->ed25519_pk = malloc(ED25519_PK_SZ)) == NULL) + return SSH_ERR_ALLOC_FAIL; + memcpy(to->ed25519_pk, from->ed25519_pk, ED25519_PK_SZ); + 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) @@ -208,6 +219,7 @@ const struct sshkey_impl_funcs sshkey_ed25519_funcs = { /* .equal = */ ssh_ed25519_equal, /* .ssh_serialize_public = */ ssh_ed25519_serialize_public, /* .generate = */ ssh_ed25519_generate, + /* .copy_public = */ ssh_ed25519_copy_public, }; const struct sshkey_impl sshkey_ed25519_impl = { |