diff options
author | 2015-02-08 13:35:06 +0000 | |
---|---|---|
committer | 2015-02-08 13:35:06 +0000 | |
commit | 63d9167de8463531a4634223ac89b01234a50ffc (patch) | |
tree | f5b708280dcad7afbee14aa1cfad0de0ab009a9b /lib/libcrypto/ecdsa/ecs_vrf.c | |
parent | Fix mfi ioctl to set drive state properly. (diff) | |
download | wireguard-openbsd-63d9167de8463531a4634223ac89b01234a50ffc.tar.xz wireguard-openbsd-63d9167de8463531a4634223ac89b01234a50ffc.zip |
Lob a KNF grenade into the ecdsa code.
Diffstat (limited to 'lib/libcrypto/ecdsa/ecs_vrf.c')
-rw-r--r-- | lib/libcrypto/ecdsa/ecs_vrf.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/lib/libcrypto/ecdsa/ecs_vrf.c b/lib/libcrypto/ecdsa/ecs_vrf.c index b1e66af80a0..a4b627ace65 100644 --- a/lib/libcrypto/ecdsa/ecs_vrf.c +++ b/lib/libcrypto/ecdsa/ecs_vrf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_vrf.c,v 1.4 2015/01/28 04:14:31 beck Exp $ */ +/* $OpenBSD: ecs_vrf.c,v 1.5 2015/02/08 13:35:07 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -69,42 +69,48 @@ * 0: incorrect signature * -1: error */ -int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey) - { +int +ECDSA_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, + EC_KEY *eckey) +{ ECDSA_DATA *ecdsa = ecdsa_check(eckey); + if (ecdsa == NULL) return 0; return ecdsa->meth->ecdsa_do_verify(dgst, dgst_len, sig, eckey); - } +} /* returns * 1: correct signature * 0: incorrect signature * -1: error */ -int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) - { +int +ECDSA_verify(int type, const unsigned char *dgst, int dgst_len, + const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) +{ ECDSA_SIG *s; unsigned char *der = NULL; const unsigned char *p = sigbuf; int derlen = -1; - int ret=-1; + int ret = -1; s = ECDSA_SIG_new(); - if (s == NULL) return(ret); - if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) goto err; + if (s == NULL) + return (ret); + if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) + goto err; /* Ensure signature uses DER and doesn't have trailing garbage */ derlen = i2d_ECDSA_SIG(s, &der); if (derlen != sig_len || memcmp(sigbuf, der, derlen)) goto err; - ret=ECDSA_do_verify(dgst, dgst_len, s, eckey); + ret = ECDSA_do_verify(dgst, dgst_len, s, eckey); + err: if (derlen > 0) { explicit_bzero(der, derlen); free(der); } ECDSA_SIG_free(s); - return(ret); - } + return (ret); +} |