summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509
diff options
context:
space:
mode:
authordjm <>2009-01-09 12:14:11 +0000
committerdjm <>2009-01-09 12:14:11 +0000
commita0fdc9ec41594852f67ec77dfad9cb06bacc4186 (patch)
treec43f6b3a4d93ad2cb3dcf93275295679d895a033 /src/lib/libcrypto/x509
parent5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 (diff)
downloadopenbsd-a0fdc9ec41594852f67ec77dfad9cb06bacc4186.tar.gz
openbsd-a0fdc9ec41594852f67ec77dfad9cb06bacc4186.tar.bz2
openbsd-a0fdc9ec41594852f67ec77dfad9cb06bacc4186.zip
import openssl-0.9.8j
Diffstat (limited to 'src/lib/libcrypto/x509')
-rw-r--r--src/lib/libcrypto/x509/by_dir.c4
-rw-r--r--src/lib/libcrypto/x509/x509_att.c12
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c8
-rw-r--r--src/lib/libcrypto/x509/x509_trs.c2
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c12
-rw-r--r--src/lib/libcrypto/x509/x509_vpm.c2
-rw-r--r--src/lib/libcrypto/x509/x509cset.c2
-rw-r--r--src/lib/libcrypto/x509/x509spki.c2
8 files changed, 32 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c
index 37f9a48206..341e0ba6a4 100644
--- a/src/lib/libcrypto/x509/by_dir.c
+++ b/src/lib/libcrypto/x509/by_dir.c
@@ -74,6 +74,10 @@
74#include <openssl/lhash.h> 74#include <openssl/lhash.h>
75#include <openssl/x509.h> 75#include <openssl/x509.h>
76 76
77#ifdef _WIN32
78#define stat _stat
79#endif
80
77typedef struct lookup_dir_st 81typedef struct lookup_dir_st
78 { 82 {
79 BUF_MEM *buffer; 83 BUF_MEM *buffer;
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c
index 511b49d589..98460e8921 100644
--- a/src/lib/libcrypto/x509/x509_att.c
+++ b/src/lib/libcrypto/x509/x509_att.c
@@ -245,7 +245,7 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
245 goto err; 245 goto err;
246 if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len)) 246 if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len))
247 goto err; 247 goto err;
248 248
249 if ((attr != NULL) && (*attr == NULL)) *attr=ret; 249 if ((attr != NULL) && (*attr == NULL)) *attr=ret;
250 return(ret); 250 return(ret);
251err: 251err:
@@ -302,8 +302,15 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *dat
302 atype = attrtype; 302 atype = attrtype;
303 } 303 }
304 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; 304 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
305 attr->single = 0;
306 /* This is a bit naughty because the attribute should really have
307 * at least one value but some types use and zero length SET and
308 * require this.
309 */
310 if (attrtype == 0)
311 return 1;
305 if(!(ttmp = ASN1_TYPE_new())) goto err; 312 if(!(ttmp = ASN1_TYPE_new())) goto err;
306 if (len == -1) 313 if ((len == -1) && !(attrtype & MBSTRING_FLAG))
307 { 314 {
308 if (!ASN1_TYPE_set1(ttmp, attrtype, data)) 315 if (!ASN1_TYPE_set1(ttmp, attrtype, data))
309 goto err; 316 goto err;
@@ -311,7 +318,6 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *dat
311 else 318 else
312 ASN1_TYPE_set(ttmp, atype, stmp); 319 ASN1_TYPE_set(ttmp, atype, stmp);
313 if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err; 320 if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err;
314 attr->single = 0;
315 return 1; 321 return 1;
316 err: 322 err:
317 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); 323 X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index 0d6bc653b2..e4c682fc44 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -322,10 +322,16 @@ unsigned long X509_NAME_hash(X509_NAME *x)
322 { 322 {
323 unsigned long ret=0; 323 unsigned long ret=0;
324 unsigned char md[16]; 324 unsigned char md[16];
325 EVP_MD_CTX md_ctx;
325 326
326 /* Make sure X509_NAME structure contains valid cached encoding */ 327 /* Make sure X509_NAME structure contains valid cached encoding */
327 i2d_X509_NAME(x,NULL); 328 i2d_X509_NAME(x,NULL);
328 EVP_Digest(x->bytes->data, x->bytes->length, md, NULL, EVP_md5(), NULL); 329 EVP_MD_CTX_init(&md_ctx);
330 EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
331 EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL);
332 EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length);
333 EVP_DigestFinal_ex(&md_ctx,md,NULL);
334 EVP_MD_CTX_cleanup(&md_ctx);
329 335
330 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)| 336 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
331 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) 337 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c
index 9c84a59d52..ed18700585 100644
--- a/src/lib/libcrypto/x509/x509_trs.c
+++ b/src/lib/libcrypto/x509/x509_trs.c
@@ -1,5 +1,5 @@
1/* x509_trs.c */ 1/* x509_trs.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 9a62ebcf67..336c40ddd7 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -394,7 +394,7 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
394#ifdef OPENSSL_NO_CHAIN_VERIFY 394#ifdef OPENSSL_NO_CHAIN_VERIFY
395 return 1; 395 return 1;
396#else 396#else
397 int i, ok=0, must_be_ca; 397 int i, ok=0, must_be_ca, plen = 0;
398 X509 *x; 398 X509 *x;
399 int (*cb)(int xok,X509_STORE_CTX *xctx); 399 int (*cb)(int xok,X509_STORE_CTX *xctx);
400 int proxy_path_length = 0; 400 int proxy_path_length = 0;
@@ -495,9 +495,10 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
495 if (!ok) goto end; 495 if (!ok) goto end;
496 } 496 }
497 } 497 }
498 /* Check pathlen */ 498 /* Check pathlen if not self issued */
499 if ((i > 1) && (x->ex_pathlen != -1) 499 if ((i > 1) && !(x->ex_flags & EXFLAG_SI)
500 && (i > (x->ex_pathlen + proxy_path_length + 1))) 500 && (x->ex_pathlen != -1)
501 && (plen > (x->ex_pathlen + proxy_path_length + 1)))
501 { 502 {
502 ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED; 503 ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED;
503 ctx->error_depth = i; 504 ctx->error_depth = i;
@@ -505,6 +506,9 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
505 ok=cb(0,ctx); 506 ok=cb(0,ctx);
506 if (!ok) goto end; 507 if (!ok) goto end;
507 } 508 }
509 /* Increment path length if not self issued */
510 if (!(x->ex_flags & EXFLAG_SI))
511 plen++;
508 /* If this certificate is a proxy certificate, the next 512 /* If this certificate is a proxy certificate, the next
509 certificate must be another proxy certificate or a EE 513 certificate must be another proxy certificate or a EE
510 certificate. If not, the next certificate must be a 514 certificate. If not, the next certificate must be a
diff --git a/src/lib/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c
index e9db6d62a7..c92e65936f 100644
--- a/src/lib/libcrypto/x509/x509_vpm.c
+++ b/src/lib/libcrypto/x509/x509_vpm.c
@@ -1,5 +1,5 @@
1/* x509_vpm.c */ 1/* x509_vpm.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2004. 3 * project 2004.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509/x509cset.c b/src/lib/libcrypto/x509/x509cset.c
index 9d1646d5c8..7f4004b291 100644
--- a/src/lib/libcrypto/x509/x509cset.c
+++ b/src/lib/libcrypto/x509/x509cset.c
@@ -1,5 +1,5 @@
1/* crypto/x509/x509cset.c */ 1/* crypto/x509/x509cset.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
diff --git a/src/lib/libcrypto/x509/x509spki.c b/src/lib/libcrypto/x509/x509spki.c
index ed868b838e..02a203d72c 100644
--- a/src/lib/libcrypto/x509/x509spki.c
+++ b/src/lib/libcrypto/x509/x509spki.c
@@ -1,5 +1,5 @@
1/* x509spki.c */ 1/* x509spki.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================