diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-10-28 02:35:40 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-10-28 03:46:56 +0200 |
commit | 25de1c01a8b9a2c8ab9b1da22444a03e89c982de (patch) | |
tree | 286c31a5342ca485bdb117315b7ce908e4bf4432 /ssh-ed25519.c | |
parent | upstream: Be more paranoid with host/domain names coming from the (diff) | |
download | openssh-25de1c01a8b9a2c8ab9b1da22444a03e89c982de.tar.xz openssh-25de1c01a8b9a2c8ab9b1da22444a03e89c982de.zip |
upstream: begin big refactor of sshkey
Move keytype data and some of the type-specific code (allocation,
cleanup, etc) out into each key type's implementation. Subsequent
commits will move more, with the goal of having each key-*.c file
owning as much of its keytype's implementation as possible.
lots of feedback + ok markus@
OpenBSD-Commit-ID: 0f2b4334f73914344e9e5b3d33522d41762a57ec
Diffstat (limited to 'ssh-ed25519.c')
-rw-r--r-- | ssh-ed25519.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/ssh-ed25519.c b/ssh-ed25519.c index 4861628cb..abd983df9 100644 --- a/ssh-ed25519.c +++ b/ssh-ed25519.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-ed25519.c,v 1.10 2022/08/26 08:12:56 djm Exp $ */ +/* $OpenBSD: ssh-ed25519.c,v 1.11 2022/10/28 00:35:40 djm Exp $ */ /* * Copyright (c) 2013 Markus Friedl <markus@openbsd.org> * @@ -32,6 +32,15 @@ #include "ssherr.h" #include "ssh.h" +static void +ssh_ed25519_cleanup(struct sshkey *k) +{ + freezero(k->ed25519_pk, ED25519_PK_SZ); + freezero(k->ed25519_sk, ED25519_SK_SZ); + k->ed25519_pk = NULL; + k->ed25519_sk = NULL; +} + int ssh_ed25519_sign(const struct sshkey *key, u_char **sigp, size_t *lenp, const u_char *data, size_t datalen, u_int compat) @@ -158,3 +167,33 @@ ssh_ed25519_verify(const struct sshkey *key, free(ktype); return r; } + +static const struct sshkey_impl_funcs sshkey_ed25519_funcs = { + /* .size = */ NULL, + /* .alloc = */ NULL, + /* .cleanup = */ ssh_ed25519_cleanup, +}; + +const struct sshkey_impl sshkey_ed25519_impl = { + /* .name = */ "ssh-ed25519", + /* .shortname = */ "ED25519", + /* .sigalg = */ NULL, + /* .type = */ KEY_ED25519, + /* .nid = */ 0, + /* .cert = */ 0, + /* .sigonly = */ 0, + /* .keybits = */ 256, + /* .funcs = */ &sshkey_ed25519_funcs, +}; + +const struct sshkey_impl sshkey_ed25519_cert_impl = { + /* .name = */ "ssh-ed25519-cert-v01@openssh.com", + /* .shortname = */ "ED25519-CERT", + /* .sigalg = */ NULL, + /* .type = */ KEY_ED25519_CERT, + /* .nid = */ 0, + /* .cert = */ 1, + /* .sigonly = */ 0, + /* .keybits = */ 256, + /* .funcs = */ &sshkey_ed25519_funcs, +}; |