diff options
author | 2019-06-14 19:55:08 +0000 | |
---|---|---|
committer | 2019-06-14 19:55:08 +0000 | |
commit | 65a104fa3c32761ba99e1844f97bd476a44a3b35 (patch) | |
tree | 1c2ca5b883335f67597a62862d4abfe9e2a8dd78 /usr.sbin/acme-client/keyproc.c | |
parent | new regress: clock_gettime(2); test if CLOCK_MONOTONIC is really monotonic (diff) | |
download | wireguard-openbsd-65a104fa3c32761ba99e1844f97bd476a44a3b35.tar.xz wireguard-openbsd-65a104fa3c32761ba99e1844f97bd476a44a3b35.zip |
Track key type (RSA or ECDSA) in an enum and clean up a bit while here.
Originaly from Renaud Allard following input from benno, tweaked by me.
OK benno
Diffstat (limited to 'usr.sbin/acme-client/keyproc.c')
-rw-r--r-- | usr.sbin/acme-client/keyproc.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/acme-client/keyproc.c b/usr.sbin/acme-client/keyproc.c index 9c392a0f3f6..cb0aca78608 100644 --- a/usr.sbin/acme-client/keyproc.c +++ b/usr.sbin/acme-client/keyproc.c @@ -1,4 +1,4 @@ -/* $Id: keyproc.c,v 1.13 2019/06/12 11:09:25 gilles Exp $ */ +/* $Id: keyproc.c,v 1.14 2019/06/14 19:55:08 florian Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -74,8 +74,8 @@ add_ext(STACK_OF(X509_EXTENSION) *sk, int nid, const char *value) * jail and, on success, ship it to "netsock" as an X509 request. */ int -keyproc(int netsock, const char *keyfile, - const char **alts, size_t altsz) +keyproc(int netsock, const char *keyfile, const char **alts, size_t altsz, + enum keytype keytype) { char *der64 = NULL, *der = NULL, *dercp; char *sans = NULL, *san = NULL; @@ -117,14 +117,17 @@ keyproc(int netsock, const char *keyfile, } if (newkey) { - if (ecdsa) { + switch (keytype) { + case KT_ECDSA: if ((pkey = ec_key_create(f, keyfile)) == NULL) goto out; dodbg("%s: generated ECDSA domain key", keyfile); - } else { + break; + case KT_RSA: if ((pkey = rsa_key_create(f, keyfile)) == NULL) goto out; dodbg("%s: generated RSA domain key", keyfile); + break; } } else { if ((pkey = key_load(f, keyfile)) == NULL) |