Skip to content

Commit dc23a24

Browse files
Lukasaweissi
authored andcommitted
Update boringssl to ff62b38 (#108)
1 parent 76b2883 commit dc23a24

Some content is hidden

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

67 files changed

+9438
-391
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import PackageDescription
2222
// Sources/CNIOBoringSSL directory. The source repository is at
2323
// https://boringssl.googlesource.com/boringssl.
2424
//
25-
// BoringSSL Commit: ad9eee1628aa4dac2ac3528cb6bb5ddf27e73560
25+
// BoringSSL Commit: ff62b38b4b5a0e7926034b5f93d0c276e55b571d
2626

2727
let package = Package(
2828
name: "swift-nio-ssl",

Sources/CNIOBoringSSL/crypto/cipher_extra/e_aesgcmsiv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
426426
return 0;
427427
}
428428

429+
if (nonce_len != EVP_AEAD_AES_GCM_SIV_NONCE_LEN) {
430+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
431+
return 0;
432+
}
433+
429434
const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
430435
const size_t plaintext_len = in_len - EVP_AEAD_AES_GCM_SIV_TAG_LEN;
431436
const uint8_t *const given_tag = in + plaintext_len;

Sources/CNIOBoringSSL/crypto/dsa/dsa.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -558,29 +558,34 @@ static int mod_mul_consttime(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
558558
}
559559

560560
DSA_SIG *DSA_do_sign(const uint8_t *digest, size_t digest_len, const DSA *dsa) {
561-
BIGNUM *kinv = NULL, *r = NULL, *s = NULL;
562-
BIGNUM m;
563-
BIGNUM xr;
564-
BN_CTX *ctx = NULL;
565-
int reason = ERR_R_BN_LIB;
566-
DSA_SIG *ret = NULL;
567-
568-
BN_init(&m);
569-
BN_init(&xr);
570-
571561
if (!dsa->p || !dsa->q || !dsa->g) {
572-
reason = DSA_R_MISSING_PARAMETERS;
573-
goto err;
562+
OPENSSL_PUT_ERROR(DSA, DSA_R_MISSING_PARAMETERS);
563+
return NULL;
564+
}
565+
566+
// Reject invalid parameters. In particular, the algorithm will infinite loop
567+
// if |g| is zero.
568+
if (BN_is_zero(dsa->p) || BN_is_zero(dsa->q) || BN_is_zero(dsa->g)) {
569+
OPENSSL_PUT_ERROR(DSA, DSA_R_INVALID_PARAMETERS);
570+
return NULL;
574571
}
575572

576573
// We only support DSA keys that are a multiple of 8 bits. (This is a weaker
577574
// check than the one in |DSA_do_check_signature|, which only allows 160-,
578575
// 224-, and 256-bit keys.
579576
if (BN_num_bits(dsa->q) % 8 != 0) {
580-
reason = DSA_R_BAD_Q_VALUE;
581-
goto err;
577+
OPENSSL_PUT_ERROR(DSA, DSA_R_BAD_Q_VALUE);
578+
return NULL;
582579
}
583580

581+
BIGNUM *kinv = NULL, *r = NULL, *s = NULL;
582+
BIGNUM m;
583+
BIGNUM xr;
584+
BN_CTX *ctx = NULL;
585+
DSA_SIG *ret = NULL;
586+
587+
BN_init(&m);
588+
BN_init(&xr);
584589
s = BN_new();
585590
if (s == NULL) {
586591
goto err;
@@ -640,7 +645,7 @@ DSA_SIG *DSA_do_sign(const uint8_t *digest, size_t digest_len, const DSA *dsa) {
640645

641646
err:
642647
if (ret == NULL) {
643-
OPENSSL_PUT_ERROR(DSA, reason);
648+
OPENSSL_PUT_ERROR(DSA, ERR_R_BN_LIB);
644649
BN_free(r);
645650
BN_free(s);
646651
}

Sources/CNIOBoringSSL/crypto/engine/engine.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ ENGINE *ENGINE_new(void) {
4141
return engine;
4242
}
4343

44-
void ENGINE_free(ENGINE *engine) {
44+
int ENGINE_free(ENGINE *engine) {
4545
// Methods are currently required to be static so are not unref'ed.
4646
OPENSSL_free(engine);
47+
return 1;
4748
}
4849

4950
// set_method takes a pointer to a method and its given size and sets

Sources/CNIOBoringSSL/crypto/err/err_data.c

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const uint32_t kOpenSSLReasonValues[] = {
7979
0x10331580,
8080
0x10339599,
8181
0x103415ac,
82-
0x10348f14,
82+
0x10348f27,
8383
0x10350c60,
8484
0x103595bf,
8585
0x103615e9,
@@ -120,7 +120,7 @@ const uint32_t kOpenSSLReasonValues[] = {
120120
0x104798ad,
121121
0x104818c2,
122122
0x104898d0,
123-
0x10490e60,
123+
0x10490e73,
124124
0x1049970a,
125125
0x104a15d4,
126126
0x14320c07,
@@ -130,24 +130,24 @@ const uint32_t kOpenSSLReasonValues[] = {
130130
0x143400ac,
131131
0x143480ea,
132132
0x18320083,
133-
0x18328f6a,
133+
0x18328f7d,
134134
0x183300ac,
135-
0x18338f80,
136-
0x18340f94,
135+
0x18338f93,
136+
0x18340fa7,
137137
0x183480ea,
138-
0x18350fa9,
139-
0x18358fc1,
140-
0x18360fd6,
141-
0x18368fea,
142-
0x1837100e,
143-
0x18379024,
144-
0x18381038,
145-
0x18389048,
138+
0x18350fbc,
139+
0x18358fd4,
140+
0x18360fe9,
141+
0x18368ffd,
142+
0x18371021,
143+
0x18379037,
144+
0x1838104b,
145+
0x1838905b,
146146
0x18390a75,
147-
0x18399058,
147+
0x1839906b,
148148
0x183a1080,
149149
0x183a90a6,
150-
0x183b0c6c,
150+
0x183b0c7f,
151151
0x183b90db,
152152
0x183c10ed,
153153
0x183c90f8,
@@ -162,7 +162,7 @@ const uint32_t kOpenSSLReasonValues[] = {
162162
0x184110c9,
163163
0x18419094,
164164
0x184210b3,
165-
0x1842906d,
165+
0x18428c6c,
166166
0x203211d0,
167167
0x203291bd,
168168
0x243211dc,
@@ -181,12 +181,13 @@ const uint32_t kOpenSSLReasonValues[] = {
181181
0x24389293,
182182
0x243912a6,
183183
0x28320c54,
184-
0x28328c6c,
184+
0x28328c7f,
185185
0x28330c24,
186-
0x28338c7f,
186+
0x28338c92,
187187
0x28340c60,
188188
0x283480ac,
189189
0x283500ea,
190+
0x28358c6c,
190191
0x2c322ec7,
191192
0x2c3292bd,
192193
0x2c332ed5,
@@ -326,39 +327,39 @@ const uint32_t kOpenSSLReasonValues[] = {
326327
0x34348bf1,
327328
0x34350bd5,
328329
0x3c320083,
329-
0x3c328ca9,
330-
0x3c330cc2,
331-
0x3c338cdd,
332-
0x3c340cfa,
333-
0x3c348d24,
334-
0x3c350d3f,
335-
0x3c358d65,
336-
0x3c360d7e,
337-
0x3c368d96,
338-
0x3c370da7,
339-
0x3c378db5,
340-
0x3c380dc2,
341-
0x3c388dd6,
342-
0x3c390c6c,
343-
0x3c398df9,
344-
0x3c3a0e0d,
330+
0x3c328cbc,
331+
0x3c330cd5,
332+
0x3c338cf0,
333+
0x3c340d0d,
334+
0x3c348d37,
335+
0x3c350d52,
336+
0x3c358d78,
337+
0x3c360d91,
338+
0x3c368da9,
339+
0x3c370dba,
340+
0x3c378dc8,
341+
0x3c380dd5,
342+
0x3c388de9,
343+
0x3c390c7f,
344+
0x3c398e0c,
345+
0x3c3a0e20,
345346
0x3c3a890f,
346-
0x3c3b0e1d,
347-
0x3c3b8e38,
348-
0x3c3c0e4a,
349-
0x3c3c8e7d,
350-
0x3c3d0e87,
351-
0x3c3d8e9b,
352-
0x3c3e0ea9,
353-
0x3c3e8ece,
354-
0x3c3f0c95,
355-
0x3c3f8eb7,
347+
0x3c3b0e30,
348+
0x3c3b8e4b,
349+
0x3c3c0e5d,
350+
0x3c3c8e90,
351+
0x3c3d0e9a,
352+
0x3c3d8eae,
353+
0x3c3e0ebc,
354+
0x3c3e8ee1,
355+
0x3c3f0ca8,
356+
0x3c3f8eca,
356357
0x3c4000ac,
357358
0x3c4080ea,
358-
0x3c410d15,
359-
0x3c418d54,
360-
0x3c420e60,
361-
0x3c428dea,
359+
0x3c410d28,
360+
0x3c418d67,
361+
0x3c420e73,
362+
0x3c428dfd,
362363
0x40321946,
363364
0x4032995c,
364365
0x4033198a,
@@ -373,7 +374,7 @@ const uint32_t kOpenSSLReasonValues[] = {
373374
0x40379a2b,
374375
0x40381a36,
375376
0x40389a48,
376-
0x40390f14,
377+
0x40390f27,
377378
0x40399a58,
378379
0x403a1a6b,
379380
0x403a9a8c,
@@ -710,17 +711,17 @@ const uint32_t kOpenSSLReasonValues[] = {
710711
0x505035f2,
711712
0x505086f1,
712713
0x50513605,
713-
0x58320f52,
714-
0x68320f14,
715-
0x68328c6c,
716-
0x68330c7f,
717-
0x68338f22,
718-
0x68340f32,
714+
0x58320f65,
715+
0x68320f27,
716+
0x68328c7f,
717+
0x68330c92,
718+
0x68338f35,
719+
0x68340f45,
719720
0x683480ea,
720-
0x6c320eda,
721+
0x6c320eed,
721722
0x6c328c36,
722-
0x6c330ee5,
723-
0x6c338efe,
723+
0x6c330ef8,
724+
0x6c338f11,
724725
0x74320a1b,
725726
0x743280ac,
726727
0x74330c47,
@@ -924,6 +925,7 @@ const char kOpenSSLReasonStringData[] =
924925
"UNKNOWN_HASH\0"
925926
"BAD_Q_VALUE\0"
926927
"BAD_VERSION\0"
928+
"INVALID_PARAMETERS\0"
927929
"MISSING_PARAMETERS\0"
928930
"NEED_NEW_SETUP_VALUES\0"
929931
"BIGNUM_OUT_OF_RANGE\0"
@@ -974,7 +976,6 @@ const char kOpenSSLReasonStringData[] =
974976
"INVALID_KEYBITS\0"
975977
"INVALID_MGF1_MD\0"
976978
"INVALID_PADDING_MODE\0"
977-
"INVALID_PARAMETERS\0"
978979
"INVALID_PSS_SALTLEN\0"
979980
"INVALID_SIGNATURE\0"
980981
"KEYS_NOT_SET\0"

Sources/CNIOBoringSSL/crypto/evp/evp.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,73 @@ int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) {
330330
return 1;
331331
}
332332

333+
EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *unused,
334+
const uint8_t *in, size_t len) {
335+
EVP_PKEY *ret = EVP_PKEY_new();
336+
if (ret == NULL ||
337+
!EVP_PKEY_set_type(ret, type)) {
338+
goto err;
339+
}
340+
341+
if (ret->ameth->set_priv_raw == NULL) {
342+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
343+
goto err;
344+
}
345+
346+
if (!ret->ameth->set_priv_raw(ret, in, len)) {
347+
goto err;
348+
}
349+
350+
return ret;
351+
352+
err:
353+
EVP_PKEY_free(ret);
354+
return NULL;
355+
}
356+
357+
EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *unused,
358+
const uint8_t *in, size_t len) {
359+
EVP_PKEY *ret = EVP_PKEY_new();
360+
if (ret == NULL ||
361+
!EVP_PKEY_set_type(ret, type)) {
362+
goto err;
363+
}
364+
365+
if (ret->ameth->set_pub_raw == NULL) {
366+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
367+
goto err;
368+
}
369+
370+
if (!ret->ameth->set_pub_raw(ret, in, len)) {
371+
goto err;
372+
}
373+
374+
return ret;
375+
376+
err:
377+
EVP_PKEY_free(ret);
378+
return NULL;
379+
}
333380

381+
int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, uint8_t *out,
382+
size_t *out_len) {
383+
if (pkey->ameth->get_priv_raw == NULL) {
384+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
385+
return 0;
386+
}
387+
388+
return pkey->ameth->get_priv_raw(pkey, out, out_len);
389+
}
390+
391+
int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, uint8_t *out,
392+
size_t *out_len) {
393+
if (pkey->ameth->get_pub_raw == NULL) {
394+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
395+
return 0;
396+
}
397+
398+
return pkey->ameth->get_pub_raw(pkey, out, out_len);
399+
}
334400

335401
int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) {
336402
if (a->type != b->type) {

Sources/CNIOBoringSSL/crypto/evp/internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ struct evp_pkey_asn1_method_st {
9696
// |out|. It returns one on success and zero on error.
9797
int (*priv_encode)(CBB *out, const EVP_PKEY *key);
9898

99+
int (*set_priv_raw)(EVP_PKEY *pkey, const uint8_t *in, size_t len);
100+
int (*set_pub_raw)(EVP_PKEY *pkey, const uint8_t *in, size_t len);
101+
int (*get_priv_raw)(const EVP_PKEY *pkey, uint8_t *out, size_t *out_len);
102+
int (*get_pub_raw)(const EVP_PKEY *pkey, uint8_t *out, size_t *out_len);
103+
99104
// pkey_opaque returns 1 if the |pk| is opaque. Opaque keys are backed by
100105
// custom implementations which do not expose key material and parameters.
101106
int (*pkey_opaque)(const EVP_PKEY *pk);

Sources/CNIOBoringSSL/crypto/evp/p_dsa_asn1.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meth = {
255255
dsa_priv_decode,
256256
dsa_priv_encode,
257257

258+
NULL /* set_priv_raw */,
259+
NULL /* set_pub_raw */,
260+
NULL /* get_priv_raw */,
261+
NULL /* get_pub_raw */,
262+
258263
NULL /* pkey_opaque */,
259264

260265
int_dsa_size,

0 commit comments

Comments
 (0)