diff options
| author | beck <> | 2015-01-28 04:14:31 +0000 |
|---|---|---|
| committer | beck <> | 2015-01-28 04:14:31 +0000 |
| commit | 36ad7f26648c87c63edaa9659d100b44b14f0ae1 (patch) | |
| tree | f7e3e1ca2ec359adbc6581af16b8421550c018d8 /src/lib/libcrypto/dsa/dsa_asn1.c | |
| parent | c899559ffef49152f98a2504c0b30edb540fb863 (diff) | |
| download | openbsd-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/dsa/dsa_asn1.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_asn1.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c index 7040b5a672..16cb1fa379 100644 --- a/src/lib/libcrypto/dsa/dsa_asn1.c +++ b/src/lib/libcrypto/dsa/dsa_asn1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_asn1.c,v 1.13 2014/10/18 17:20:40 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_asn1.c,v 1.14 2015/01/28 04:14:31 beck Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -57,6 +57,7 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <string.h> | ||
| 60 | 61 | ||
| 61 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
| 62 | #include <openssl/asn1t.h> | 63 | #include <openssl/asn1t.h> |
| @@ -181,15 +182,26 @@ DSA_verify(int type, const unsigned char *dgst, int dgst_len, | |||
| 181 | const unsigned char *sigbuf, int siglen, DSA *dsa) | 182 | const unsigned char *sigbuf, int siglen, DSA *dsa) |
| 182 | { | 183 | { |
| 183 | DSA_SIG *s; | 184 | DSA_SIG *s; |
| 185 | unsigned char *der = NULL; | ||
| 186 | const unsigned char *p = sigbuf; | ||
| 187 | int derlen = -1; | ||
| 184 | int ret = -1; | 188 | int ret = -1; |
| 185 | 189 | ||
| 186 | s = DSA_SIG_new(); | 190 | s = DSA_SIG_new(); |
| 187 | if (s == NULL) | 191 | if (s == NULL) |
| 188 | return ret; | 192 | return ret; |
| 189 | if (d2i_DSA_SIG(&s, &sigbuf, siglen) == NULL) | 193 | if (d2i_DSA_SIG(&s, &p, siglen) == NULL) |
| 194 | goto err; | ||
| 195 | /* Ensure signature uses DER and doesn't have trailing garbage */ | ||
| 196 | derlen = i2d_DSA_SIG(s, &der); | ||
| 197 | if (derlen != siglen || memcmp(sigbuf, der, derlen)) | ||
| 190 | goto err; | 198 | goto err; |
| 191 | ret = DSA_do_verify(dgst, dgst_len, s, dsa); | 199 | ret = DSA_do_verify(dgst, dgst_len, s, dsa); |
| 192 | err: | 200 | err: |
| 201 | if (derlen > 0) { | ||
| 202 | explicit_bzero(der, derlen); | ||
| 203 | free(der); | ||
| 204 | } | ||
| 193 | DSA_SIG_free(s); | 205 | DSA_SIG_free(s); |
| 194 | return ret; | 206 | return ret; |
| 195 | } | 207 | } |
