summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ecdsa/ecs_vrf.c
diff options
context:
space:
mode:
authorbeck <>2015-01-28 04:14:31 +0000
committerbeck <>2015-01-28 04:14:31 +0000
commit36ad7f26648c87c63edaa9659d100b44b14f0ae1 (patch)
treef7e3e1ca2ec359adbc6581af16b8421550c018d8 /src/lib/libcrypto/ecdsa/ecs_vrf.c
parentc899559ffef49152f98a2504c0b30edb540fb863 (diff)
downloadopenbsd-36ad7f26648c87c63edaa9659d100b44b14f0ae1.tar.gz
openbsd-36ad7f26648c87c63edaa9659d100b44b14f0ae1.tar.bz2
openbsd-36ad7f26648c87c63edaa9659d100b44b14f0ae1.zip
Fix a number of issues relating to algorithms in signatures, Mostly
from OpenSSL with a hint of boring and some things done here. Addresses CVE-2014-8275 for OpenSSL fully ok miod@ doug@
Diffstat (limited to 'src/lib/libcrypto/ecdsa/ecs_vrf.c')
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_vrf.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_vrf.c b/src/lib/libcrypto/ecdsa/ecs_vrf.c
index 40a677c46a..b1e66af80a 100644
--- a/src/lib/libcrypto/ecdsa/ecs_vrf.c
+++ b/src/lib/libcrypto/ecdsa/ecs_vrf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecs_vrf.c,v 1.3 2014/07/10 22:45:57 jsing Exp $ */ 1/* $OpenBSD: ecs_vrf.c,v 1.4 2015/01/28 04:14:31 beck Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project 3 * Written by Nils Larsch for the OpenSSL project
4 */ 4 */
@@ -56,6 +56,7 @@
56 * 56 *
57 */ 57 */
58 58
59#include <string.h>
59#include <openssl/opensslconf.h> 60#include <openssl/opensslconf.h>
60 61
61#include "ecs_locl.h" 62#include "ecs_locl.h"
@@ -86,13 +87,24 @@ int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,
86 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) 87 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
87 { 88 {
88 ECDSA_SIG *s; 89 ECDSA_SIG *s;
90 unsigned char *der = NULL;
91 const unsigned char *p = sigbuf;
92 int derlen = -1;
89 int ret=-1; 93 int ret=-1;
90 94
91 s = ECDSA_SIG_new(); 95 s = ECDSA_SIG_new();
92 if (s == NULL) return(ret); 96 if (s == NULL) return(ret);
93 if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err; 97 if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) goto err;
98 /* Ensure signature uses DER and doesn't have trailing garbage */
99 derlen = i2d_ECDSA_SIG(s, &der);
100 if (derlen != sig_len || memcmp(sigbuf, der, derlen))
101 goto err;
94 ret=ECDSA_do_verify(dgst, dgst_len, s, eckey); 102 ret=ECDSA_do_verify(dgst, dgst_len, s, eckey);
95err: 103err:
104 if (derlen > 0) {
105 explicit_bzero(der, derlen);
106 free(der);
107 }
96 ECDSA_SIG_free(s); 108 ECDSA_SIG_free(s);
97 return(ret); 109 return(ret);
98 } 110 }