Skip to content

Commit d9825fa

Browse files
authored
Update BoringSSL to f961de5c47ed265c3e758ec70dd15ece20809962 (#115)
This patch also cleans up an include issue. The actual code change is in `scripts/vendor_boringssl.sh`, the rest is just the update.
1 parent d180057 commit d9825fa

15 files changed

+59
-70
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// Sources/CCryptoBoringSSL directory. The source repository is at
2121
// https://boringssl.googlesource.com/boringssl.
2222
//
23-
// BoringSSL Commit: 2fc6d38391cb76839c76b2a462619e7d69fd998d
23+
// BoringSSL Commit: f961de5c47ed265c3e758ec70dd15ece20809962
2424

2525
import PackageDescription
2626

Sources/CCryptoBoringSSL/crypto/asn1/tasn_dec.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474
*/
7575
#define ASN1_MAX_CONSTRUCTED_NEST 30
7676

77-
static int asn1_check_eoc(const unsigned char **in, long len);
78-
7977
static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
8078
char *cst, const unsigned char **in, long len,
8179
int exptag, int expclass, char opt, ASN1_TLC *ctx);
@@ -373,13 +371,6 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
373371
if (!len)
374372
break;
375373
q = p;
376-
/* TODO(https://crbug.com/boringssl/455): Although we've removed
377-
* indefinite-length support, this check is not quite a no-op.
378-
* Reject [UNIVERSAL 0] in the tag parsers themselves. */
379-
if (asn1_check_eoc(&p, len)) {
380-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
381-
goto err;
382-
}
383374
/*
384375
* This determines the OPTIONAL flag value. The field cannot be
385376
* omitted if it is the last of a SEQUENCE and there is still
@@ -592,13 +583,6 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
592583
while (len > 0) {
593584
ASN1_VALUE *skfield;
594585
const unsigned char *q = p;
595-
/* TODO(https://crbug.com/boringssl/455): Although we've removed
596-
* indefinite-length support, this check is not quite a no-op.
597-
* Reject [UNIVERSAL 0] in the tag parsers themselves. */
598-
if (asn1_check_eoc(&p, len)) {
599-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
600-
goto err;
601-
}
602586
skfield = NULL;
603587
if (!asn1_item_ex_d2i(&skfield, &p, len, ASN1_ITEM_ptr(tt->item),
604588
-1, 0, 0, ctx, depth)) {
@@ -868,21 +852,6 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
868852
return ret;
869853
}
870854

871-
/* Check for ASN1 EOC and swallow it if found */
872-
873-
static int asn1_check_eoc(const unsigned char **in, long len)
874-
{
875-
const unsigned char *p;
876-
if (len < 2)
877-
return 0;
878-
p = *in;
879-
if (!p[0] && !p[1]) {
880-
*in += 2;
881-
return 1;
882-
}
883-
return 0;
884-
}
885-
886855
/*
887856
* Check an ASN1 tag and length: a bit like ASN1_get_object but it handles
888857
* the ASN1_TLC cache and checks the expected tag.

Sources/CCryptoBoringSSL/crypto/bytestring/ber.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ static int cbs_find_ber(const CBS *orig_in, int *ber_found, unsigned depth) {
9393
return 1;
9494
}
9595

96-
// is_eoc returns true if |header_len| and |contents|, as returned by
97-
// |CBS_get_any_ber_asn1_element|, indicate an "end of contents" (EOC) value.
98-
static char is_eoc(size_t header_len, CBS *contents) {
99-
return header_len == 2 && CBS_len(contents) == 2 &&
100-
OPENSSL_memcmp(CBS_data(contents), "\x00\x00", 2) == 0;
96+
// cbs_get_eoc returns one if |cbs| begins with an "end of contents" (EOC) value
97+
// and zero otherwise. If an EOC was found, it advances |cbs| past it.
98+
static int cbs_get_eoc(CBS *cbs) {
99+
if (CBS_len(cbs) >= 2 &&
100+
CBS_data(cbs)[0] == 0 && CBS_data(cbs)[1] == 0) {
101+
return CBS_skip(cbs, 2);
102+
}
103+
return 0;
101104
}
102105

103106
// cbs_convert_ber reads BER data from |in| and writes DER data to |out|. If
@@ -116,21 +119,20 @@ static int cbs_convert_ber(CBS *in, CBB *out, unsigned string_tag,
116119
}
117120

118121
while (CBS_len(in) > 0) {
122+
if (looking_for_eoc && cbs_get_eoc(in)) {
123+
return 1;
124+
}
125+
119126
CBS contents;
120127
unsigned tag, child_string_tag = string_tag;
121128
size_t header_len;
122129
int indefinite;
123130
CBB *out_contents, out_contents_storage;
124-
125131
if (!CBS_get_any_ber_asn1_element(in, &contents, &tag, &header_len,
126132
/*out_ber_found=*/NULL, &indefinite)) {
127133
return 0;
128134
}
129135

