summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjob <>2023-04-30 16:46:49 +0000
committerjob <>2023-04-30 16:46:49 +0000
commitf31a437549264c66096a997ee2e4d7b4afecefb1 (patch)
treead7b978bb12f503e60d7814271c73dd39bc8d116
parentb84d7c53fec2427d8d237f4cef51f1aeb76d4cf7 (diff)
downloadopenbsd-f31a437549264c66096a997ee2e4d7b4afecefb1.tar.gz
openbsd-f31a437549264c66096a997ee2e4d7b4afecefb1.tar.bz2
openbsd-f31a437549264c66096a997ee2e4d7b4afecefb1.zip
Revert disablement of the encoding cache
Without the cache, we verify CRL signatures on bytes that have been pulled through d2i_ -> i2d_, this can cause reordering, which in turn invalidates the signature. for example if in the original CRL revocation entries were sorted by date instead of ascending serial number order. There are probably multiple things we can do here, but they will need careful consideration and planning. OK jsing@
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c11
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c10
2 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index ac59cc7e21..8964d467c2 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_dec.c,v 1.85 2023/04/28 17:59:53 job Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.86 2023/04/30 16:46:49 job 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 */
@@ -736,7 +736,7 @@ static int
736asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it, 736asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it,
737 int tag_number, int tag_class, int optional, int depth) 737 int tag_number, int tag_class, int optional, int depth)
738{ 738{
739 CBS cbs_seq, cbs_seq_content; 739 CBS cbs_seq, cbs_seq_content, cbs_object;
740 int constructed, indefinite, optional_field; 740 int constructed, indefinite, optional_field;
741 const ASN1_TEMPLATE *errat = NULL; 741 const ASN1_TEMPLATE *errat = NULL;
742 const ASN1_TEMPLATE *seqat, *at; 742 const ASN1_TEMPLATE *seqat, *at;
@@ -878,9 +878,14 @@ asn1_item_d2i_sequence(ASN1_VALUE **pval, CBS *cbs, const ASN1_ITEM *it,
878 ASN1_template_free(pseqval, seqat); 878 ASN1_template_free(pseqval, seqat);
879 } 879 }
880 880
881 if (!CBS_skip(cbs, CBS_offset(&cbs_seq))) 881 if (!CBS_get_bytes(cbs, &cbs_object, CBS_offset(&cbs_seq)))
882 goto err; 882 goto err;
883 883
884 if (!asn1_enc_save(&aseq, &cbs_object, it)) {
885 ASN1error(ERR_R_MALLOC_FAILURE);
886 goto err;
887 }
888
884 if (asn1_cb != NULL && !asn1_cb(ASN1_OP_D2I_POST, &aseq, it, NULL)) { 889 if (asn1_cb != NULL && !asn1_cb(ASN1_OP_D2I_POST, &aseq, it, NULL)) {
885 ASN1error(ASN1_R_AUX_ERROR); 890 ASN1error(ASN1_R_AUX_ERROR);
886 goto err; 891 goto err;
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index 430e8e1e8e..bbe8a2e949 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_enc.c,v 1.30 2023/04/28 17:59:53 job Exp $ */ 1/* $OpenBSD: tasn_enc.c,v 1.31 2023/04/30 16:46:49 job 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 */
@@ -210,6 +210,14 @@ ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it,
210 /* fall through */ 210 /* fall through */
211 211
212 case ASN1_ITYPE_SEQUENCE: 212 case ASN1_ITYPE_SEQUENCE:
213 i = asn1_enc_restore(&seqcontlen, out, pval, it);
214 /* An error occurred */
215 if (i < 0)
216 return 0;
217 /* We have a valid cached encoding... */
218 if (i > 0)
219 return seqcontlen;
220 /* Otherwise carry on */
213 seqcontlen = 0; 221 seqcontlen = 0;
214 /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ 222 /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
215 if (tag == -1) { 223 if (tag == -1) {