diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-10-28 02:41:17 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-10-28 03:46:59 +0200 |
commit | 7d00799c935271ce89300494c5677190779f6453 (patch) | |
tree | 14b674e5ef56ed3f05af8b38c446b8f1cf5c2f39 /ssh-ed25519.c | |
parent | upstream: factor out key generation (diff) | |
download | openssh-7d00799c935271ce89300494c5677190779f6453.tar.xz openssh-7d00799c935271ce89300494c5677190779f6453.zip |
upstream: refactor sshkey_from_private()
feedback/ok markus@
OpenBSD-Commit-ID: e5dbe7a3545930c50f70ee75c867a1e08b382b53
Diffstat (limited to 'ssh-ed25519.c')
-rw-r--r-- | ssh-ed25519.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ssh-ed25519.c b/ssh-ed25519.c index f2a38c280..1b37760d0 100644 --- a/ssh-ed25519.c +++ b/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> * @@ -76,6 +76,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) @@ -211,6 +222,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 = { |