diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-10-28 02:44:44 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-10-28 03:47:01 +0200 |
commit | 27267642699342412964aa785b98afd69d952c88 (patch) | |
tree | b2aa59e6b542da8a1ece82e337cf38e4c253067b /ssh-ecdsa-sk.c | |
parent | upstream: refactor sshkey_private_serialize_opt() (diff) | |
download | openssh-27267642699342412964aa785b98afd69d952c88.tar.xz openssh-27267642699342412964aa785b98afd69d952c88.zip |
upstream: refactor sshkey_private_deserialize
feedback/ok markus@
OpenBSD-Commit-ID: f5ca6932fdaf840a5e8250becb38315a29b5fc9f
Diffstat (limited to 'ssh-ecdsa-sk.c')
-rw-r--r-- | ssh-ecdsa-sk.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ssh-ecdsa-sk.c b/ssh-ecdsa-sk.c index 51e444a52..729e5487c 100644 --- a/ssh-ecdsa-sk.c +++ b/ssh-ecdsa-sk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-ecdsa-sk.c,v 1.16 2022/10/28 00:44:17 djm Exp $ */ +/* $OpenBSD: ssh-ecdsa-sk.c,v 1.17 2022/10/28 00:44:44 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2010 Damien Miller. All rights reserved. @@ -137,6 +137,23 @@ ssh_ecdsa_sk_deserialize_public(const char *ktype, struct sshbuf *b, return 0; } +static int +ssh_ecdsa_sk_deserialize_private(const char *ktype, struct sshbuf *b, + struct sshkey *key) +{ + int r; + + if (!sshkey_is_cert(key)) { + if ((r = sshkey_ecdsa_funcs.deserialize_public(ktype, + b, key)) != 0) + return r; + } + if ((r = sshkey_private_deserialize_sk(b, key)) != 0) + return r; + + return 0; +} + /* * Check FIDO/W3C webauthn signatures clientData field against the expected * format and prepare a hash of it for use in signature verification. @@ -405,6 +422,7 @@ static const struct sshkey_impl_funcs sshkey_ecdsa_sk_funcs = { /* .ssh_serialize_public = */ ssh_ecdsa_sk_serialize_public, /* .ssh_deserialize_public = */ ssh_ecdsa_sk_deserialize_public, /* .ssh_serialize_private = */ ssh_ecdsa_sk_serialize_private, + /* .ssh_deserialize_private = */ ssh_ecdsa_sk_deserialize_private, /* .generate = */ NULL, /* .copy_public = */ ssh_ecdsa_sk_copy_public, /* .sign = */ NULL, |