diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-10-28 02:44:17 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-10-28 03:47:01 +0200 |
commit | 2519a7077a9332f70935e5242ba91ee670ed6b87 (patch) | |
tree | 2807e57cf1a61c8e7f8c26e273fad586c798ee2d /ssh-ecdsa.c | |
parent | upstream: refactor certify (diff) | |
download | openssh-2519a7077a9332f70935e5242ba91ee670ed6b87.tar.xz openssh-2519a7077a9332f70935e5242ba91ee670ed6b87.zip |
upstream: refactor sshkey_private_serialize_opt()
feedback/ok markus@
OpenBSD-Commit-ID: 61e0fe989897901294efe7c3b6d670cefaf44cbd
Diffstat (limited to 'ssh-ecdsa.c')
-rw-r--r-- | ssh-ecdsa.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ssh-ecdsa.c b/ssh-ecdsa.c index a7b1b7b21..27f91a251 100644 --- a/ssh-ecdsa.c +++ b/ssh-ecdsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-ecdsa.c,v 1.23 2022/10/28 00:43:08 djm Exp $ */ +/* $OpenBSD: ssh-ecdsa.c,v 1.24 2022/10/28 00:44:17 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2010 Damien Miller. All rights reserved. @@ -108,6 +108,22 @@ ssh_ecdsa_serialize_public(const struct sshkey *key, struct sshbuf *b, } static int +ssh_ecdsa_serialize_private(const struct sshkey *key, struct sshbuf *b, + enum sshkey_serialize_rep opts) +{ + int r; + + if (!sshkey_is_cert(key)) { + if ((r = ssh_ecdsa_serialize_public(key, b, opts)) != 0) + return r; + } + if ((r = sshbuf_put_bignum2(b, + EC_KEY_get0_private_key(key->ecdsa))) != 0) + return r; + return 0; +} + +static int ssh_ecdsa_generate(struct sshkey *k, int bits) { EC_KEY *private; @@ -350,6 +366,7 @@ const struct sshkey_impl_funcs sshkey_ecdsa_funcs = { /* .equal = */ ssh_ecdsa_equal, /* .ssh_serialize_public = */ ssh_ecdsa_serialize_public, /* .ssh_deserialize_public = */ ssh_ecdsa_deserialize_public, + /* .ssh_serialize_private = */ ssh_ecdsa_serialize_private, /* .generate = */ ssh_ecdsa_generate, /* .copy_public = */ ssh_ecdsa_copy_public, /* .sign = */ ssh_ecdsa_sign, |