Skip to content

Commit e0883b4

Browse files
LukasaYourMJKrnrojosephnoirsimonjbeaumont
authored
Final catchup merge (#415)
This is the last catchup merge into the WWDC-25 branch required to get the two branches to line up. From here, it's a straightforward merge to `main` to get the WWDC-25 branch in. --------- Co-authored-by: YourMJK <37852512+YourMJK@users.noreply.github.com> Co-authored-by: Rick Newton-Rogers <rnro@apple.com> Co-authored-by: Raphael <josephnoir@users.noreply.github.com> Co-authored-by: Si Beaumont <beaumont@apple.com> Co-authored-by: Evan Wilde <ewilde@apple.com> Co-authored-by: Tim Condon <0xTim@users.noreply.github.com> Co-authored-by: Gus Cairo <gus.cairo@apple.com> Co-authored-by: George Barnett <gbarnett@apple.com> Co-authored-by: Fabrice de Gans <Steelskin@users.noreply.github.com> Co-authored-by: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Co-authored-by: Jesse L. Zamora <xtremekforever@gmail.com> Co-authored-by: aryan-25 <aryan_shah@apple.com> Co-authored-by: Gwynne Raskind <gwynne@vapor.codes> Co-authored-by: 3405691582 <dsk@google.com> Co-authored-by: Paul Toffoloni <69189821+ptoffy@users.noreply.github.com>
1 parent 459adb9 commit e0883b4

File tree

188 files changed

+8136
-4426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+8136
-4426
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ jobs:
1414
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
1515
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
1616
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error"
17+
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error"
1718
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
1819
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
1920
windows_6_0_enabled: true
2021
windows_6_1_enabled: true
22+
windows_6_2_enabled: true
2123
windows_nightly_next_enabled: true
2224
windows_nightly_main_enabled: true
2325
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2426
windows_6_1_arguments_override: "--explicit-target-dependency-import-check error"
27+
windows_6_2_arguments_override: "--explicit-target-dependency-import-check error"
2528
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
2629
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
2730

@@ -31,6 +34,7 @@ jobs:
3134
with:
3235
windows_6_0_enabled: true
3336
windows_6_1_enabled: true
37+
windows_6_2_enabled: true
3438
windows_nightly_next_enabled: true
3539
windows_nightly_main_enabled: true
3640

.github/workflows/pull_request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ jobs:
1919
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
2020
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2121
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error"
22+
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error"
2223
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
2324
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
2425
windows_6_0_enabled: true
2526
windows_6_1_enabled: true
27+
windows_6_2_enabled: true
2628
windows_nightly_next_enabled: true
2729
windows_nightly_main_enabled: true
2830
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2931
windows_6_1_arguments_override: "--explicit-target-dependency-import-check error"
32+
windows_6_2_arguments_override: "--explicit-target-dependency-import-check error"
3033
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
3134
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
3235

@@ -36,6 +39,7 @@ jobs:
3639
with:
3740
windows_6_0_enabled: true
3841
windows_6_1_enabled: true
42+
windows_6_2_enabled: true
3943
windows_nightly_next_enabled: true
4044
windows_nightly_main_enabled: true
4145

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: 035e720641f385e82c72b7b0a9e1d89e58cb5ed5
23+
// BoringSSL Commit: 0226f30467f540a3f62ef48d453f93927da199b6
2424

2525
import PackageDescription
2626

Sources/CCryptoBoringSSL/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ add_library(CCryptoBoringSSL STATIC
255255
"crypto/x509/x_req.cc"
256256
"crypto/x509/x_sig.cc"
257257
"crypto/x509/x_spki.cc"
258-
"crypto/x509/x_val.cc"
259258
"crypto/x509/x_x509.cc"
260259
"crypto/x509/x_x509a.cc"
261260
"crypto/xwing/xwing.cc"

Sources/CCryptoBoringSSL/crypto/asn1/a_bitstr.cc

Lines changed: 72 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <CCryptoBoringSSL_bytestring.h>
2121
#include <CCryptoBoringSSL_err.h>
2222
#include <CCryptoBoringSSL_mem.h>
23+
#include <CCryptoBoringSSL_span.h>
2324

2425
#include "../internal.h"
2526
#include "internal.h"
@@ -110,76 +111,96 @@ int asn1_marshal_bit_string(CBB *out, const ASN1_BIT_STRING *in,
110111
CBB_flush(out);
111112
}
112113

113-
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
114-
const unsigned char **pp, long len) {
115-
ASN1_BIT_STRING *ret = NULL;
116-
const unsigned char *p;
117-
unsigned char *s;
118-
int padding;
119-
uint8_t padding_mask;
120-
121-
if (len < 1) {
114+
static int asn1_parse_bit_string_contents(bssl::Span<const uint8_t> in,
115+
ASN1_BIT_STRING *out) {
116+
CBS cbs = in;
117+
uint8_t padding;
118+
if (!CBS_get_u8(&cbs, &padding)) {
122119
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
123-
goto err;
120+
return 0;
124121
}
125122

126-
if (len > INT_MAX) {
127-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
128-
goto err;
123+
if (padding > 7) {
124+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
125+
return 0;
129126
}
130127

131-
if ((a == NULL) || ((*a) == NULL)) {
132-
if ((ret = ASN1_BIT_STRING_new()) == NULL) {
133-
return NULL;
128+
// Unused bits in a BIT STRING must be zero.
129+
uint8_t padding_mask = (1 << padding) - 1;
130+
if (padding != 0) {
131+
CBS copy = cbs;
132+
uint8_t last;
133+
if (!CBS_get_last_u8(&copy, &last) || (last & padding_mask) != 0) {
134+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_PADDING);
135+
return 0;
134136
}
135-
} else {
136-
ret = (*a);
137137
}
138138

139-
p = *pp;
140-
padding = *(p++);
141-
len--;
142-
if (padding > 7) {
143-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
144-
goto err;
139+
if (!ASN1_STRING_set(out, CBS_data(&cbs), CBS_len(&cbs))) {
140+
return 0;
145141
}
146142

147-
// Unused bits in a BIT STRING must be zero.
148-
padding_mask = (1 << padding) - 1;
149-
if (padding != 0 && (len < 1 || (p[len - 1] & padding_mask) != 0)) {
150-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_PADDING);
151-
goto err;
152-
}
143+
out->type = V_ASN1_BIT_STRING;
144+
// |ASN1_STRING_FLAG_BITS_LEFT| and the bottom 3 bits encode |padding|.
145+
out->flags &= ~0x07;
146+
out->flags |= ASN1_STRING_FLAG_BITS_LEFT | padding;
147+
return 1;
148+
}
153149

154-
// We do this to preserve the settings. If we modify the settings, via
155-
// the _set_bit function, we will recalculate on output
156-
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); // clear
157-
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); // set
150+
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
151+
const unsigned char **pp, long len) {
152+
if (len < 0) {
153+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
154+
return nullptr;
155+
}
158156

159-
if (len > 0) {
160-
s = reinterpret_cast<uint8_t *>(OPENSSL_memdup(p, len));
161-
if (s == NULL) {
162-
goto err;
157+
ASN1_BIT_STRING *ret = nullptr;
158+
if (a == nullptr || *a == nullptr) {
159+
if ((ret = ASN1_BIT_STRING_new()) == nullptr) {
160+
return nullptr;
163161
}
164-
p += len;
165162
} else {
166-
s = NULL;
163+
ret = *a;
167164
}
168165

169-
ret->length = (int)len;
170-
OPENSSL_free(ret->data);
171-
ret->data = s;
172-
ret->type = V_ASN1_BIT_STRING;
173-
if (a != NULL) {
174-
(*a) = ret;
166+
if (!asn1_parse_bit_string_contents(bssl::Span(*pp, len), ret)) {
167+
if (ret != nullptr && (a == nullptr || *a != ret)) {
168+
ASN1_BIT_STRING_free(ret);
169+
}
170+
return nullptr;
175171
}
176-
*pp = p;
172+
173+
if (a != nullptr) {
174+
*a = ret;
175+
}
176+
*pp += len;
177177
return ret;
178-
err:
179-
if ((ret != NULL) && ((a == NULL) || (*a != ret))) {
180-
ASN1_BIT_STRING_free(ret);
178+
}
179+
180+
int asn1_parse_bit_string(CBS *cbs, ASN1_BIT_STRING *out, CBS_ASN1_TAG tag) {
181+
tag = tag == 0 ? CBS_ASN1_BITSTRING : tag;
182+
CBS child;
183+
if (!CBS_get_asn1(cbs, &child, tag)) {
184+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
185+
return 0;
186+
}
187+
return asn1_parse_bit_string_contents(child, out);
188+
}
189+
190+
int asn1_parse_bit_string_with_bad_length(CBS *cbs, ASN1_BIT_STRING *out) {
191+
CBS child;
192+
CBS_ASN1_TAG tag;
193+
size_t header_len;
194+
int indefinite;
195+
if (!CBS_get_any_ber_asn1_element(cbs, &child, &tag, &header_len,
196+
/*out_ber_found=*/nullptr,
197+
&indefinite) ||
198+
tag != CBS_ASN1_BITSTRING || indefinite || //
199+
!CBS_skip(&child, header_len)) {
200+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
201+
return 0;
181202
}
182-
return NULL;
203+
return asn1_parse_bit_string_contents(child, out);
183204
}
184205

185206
// These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>

Sources/CCryptoBoringSSL/crypto/asn1/a_bool.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121

2222

2323
int i2d_ASN1_BOOLEAN(ASN1_BOOLEAN a, unsigned char **outp) {
24-
CBB cbb;
25-
if (!CBB_init(&cbb, 3) || //
26-
!CBB_add_asn1_bool(&cbb, a != ASN1_BOOLEAN_FALSE)) {
27-
CBB_cleanup(&cbb);
28-
return -1;
29-
}
30-
return CBB_finish_i2d(&cbb, outp);
24+
return bssl::I2DFromCBB(
25+
/*initial_capacity=*/3, outp, [&](CBB *cbb) -> bool {
26+
return CBB_add_asn1_bool(cbb, a != ASN1_BOOLEAN_FALSE);
27+
});
3128
}
3229

3330
ASN1_BOOLEAN d2i_ASN1_BOOLEAN(ASN1_BOOLEAN *out, const unsigned char **inp,

Sources/CCryptoBoringSSL/crypto/asn1/a_gentm.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) {
3636
return 1;
3737
}
3838

39+
int asn1_parse_generalized_time(CBS *cbs, ASN1_GENERALIZEDTIME *out,
40+
CBS_ASN1_TAG tag) {
41+
tag = tag == 0 ? CBS_ASN1_GENERALIZEDTIME : tag;
42+
CBS child;
43+
if (!CBS_get_asn1(cbs, &child, tag) ||
44+
!CBS_parse_generalized_time(&child, nullptr,
45+
/*allow_timezone_offset=*/0)) {
46+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
47+
return 0;
48+
}
49+
if (!ASN1_STRING_set(out, CBS_data(&child), CBS_len(&child))) {
50+
return 0;
51+
}
52+
out->type = V_ASN1_GENERALIZEDTIME;
53+
return 1;
54+
}
55+
3956
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) {
4057
return asn1_generalizedtime_to_tm(NULL, d);
4158
}

0 commit comments

Comments
 (0)