diff options
author | tb <> | 2019-03-13 20:34:00 +0000 |
---|---|---|
committer | tb <> | 2019-03-13 20:34:00 +0000 |
commit | e44d7af88579ebe18a2d8ef57242b067993706b1 (patch) | |
tree | 81f6ab2828c3099781b20bfb3c3d4c20a8449029 | |
parent | 06abece690d53a96a5357c7304e3672e1601f54a (diff) | |
download | openbsd-e44d7af88579ebe18a2d8ef57242b067993706b1.tar.gz openbsd-e44d7af88579ebe18a2d8ef57242b067993706b1.tar.bz2 openbsd-e44d7af88579ebe18a2d8ef57242b067993706b1.zip |
Fix a number of ASN1_INTEGER vs ASN1_STRING mixups coming from the
mechanical M_ASN1 macro expansion. The ASN1_INTEGER_cmp function
takes signs into account while ASN1_STRING_cmp doesn't. The mixups
mostly involve serialNumbers, which, in principle, should be positive.
However, it is unclear whether that is checked or enforced anywhere
in the code, so these are probably bugs.
Patch from Holger Mikolon
ok jsing
-rw-r--r-- | src/lib/libcrypto/asn1/x_crl.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_doit.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_lib.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_cmp.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_sxnet.c | 4 |
5 files changed, 11 insertions, 13 deletions
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c index 0837ec15be..bc1783dbfb 100644 --- a/src/lib/libcrypto/asn1/x_crl.c +++ b/src/lib/libcrypto/asn1/x_crl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x_crl.c,v 1.33 2018/08/24 19:55:58 tb Exp $ */ | 1 | /* $OpenBSD: x_crl.c,v 1.34 2019/03/13 20:34:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -527,9 +527,7 @@ X509_CRL_dup(X509_CRL *x) | |||
527 | static int | 527 | static int |
528 | X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b) | 528 | X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b) |
529 | { | 529 | { |
530 | return(ASN1_STRING_cmp( | 530 | return(ASN1_INTEGER_cmp((*a)->serialNumber, (*b)->serialNumber)); |
531 | (ASN1_STRING *)(*a)->serialNumber, | ||
532 | (ASN1_STRING *)(*b)->serialNumber)); | ||
533 | } | 531 | } |
534 | 532 | ||
535 | int | 533 | int |
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c index 24ab957b4c..d0c27e98a9 100644 --- a/src/lib/libcrypto/pkcs7/pk7_doit.c +++ b/src/lib/libcrypto/pkcs7/pk7_doit.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pk7_doit.c,v 1.42 2017/05/02 03:59:45 deraadt Exp $ */ | 1 | /* $OpenBSD: pk7_doit.c,v 1.43 2019/03/13 20:34:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -410,7 +410,7 @@ pkcs7_cmp_ri(PKCS7_RECIP_INFO *ri, X509 *pcert) | |||
410 | pcert->cert_info->issuer); | 410 | pcert->cert_info->issuer); |
411 | if (ret) | 411 | if (ret) |
412 | return ret; | 412 | return ret; |
413 | return ASN1_STRING_cmp(pcert->cert_info->serialNumber, | 413 | return ASN1_INTEGER_cmp(pcert->cert_info->serialNumber, |
414 | ri->issuer_and_serial->serial); | 414 | ri->issuer_and_serial->serial); |
415 | } | 415 | } |
416 | 416 | ||
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c index dc407dad55..28f812a811 100644 --- a/src/lib/libcrypto/pkcs7/pk7_lib.c +++ b/src/lib/libcrypto/pkcs7/pk7_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pk7_lib.c,v 1.19 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: pk7_lib.c,v 1.20 2019/03/13 20:34:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -374,7 +374,7 @@ PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, | |||
374 | * things the ugly way. */ | 374 | * things the ugly way. */ |
375 | ASN1_INTEGER_free(p7i->issuer_and_serial->serial); | 375 | ASN1_INTEGER_free(p7i->issuer_and_serial->serial); |
376 | if (!(p7i->issuer_and_serial->serial = | 376 | if (!(p7i->issuer_and_serial->serial = |
377 | ASN1_STRING_dup(X509_get_serialNumber(x509)))) | 377 | ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) |
378 | goto err; | 378 | goto err; |
379 | 379 | ||
380 | /* lets keep the pkey around for a while */ | 380 | /* lets keep the pkey around for a while */ |
@@ -534,7 +534,7 @@ PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) | |||
534 | 534 | ||
535 | ASN1_INTEGER_free(p7i->issuer_and_serial->serial); | 535 | ASN1_INTEGER_free(p7i->issuer_and_serial->serial); |
536 | if (!(p7i->issuer_and_serial->serial = | 536 | if (!(p7i->issuer_and_serial->serial = |
537 | ASN1_STRING_dup(X509_get_serialNumber(x509)))) | 537 | ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) |
538 | return 0; | 538 | return 0; |
539 | 539 | ||
540 | pkey = X509_get_pubkey(x509); | 540 | pkey = X509_get_pubkey(x509); |
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c index 2141f871e5..6d6e840899 100644 --- a/src/lib/libcrypto/x509/x509_cmp.c +++ b/src/lib/libcrypto/x509/x509_cmp.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_cmp.c,v 1.34 2018/08/24 19:59:32 tb Exp $ */ | 1 | /* $OpenBSD: x509_cmp.c,v 1.35 2019/03/13 20:34:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -76,7 +76,7 @@ X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) | |||
76 | 76 | ||
77 | ai = a->cert_info; | 77 | ai = a->cert_info; |
78 | bi = b->cert_info; | 78 | bi = b->cert_info; |
79 | i = ASN1_STRING_cmp(ai->serialNumber, bi->serialNumber); | 79 | i = ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber); |
80 | if (i) | 80 | if (i) |
81 | return (i); | 81 | return (i); |
82 | return (X509_NAME_cmp(ai->issuer, bi->issuer)); | 82 | return (X509_NAME_cmp(ai->issuer, bi->issuer)); |
diff --git a/src/lib/libcrypto/x509v3/v3_sxnet.c b/src/lib/libcrypto/x509v3/v3_sxnet.c index 53db28248a..400bc26346 100644 --- a/src/lib/libcrypto/x509v3/v3_sxnet.c +++ b/src/lib/libcrypto/x509v3/v3_sxnet.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: v3_sxnet.c,v 1.21 2018/05/13 15:03:01 tb Exp $ */ | 1 | /* $OpenBSD: v3_sxnet.c,v 1.22 2019/03/13 20:34:00 tb 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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -376,7 +376,7 @@ SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone) | |||
376 | 376 | ||
377 | for (i = 0; i < sk_SXNETID_num(sx->ids); i++) { | 377 | for (i = 0; i < sk_SXNETID_num(sx->ids); i++) { |
378 | id = sk_SXNETID_value(sx->ids, i); | 378 | id = sk_SXNETID_value(sx->ids, i); |
379 | if (!ASN1_STRING_cmp(id->zone, zone)) | 379 | if (!ASN1_INTEGER_cmp(id->zone, zone)) |
380 | return id->user; | 380 | return id->user; |
381 | } | 381 | } |
382 | return NULL; | 382 | return NULL; |