130-
if (is_eoc(header_len, &contents)) {
131-
return looking_for_eoc;
132-
}
133-
134136
if (string_tag != 0) {
135137
// This is part of a constructed string. All elements must match
136138
// |string_tag| up to the constructed bit and get appended to |out|

Sources/CCryptoBoringSSL/crypto/bytestring/cbs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ static int parse_asn1_tag(CBS *cbs, unsigned *out) {
279279

280280
tag |= tag_number;
281281

282+
// Tag [UNIVERSAL 0] is reserved for use by the encoding. Reject it here to
283+
// avoid some ambiguity around ANY values and BER indefinite-length EOCs. See
284+
// https://crbug.com/boringssl/455.
285+
if ((tag & ~CBS_ASN1_CONSTRUCTED) == 0) {
286+
return 0;
287+
}
288+
282289
*out = tag;
283290
return 1;
284291
}

Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm.ios.aarch64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#if defined(BORINGSSL_PREFIX)
1515
#include <CCryptoBoringSSL_boringssl_prefix_symbols_asm.h>
1616
#endif
17-
#include "openssl/arm_arch.h"
17+
#include "CCryptoBoringSSL_arm_arch.h"
1818

1919
.text
2020
.align 5

Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm.linux.aarch64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#if defined(BORINGSSL_PREFIX)
1616
#include <CCryptoBoringSSL_boringssl_prefix_symbols_asm.h>
1717
#endif
18-
#include "openssl/arm_arch.h"
18+
#include "CCryptoBoringSSL_arm_arch.h"
1919

2020
.text
2121
.align 5

Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm.ios.aarch64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#if defined(BORINGSSL_PREFIX)
1515
#include <CCryptoBoringSSL_boringssl_prefix_symbols_asm.h>
1616
#endif
17-
#include "openssl/arm_arch.h"
17+
#include "CCryptoBoringSSL_arm_arch.h"
1818

1919
.text
2020
.globl _beeu_mod_inverse_vartime

Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm.linux.aarch64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#if defined(BORINGSSL_PREFIX)
1616
#include <CCryptoBoringSSL_boringssl_prefix_symbols_asm.h>
1717
#endif
18-
#include "openssl/arm_arch.h"
18+
#include "CCryptoBoringSSL_arm_arch.h"
1919

2020
.text
2121
.globl beeu_mod_inverse_vartime

Sources/CCryptoBoringSSL/crypto/internal.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@
126126
#endif
127127

128128
#if !defined(__cplusplus)
129-
#if defined(_MSC_VER)
129+
#if defined(_MSC_VER) && !defined(__clang__)
130130
#define alignas(x) __declspec(align(x))
131131
#define alignof __alignof
132132
#else
133+
// With the exception of MSVC, we require C11 to build the library. C11 is a
134+
// prerequisite for improved refcounting performance. All our supported C
135+
// compilers have long implemented C11 and made it default. The most likely
136+
// cause of pre-C11 modes is stale -std=c99 or -std=gnu99 flags in build
137+
// configuration. Such flags can be removed.
138+
#if __STDC_VERSION__ < 201112L
139+
#error "BoringSSL must be built in C11 mode or higher."
140+
#endif
133141
#include <stdalign.h>
134142
#endif
135143
#endif

Sources/CCryptoBoringSSL/hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 2fc6d38391cb76839c76b2a462619e7d69fd998d
1+
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision f961de5c47ed265c3e758ec70dd15ece20809962

0 commit comments

Comments
 (0)