Skip to content

Commit 127d374

Browse files
authored
Update BoringSSL to 25773430c07075a368416c3646fa4b07daf4968a (#91)
1 parent d89b2ef commit 127d374

Some content is hidden

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

55 files changed

+984
-714
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: 2e68a05c9943a8dec1758d4a393b2ae906fd3295
23+
// BoringSSL Commit: 25773430c07075a368416c3646fa4b07daf4968a
2424

2525
import PackageDescription
2626

Sources/CCryptoBoringSSL/crypto/asn1/a_mbstr.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
#include "internal.h"
6767
#include "../bytestring/internal.h"
6868

69-
static int is_printable(uint32_t value);
70-
7169
/*
7270
* These functions take a string in UTF8, ASCII or multibyte form and a mask
7371
* of permissible ASN1 string types. It then works out the minimal type
@@ -153,7 +151,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
153151
}
154152

155153
/* Update which output formats are still possible. */
156-
if ((mask & B_ASN1_PRINTABLESTRING) && !is_printable(c)) {
154+
if ((mask & B_ASN1_PRINTABLESTRING) && !asn1_is_printable(c)) {
157155
mask &= ~B_ASN1_PRINTABLESTRING;
158156
}
159157
if ((mask & B_ASN1_IA5STRING) && (c > 127)) {
@@ -285,24 +283,16 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
285283
return -1;
286284
}
287285

288-
/* Return 1 if the character is permitted in a PrintableString */
289-
static int is_printable(uint32_t value)
286+
int asn1_is_printable(uint32_t value)
290287
{
291-
int ch;
292-
if (value > 0x7f)
288+
if (value > 0x7f) {
293289
return 0;
294-
ch = (int)value;
295-
/*
296-
* Note: we can't use 'isalnum' because certain accented characters may
297-
* count as alphanumeric in some environments.
298-
*/
299-
if ((ch >= 'a') && (ch <= 'z'))
300-
return 1;
301-
if ((ch >= 'A') && (ch <= 'Z'))
302-
return 1;
303-
if ((ch >= '0') && (ch <= '9'))
304-
return 1;
305-
if ((ch == ' ') || strchr("'()+,-./:=?", ch))
306-
return 1;
307-
return 0;
290+
}
291+
/* Note we cannot use |isalnum| because it is locale-dependent. */
292+
return ('a' <= value && value <= 'z') || //
293+
('A' <= value && value <= 'Z') || //
294+
('0' <= value && value <= '9') || //
295+
value == ' ' || value == '\'' || value == '(' || value == ')' ||
296+
value == '+' || value == ',' || value == '-' || value == '.' ||
297+
value == '/' || value == ':' || value == '=' || value == '?';
308298
}

Sources/CCryptoBoringSSL/crypto/asn1/a_print.c

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,28 @@
5656

5757
#include <CCryptoBoringSSL_asn1.h>
5858

59-
#include <CCryptoBoringSSL_err.h>
60-
#include <CCryptoBoringSSL_mem.h>
59+
#include <string.h>
60+
61+
#include "internal.h"
62+
6163

6264
int ASN1_PRINTABLE_type(const unsigned char *s, int len)
6365
{
64-
int c;
65-
int ia5 = 0;
66-
int t61 = 0;
67-
68-
if (len <= 0)
69-
len = -1;
70-
if (s == NULL)
71-
return (V_ASN1_PRINTABLESTRING);
66+
if (len < 0) {
67+
len = strlen((const char *)s);
68+
}
7269

73-
while ((*s) && (len-- != 0)) {
74-
c = *(s++);
75-
if (!(((c >= 'a') && (c <= 'z')) ||
76-
((c >= 'A') && (c <= 'Z')) ||
77-
(c == ' ') ||
78-
((c >= '0') && (c <= '9')) ||
79-
(c == ' ') || (c == '\'') ||
80-
(c == '(') || (c == ')') ||
81-
(c == '+') || (c == ',') ||
82-
(c == '-') || (c == '.') ||
83-
(c == '/') || (c == ':') || (c == '=') || (c == '?')))
84-
ia5 = 1;
85-
if (c & 0x80)
86-
t61 = 1;
70+
int printable = 1;
71+
for (int i = 0; i < len; i++) {
72+
unsigned char c = s[i];
73+
if (c & 0x80) {
74+
/* No need to continue iterating. */
75+
return V_ASN1_T61STRING;
76+
}
77+
if (!asn1_is_printable(c)) {
78+
printable = 0;
79+
}
8780
}
88-
if (t61)
89-
return (V_ASN1_T61STRING);
90-
if (ia5)
91-
return (V_ASN1_IA5STRING);
92-
return (V_ASN1_PRINTABLESTRING);
81+
82+
return printable ? V_ASN1_PRINTABLESTRING : V_ASN1_IA5STRING;
9383
}

Sources/CCryptoBoringSSL/crypto/asn1/a_strex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static int do_hex_dump(BIO *out, unsigned char *buf, int buflen)
279279
/*
280280
* "dump" a string. This is done when the type is unknown, or the flags
281281
* request it. We can either dump the content octets or the entire DER
282-
* encoding. This uses the RFC2253 #01234 format.
282+
* encoding. This uses the RFC 2253 #01234 format.
283283
*/
284284

285285
static int do_dump(unsigned long lflags, BIO *out, const ASN1_STRING *str)

Sources/CCryptoBoringSSL/crypto/asn1/a_strnid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
118118
* Now the tables and helper functions for the string table:
119119
*/
120120

121-
/* size limits: this stuff is taken straight from RFC3280 */
121+
/* size limits: this stuff is taken straight from RFC 3280 */
122122

123123
#define ub_name 32768
124124
#define ub_common_name 64

Sources/CCryptoBoringSSL/crypto/asn1/internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
150150
* a pointer. */
151151
const void *asn1_type_value_as_pointer(const ASN1_TYPE *a);
152152

153+
/* asn1_is_printable returns one if |value| is a valid Unicode codepoint for an
154+
* ASN.1 PrintableString, and zero otherwise. */
155+
int asn1_is_printable(uint32_t value);
156+
153157

154158
#if defined(__cplusplus)
155159
} /* extern C */

Sources/CCryptoBoringSSL/crypto/bytestring/cbb.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,15 @@ int CBB_add_bytes(CBB *cbb, const uint8_t *data, size_t len) {
404404
return 1;
405405
}
406406

407+
int CBB_add_zeros(CBB *cbb, size_t len) {
408+
uint8_t *out;
409+
if (!CBB_add_space(cbb, &out, len)) {
410+
return 0;
411+
}
412+
OPENSSL_memset(out, 0, len);
413+
return 1;
414+
}
415+
407416
int CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) {
408417
if (!CBB_flush(cbb) ||
409418
!cbb_buffer_add(cbb->base, out_data, len)) {

Sources/CCryptoBoringSSL/crypto/bytestring/cbs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out) {
216216
return cbs_get_length_prefixed(cbs, out, 3);
217217
}
218218

219+
int CBS_get_until_first(CBS *cbs, CBS *out, uint8_t c) {
220+
const uint8_t *split = OPENSSL_memchr(CBS_data(cbs), c, CBS_len(cbs));
221+
if (split == NULL) {
222+
return 0;
223+
}
224+
return CBS_get_bytes(cbs, out, split - CBS_data(cbs));
225+
}
226+
219227
// parse_base128_integer reads a big-endian base-128 integer from |cbs| and sets
220228
// |*out| to the result. This is the encoding used in DER for both high tag
221229
// number form and OID components.

Sources/CCryptoBoringSSL/crypto/digest_extra/digest_extra.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static const struct nid_to_digest nid_to_digest_mapping[] = {
8383
{NID_sha256, EVP_sha256, SN_sha256, LN_sha256},
8484
{NID_sha384, EVP_sha384, SN_sha384, LN_sha384},
8585
{NID_sha512, EVP_sha512, SN_sha512, LN_sha512},
86+
{NID_sha512_256, EVP_sha512_256, SN_sha512_256, LN_sha512_256},
8687
{NID_md5_sha1, EVP_md5_sha1, SN_md5_sha1, LN_md5_sha1},
8788
// As a remnant of signing |EVP_MD|s, OpenSSL returned the corresponding
8889
// hash function when given a signature OID. To avoid unintended lax parsing

0 commit comments

Comments
 (0)