diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-10-28 00:36:31 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-10-28 12:46:56 +1100 |
commit | 1e78844ae2b2dc01ba735d5ae740904c57e13685 (patch) | |
tree | 9aaea84e13b641b1cc04dd9446d4af46c0a0919b /ssh-ed25519-sk.c | |
parent | 25de1c01a8b9a2c8ab9b1da22444a03e89c982de (diff) | |
download | openssh-git-1e78844ae2b2dc01ba735d5ae740904c57e13685.tar.gz |
upstream: factor out sshkey_equal_public()
feedback/ok markus@
OpenBSD-Commit-ID: 1368ba114cb37732fe6ec3d89c7e6d27ea6fdc94
Diffstat (limited to 'ssh-ed25519-sk.c')
-rw-r--r-- | ssh-ed25519-sk.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/ssh-ed25519-sk.c b/ssh-ed25519-sk.c index 1c21d4bf..4c0fc707 100644 --- a/ssh-ed25519-sk.c +++ b/ssh-ed25519-sk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-ed25519-sk.c,v 1.7 2022/10/28 00:35:40 djm Exp $ */ +/* $OpenBSD: ssh-ed25519-sk.c,v 1.8 2022/10/28 00:36:31 djm Exp $ */ /* * Copyright (c) 2019 Markus Friedl. All rights reserved. * @@ -35,16 +35,24 @@ #include "ssh.h" #include "digest.h" +/* Reuse some ED25519 internals */ +extern struct sshkey_impl_funcs sshkey_ed25519_funcs; + static void ssh_ed25519_sk_cleanup(struct sshkey *k) { - free(k->sk_application); - sshbuf_free(k->sk_key_handle); - sshbuf_free(k->sk_reserved); - freezero(k->ed25519_pk, ED25519_PK_SZ); - freezero(k->ed25519_sk, ED25519_SK_SZ); - k->ed25519_pk = NULL; - k->ed25519_sk = NULL; + sshkey_sk_cleanup(k); + sshkey_ed25519_funcs.cleanup(k); +} + +static int +ssh_ed25519_sk_equal(const struct sshkey *a, const struct sshkey *b) +{ + if (!sshkey_sk_fields_equal(a, b)) + return 0; + if (!sshkey_ed25519_funcs.equal(a, b)) + return 0; + return 1; } int @@ -178,6 +186,7 @@ static const struct sshkey_impl_funcs sshkey_ed25519_sk_funcs = { /* .size = */ NULL, /* .alloc = */ NULL, /* .cleanup = */ ssh_ed25519_sk_cleanup, + /* .equal = */ ssh_ed25519_sk_equal, }; const struct sshkey_impl sshkey_ed25519_sk_impl = { |