1
Description: fix certificate fingerprints can be modified
2
Origin: upstream, https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=7fae32f6d69baf27ef69d92499c59c8a3277f3e3
3
Origin: upstream, https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=c22e2dd6e52899926d1f1ee3a2b5b9570d03130f
4
Origin: upstream, https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=63f3c9e715955f0cdc83698d8a3dfb1b80064407
5
Origin: upstream, https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=ec2fede9467ae1a65f452d3a39f7fbc4891d9285
6
Origin: upstream, https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=11f719da38c5e9aa509aa518d11f71355cca7cd1
8
Index: openssl-0.9.8k/crypto/asn1/a_bitstr.c
9
===================================================================
10
--- openssl-0.9.8k.orig/crypto/asn1/a_bitstr.c 2005-07-26 16:55:14.000000000 -0400
11
+++ openssl-0.9.8k/crypto/asn1/a_bitstr.c 2015-01-09 11:15:00.750799141 -0500
18
+ i=ASN1_R_INVALID_BIT_STRING_BITS_LEFT;
21
/* We do this to preserve the settings. If we modify
22
* the settings, via the _set_bit function, we will recalculate
24
ret->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
25
- ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|(i&0x07)); /* set */
26
+ ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|i); /* set */
28
if (len-- > 1) /* using one because of the bits left byte */
30
Index: openssl-0.9.8k/crypto/asn1/a_type.c
31
===================================================================
32
--- openssl-0.9.8k.orig/crypto/asn1/a_type.c 2008-04-02 07:11:49.000000000 -0400
33
+++ openssl-0.9.8k/crypto/asn1/a_type.c 2015-01-09 11:15:03.838826187 -0500
36
IMPLEMENT_STACK_OF(ASN1_TYPE)
37
IMPLEMENT_ASN1_SET_OF(ASN1_TYPE)
39
+/* Returns 0 if they are equal, != 0 otherwise. */
40
+int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
44
+ if (!a || !b || a->type != b->type) return -1;
49
+ result = OBJ_cmp(a->value.object, b->value.object);
52
+ result = 0; /* They do not have content. */
54
+ case V_ASN1_INTEGER:
55
+ case V_ASN1_NEG_INTEGER:
56
+ case V_ASN1_ENUMERATED:
57
+ case V_ASN1_NEG_ENUMERATED:
58
+ case V_ASN1_BIT_STRING:
59
+ case V_ASN1_OCTET_STRING:
60
+ case V_ASN1_SEQUENCE:
62
+ case V_ASN1_NUMERICSTRING:
63
+ case V_ASN1_PRINTABLESTRING:
64
+ case V_ASN1_T61STRING:
65
+ case V_ASN1_VIDEOTEXSTRING:
66
+ case V_ASN1_IA5STRING:
67
+ case V_ASN1_UTCTIME:
68
+ case V_ASN1_GENERALIZEDTIME:
69
+ case V_ASN1_GRAPHICSTRING:
70
+ case V_ASN1_VISIBLESTRING:
71
+ case V_ASN1_GENERALSTRING:
72
+ case V_ASN1_UNIVERSALSTRING:
73
+ case V_ASN1_BMPSTRING:
74
+ case V_ASN1_UTF8STRING:
77
+ result = ASN1_STRING_cmp((ASN1_STRING *) a->value.ptr,
78
+ (ASN1_STRING *) b->value.ptr);
84
Index: openssl-0.9.8k/crypto/asn1/a_verify.c
85
===================================================================
86
--- openssl-0.9.8k.orig/crypto/asn1/a_verify.c 2015-01-09 11:14:39.090609251 -0500
87
+++ openssl-0.9.8k/crypto/asn1/a_verify.c 2015-01-09 11:16:02.095335115 -0500
89
ASN1err(ASN1_F_ASN1_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
93
+ if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)
95
+ ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
100
buf_in=OPENSSL_malloc((unsigned int)inl);
105
+ if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)
107
+ ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
111
EVP_MD_CTX_init(&ctx);
112
i=OBJ_obj2nid(a->algorithm);
113
type=EVP_get_digestbyname(OBJ_nid2sn(i));
114
Index: openssl-0.9.8k/crypto/asn1/asn1.h
115
===================================================================
116
--- openssl-0.9.8k.orig/crypto/asn1/asn1.h 2015-01-09 11:14:39.234610514 -0500
117
+++ openssl-0.9.8k/crypto/asn1/asn1.h 2015-01-09 11:15:03.838826187 -0500
119
int ASN1_TYPE_get(ASN1_TYPE *a);
120
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
121
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
122
+int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
124
ASN1_OBJECT * ASN1_OBJECT_new(void );
125
void ASN1_OBJECT_free(ASN1_OBJECT *a);
126
@@ -1258,6 +1259,7 @@
127
#define ASN1_R_ILLEGAL_TIME_VALUE 184
128
#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
129
#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
130
+#define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220
131
#define ASN1_R_INVALID_BMPSTRING_LENGTH 129
132
#define ASN1_R_INVALID_DIGIT 130
133
#define ASN1_R_INVALID_MIME_TYPE 200
134
Index: openssl-0.9.8k/crypto/asn1/asn1_err.c
135
===================================================================
136
--- openssl-0.9.8k.orig/crypto/asn1/asn1_err.c 2015-01-09 11:14:39.234610514 -0500
137
+++ openssl-0.9.8k/crypto/asn1/asn1_err.c 2015-01-09 11:15:00.750799141 -0500
139
{ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) ,"illegal time value"},
140
{ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT),"integer not ascii format"},
141
{ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG),"integer too large for long"},
142
+{ERR_REASON(ASN1_R_INVALID_BIT_STRING_BITS_LEFT),"invalid bit string bits left"},
143
{ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH),"invalid bmpstring length"},
144
{ERR_REASON(ASN1_R_INVALID_DIGIT) ,"invalid digit"},
145
{ERR_REASON(ASN1_R_INVALID_MIME_TYPE) ,"invalid mime type"},
146
Index: openssl-0.9.8k/crypto/asn1/x_algor.c
147
===================================================================
148
--- openssl-0.9.8k.orig/crypto/asn1/x_algor.c 2008-11-05 13:36:39.000000000 -0500
149
+++ openssl-0.9.8k/crypto/asn1/x_algor.c 2015-01-09 11:15:03.838826187 -0500
154
+int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b)
157
+ rv = OBJ_cmp(a->algorithm, b->algorithm);
160
+ if (!a->parameter && !b->parameter)
162
+ return ASN1_TYPE_cmp(a->parameter, b->parameter);
164
Index: openssl-0.9.8k/crypto/dsa/dsa_asn1.c
165
===================================================================
166
--- openssl-0.9.8k.orig/crypto/dsa/dsa_asn1.c 2008-11-05 13:36:42.000000000 -0500
167
+++ openssl-0.9.8k/crypto/dsa/dsa_asn1.c 2015-01-09 11:15:53.619261216 -0500
169
const unsigned char *sigbuf, int siglen, DSA *dsa)
172
+ const unsigned char *p = sigbuf;
173
+ unsigned char *der = NULL;
178
if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW))
180
@@ -209,10 +213,18 @@
183
if (s == NULL) return(ret);
184
- if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
185
+ if (d2i_DSA_SIG(&s,&p,siglen) == NULL) goto err;
186
+ /* Ensure signature uses DER and doesn't have trailing garbage */
187
+ derlen = i2d_DSA_SIG(s, &der);
188
+ if (derlen != siglen || memcmp(sigbuf, der, derlen))
190
ret=DSA_do_verify(dgst,dgst_len,s,dsa);
194
+ OPENSSL_cleanse(der, derlen);
201
Index: openssl-0.9.8k/crypto/ecdsa/ecs_vrf.c
202
===================================================================
203
--- openssl-0.9.8k.orig/crypto/ecdsa/ecs_vrf.c 2005-04-29 11:56:06.000000000 -0400
204
+++ openssl-0.9.8k/crypto/ecdsa/ecs_vrf.c 2015-01-09 11:15:53.619261216 -0500
208
#include "ecs_locl.h"
209
+#include "cryptlib.h"
210
#ifndef OPENSSL_NO_ENGINE
211
#include <openssl/engine.h>
214
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
217
+ const unsigned char *p = sigbuf;
218
+ unsigned char *der = NULL;
223
if (s == NULL) return(ret);
224
- if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err;
225
+ if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) goto err;
226
+ /* Ensure signature uses DER and doesn't have trailing garbage */
227
+ derlen = i2d_ECDSA_SIG(s, &der);
228
+ if (derlen != sig_len || memcmp(sigbuf, der, derlen))
230
ret=ECDSA_do_verify(dgst, dgst_len, s, eckey);
234
+ OPENSSL_cleanse(der, derlen);
240
Index: openssl-0.9.8k/crypto/x509/x509.h
241
===================================================================
242
--- openssl-0.9.8k.orig/crypto/x509/x509.h 2008-04-02 07:11:50.000000000 -0400
243
+++ openssl-0.9.8k/crypto/x509/x509.h 2015-01-09 11:15:03.838826187 -0500
245
int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
246
void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
248
+int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
250
X509_NAME *X509_NAME_dup(X509_NAME *xn);
251
X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
252
Index: openssl-0.9.8k/crypto/x509/x_all.c
253
===================================================================
254
--- openssl-0.9.8k.orig/crypto/x509/x_all.c 2005-07-16 07:13:08.000000000 -0400
255
+++ openssl-0.9.8k/crypto/x509/x_all.c 2015-01-09 11:15:53.623261252 -0500
258
int X509_verify(X509 *a, EVP_PKEY *r)
260
+ if (X509_ALGOR_cmp(a->sig_alg, a->cert_info->signature))
262
return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg,
263
a->signature,a->cert_info,r));
265
Index: openssl-0.9.8k/util/libeay.num
266
===================================================================
267
--- openssl-0.9.8k.orig/util/libeay.num 2015-01-09 11:14:39.110609426 -0500
268
+++ openssl-0.9.8k/util/libeay.num 2015-01-09 11:15:38.775131678 -0500
269
@@ -1807,6 +1807,7 @@
270
X509_REQ_digest 2362 EXIST::FUNCTION:EVP
271
X509_CRL_digest 2391 EXIST::FUNCTION:EVP
272
d2i_ASN1_SET_OF_PKCS7 2397 NOEXIST::FUNCTION:
273
+X509_ALGOR_cmp 2398 EXIST::FUNCTION:
274
EVP_CIPHER_CTX_set_key_length 2399 EXIST::FUNCTION:
275
EVP_CIPHER_CTX_ctrl 2400 EXIST::FUNCTION:
276
BN_mod_exp_mont_word 2401 EXIST::FUNCTION:
277
@@ -3727,3 +3728,4 @@
278
ERR_load_JPAKE_strings 4112 EXIST::FUNCTION:JPAKE
279
JPAKE_STEP2_init 4113 EXIST::FUNCTION:JPAKE
280
ENGINE_load_aesni 4117 EXIST::FUNCTION:ENGINE
281
+ASN1_TYPE_cmp 4428 EXIST::FUNCTION: