Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit f0fc82d

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.25.0
PR-URL: #64944 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 8a00872 commit f0fc82d

35 files changed

Lines changed: 899 additions & 679 deletions

β€Ždeps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.cβ€Ž

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,33 +278,44 @@ int ngtcp2_crypto_cipher_ctx_encrypt_init(ngtcp2_crypto_cipher_ctx *cipher_ctx,
278278
constuint8_t*key) {
279279
ngtcp2_crypto_boringssl_cipher*hp_cipher=cipher->native_handle;
280280
ngtcp2_crypto_boringssl_cipher_ctx*ctx;
281-
intrv;
282-
(void)rv;
281+
intrv=0;
283282

284283
ctx=malloc(sizeof(*ctx));
285284
if (ctx==NULL) {
286285
return-1;
287286
}
288287

289-
ctx->type=hp_cipher->type;
290-
cipher_ctx->native_handle=ctx;
291-
292288
switch (hp_cipher->type) {
293289
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128:
294-
rv=AES_set_encrypt_key(key, 128, &ctx->aes_key);
295-
assert(0==rv);
296-
return0;
290+
if (AES_set_encrypt_key(key, 128, &ctx->aes_key) !=0) {
291+
rv=-1;
292+
}
293+
294+
break;
297295
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256:
298-
rv=AES_set_encrypt_key(key, 256, &ctx->aes_key);
299-
assert(0==rv);
300-
return0;
296+
if (AES_set_encrypt_key(key, 256, &ctx->aes_key) !=0) {
297+
rv=-1;
298+
}
299+
300+
break;
301301
caseNGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
302302
memcpy(ctx->key, key, sizeof(ctx->key));
303-
return0;
303+
break;
304304
default:
305305
assert(0);
306306
abort();
307307
};
308+
309+
if (rv!=0) {
310+
free(ctx);
311+
312+
returnrv;
313+
}
314+
315+
ctx->type=hp_cipher->type;
316+
cipher_ctx->native_handle=ctx;
317+
318+
return0;
308319
}
309320

310321
voidngtcp2_crypto_cipher_ctx_free(ngtcp2_crypto_cipher_ctx*cipher_ctx) {

β€Ždeps/ngtcp2/ngtcp2/crypto/ossl/ossl.cβ€Ž

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
730730
constuint8_t*secret, size_tsecretlen,
731731
constuint8_t*salt, size_tsaltlen) {
732732
constEVP_MD*prf=md->native_handle;
733-
EVP_KDF*kdf=crypto_kdf_hkdf();
734-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
733+
EVP_KDF*kdf;
734+
EVP_KDF_CTX*kctx;
735735
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
736736
OSSL_PARAMparams[] = {
737737
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -745,13 +745,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
745745
};
746746
intrv=0;
747747

748-
crypto_kdf_hkdf_free(kdf);
748+
kdf=crypto_kdf_hkdf();
749+
if (!kdf) {
750+
return-1;
751+
}
752+
753+
kctx=EVP_KDF_CTX_new(kdf);
754+
if (!kctx) {
755+
rv=-1;
756+
goto fail_kdf_ctx_new;
757+
}
749758

750759
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
751760
rv=-1;
752761
}
753762

754763
EVP_KDF_CTX_free(kctx);
764+
fail_kdf_ctx_new:
765+
crypto_kdf_hkdf_free(kdf);
755766

756767
returnrv;
757768
}
@@ -761,8 +772,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
761772
size_tsecretlen, constuint8_t*info,
762773
size_tinfolen) {
763774
constEVP_MD*prf=md->native_handle;
764-
EVP_KDF*kdf=crypto_kdf_hkdf();
765-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
775+
EVP_KDF*kdf;
776+
EVP_KDF_CTX*kctx;
766777
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
767778
OSSL_PARAMparams[] = {
768779
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -776,13 +787,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
776787
};
777788
intrv=0;
778789

779-
crypto_kdf_hkdf_free(kdf);
790+
kdf=crypto_kdf_hkdf();
791+
if (!kdf) {
792+
return-1;
793+
}
794+
795+
kctx=EVP_KDF_CTX_new(kdf);
796+
if (!kctx) {
797+
rv=-1;
798+
goto fail_kdf_ctx_new;
799+
}
780800

781801
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
782802
rv=-1;
783803
}
784804

785805
EVP_KDF_CTX_free(kctx);
806+
fail_kdf_ctx_new:
807+
crypto_kdf_hkdf_free(kdf);
786808

787809
returnrv;
788810
}
@@ -792,8 +814,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
792814
size_tsecretlen, constuint8_t*salt, size_tsaltlen,
793815
constuint8_t*info, size_tinfolen) {
794816
constEVP_MD*prf=md->native_handle;
795-
EVP_KDF*kdf=crypto_kdf_hkdf();
796-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
817+
EVP_KDF*kdf;
818+
EVP_KDF_CTX*kctx;
797819
OSSL_PARAMparams[] = {
798820
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
799821
(char*)EVP_MD_get0_name(prf), 0),
@@ -807,13 +829,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
807829
};
808830
intrv=0;
809831

810-
crypto_kdf_hkdf_free(kdf);
832+
kdf=crypto_kdf_hkdf();
833+
if (!kdf) {
834+
return-1;
835+
}
836+
837+
kctx=EVP_KDF_CTX_new(kdf);
838+
if (!kctx) {
839+
rv=-1;
840+
goto fail_kdf_ctx_new;
841+
}
811842

812843
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
813844
rv=-1;
814845
}
815846

816847
EVP_KDF_CTX_free(kctx);
848+
fail_kdf_ctx_new:
849+
crypto_kdf_hkdf_free(kdf);
817850

818851
returnrv;
819852
}

β€Ždeps/ngtcp2/ngtcp2/crypto/quictls/quictls.cβ€Ž

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include"shared.h"
4545

4646
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
47-
staticintcrypto_initialized;
4847
staticEVP_CIPHER*crypto_aes_128_gcm;
4948
staticEVP_CIPHER*crypto_aes_256_gcm;
5049
staticEVP_CIPHER*crypto_chacha20_poly1305;
@@ -57,57 +56,19 @@ static EVP_MD *crypto_sha384;
5756
staticEVP_KDF*crypto_hkdf;
5857

5958
intngtcp2_crypto_quictls_init(void) {
59+
/* We do not care whether the pre-fetch succeeds or not. If it
60+
fails, it returns NULL, which is still the default value, and our
61+
code should still work with it. */
6062
crypto_aes_128_gcm=EVP_CIPHER_fetch(NULL, "AES-128-GCM", NULL);
61-
if (crypto_aes_128_gcm==NULL) {
62-
return-1;
63-
}
64-
6563
crypto_aes_256_gcm=EVP_CIPHER_fetch(NULL, "AES-256-GCM", NULL);
66-
if (crypto_aes_256_gcm==NULL) {
67-
return-1;
68-
}
69-
7064
crypto_chacha20_poly1305=EVP_CIPHER_fetch(NULL, "ChaCha20-Poly1305", NULL);
71-
if (crypto_chacha20_poly1305==NULL) {
72-
return-1;
73-
}
74-
7565
crypto_aes_128_ccm=EVP_CIPHER_fetch(NULL, "AES-128-CCM", NULL);
76-
if (crypto_aes_128_ccm==NULL) {
77-
return-1;
78-
}
79-
8066
crypto_aes_128_ecb=EVP_CIPHER_fetch(NULL, "AES-128-ECB", NULL);
81-
if (crypto_aes_128_ecb==NULL) {
82-
return-1;
83-
}
84-
8567
crypto_aes_256_ecb=EVP_CIPHER_fetch(NULL, "AES-256-ECB", NULL);
86-
if (crypto_aes_256_ecb==NULL) {
87-
return-1;
88-
}
89-
9068
crypto_chacha20=EVP_CIPHER_fetch(NULL, "ChaCha20", NULL);
91-
if (crypto_chacha20==NULL) {
92-
return-1;
93-
}
94-
9569
crypto_sha256=EVP_MD_fetch(NULL, "sha256", NULL);
96-
if (crypto_sha256==NULL) {
97-
return-1;
98-
}
99-
10070
crypto_sha384=EVP_MD_fetch(NULL, "sha384", NULL);
101-
if (crypto_sha384==NULL) {
102-
return-1;
103-
}
104-
10571
crypto_hkdf=EVP_KDF_fetch(NULL, "hkdf", NULL);
106-
if (crypto_hkdf==NULL) {
107-
return-1;
108-
}
109-
110-
crypto_initialized=1;
11172

11273
return0;
11374
}
@@ -191,6 +152,12 @@ static EVP_KDF *crypto_kdf_hkdf(void) {
191152

192153
returnEVP_KDF_fetch(NULL, "hkdf", NULL);
193154
}
155+
156+
staticvoidcrypto_kdf_hkdf_free(EVP_KDF*kdf) {
157+
if (kdf&&crypto_hkdf!=kdf) {
158+
EVP_KDF_free(kdf);
159+
}
160+
}
194161
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
195162
# definecrypto_aead_aes_128_gcm EVP_aes_128_gcm
196163
# definecrypto_aead_aes_256_gcm EVP_aes_256_gcm
@@ -524,8 +491,8 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
524491
constuint8_t*salt, size_tsaltlen) {
525492
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
526493
constEVP_MD*prf=md->native_handle;
527-
EVP_KDF*kdf=crypto_kdf_hkdf();
528-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
494+
EVP_KDF*kdf;
495+
EVP_KDF_CTX*kctx;
529496
intmode=EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
530497
OSSL_PARAMparams[] = {
531498
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -539,15 +506,24 @@ int ngtcp2_crypto_hkdf_extract(uint8_t *dest, const ngtcp2_crypto_md *md,
539506
};
540507
intrv=0;
541508

542-
if (!crypto_initialized) {
543-
EVP_KDF_free(kdf);
509+
kdf=crypto_kdf_hkdf();
510+
if (!kdf) {
511+
return-1;
512+
}
513+
514+
kctx=EVP_KDF_CTX_new(kdf);
515+
if (!kctx) {
516+
rv=-1;
517+
goto fail_kdf_ctx_new;
544518
}
545519

546520
if (EVP_KDF_derive(kctx, dest, (size_t)EVP_MD_size(prf), params) <= 0) {
547521
rv=-1;
548522
}
549523

550524
EVP_KDF_CTX_free(kctx);
525+
fail_kdf_ctx_new:
526+
crypto_kdf_hkdf_free(kdf);
551527

552528
returnrv;
553529
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -581,8 +557,8 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
581557
size_tinfolen) {
582558
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
583559
constEVP_MD*prf=md->native_handle;
584-
EVP_KDF*kdf=crypto_kdf_hkdf();
585-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
560+
EVP_KDF*kdf;
561+
EVP_KDF_CTX*kctx;
586562
intmode=EVP_KDF_HKDF_MODE_EXPAND_ONLY;
587563
OSSL_PARAMparams[] = {
588564
OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode),
@@ -596,15 +572,24 @@ int ngtcp2_crypto_hkdf_expand(uint8_t *dest, size_t destlen,
596572
};
597573
intrv=0;
598574

599-
if (!crypto_initialized) {
600-
EVP_KDF_free(kdf);
575+
kdf=crypto_kdf_hkdf();
576+
if (!kdf) {
577+
return-1;
578+
}
579+
580+
kctx=EVP_KDF_CTX_new(kdf);
581+
if (!kctx) {
582+
rv=-1;
583+
goto fail_kdf_ctx_new;
601584
}
602585

603586
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
604587
rv=-1;
605588
}
606589

607590
EVP_KDF_CTX_free(kctx);
591+
fail_kdf_ctx_new:
592+
crypto_kdf_hkdf_free(kdf);
608593

609594
returnrv;
610595
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */
@@ -637,8 +622,8 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
637622
constuint8_t*info, size_tinfolen) {
638623
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
639624
constEVP_MD*prf=md->native_handle;
640-
EVP_KDF*kdf=crypto_kdf_hkdf();
641-
EVP_KDF_CTX*kctx=EVP_KDF_CTX_new(kdf);
625+
EVP_KDF*kdf;
626+
EVP_KDF_CTX*kctx;
642627
OSSL_PARAMparams[] = {
643628
OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
644629
(char*)EVP_MD_get0_name(prf), 0),
@@ -652,15 +637,24 @@ int ngtcp2_crypto_hkdf(uint8_t *dest, size_t destlen,
652637
};
653638
intrv=0;
654639

655-
if (!crypto_initialized) {
656-
EVP_KDF_free(kdf);
640+
kdf=crypto_kdf_hkdf();
641+
if (!kdf) {
642+
return-1;
643+
}
644+
645+
kctx=EVP_KDF_CTX_new(kdf);
646+
if (!kctx) {
647+
rv=-1;
648+
goto fail_kdf_ctx_new;
657649
}
658650

659651
if (EVP_KDF_derive(kctx, dest, destlen, params) <= 0) {
660652
rv=-1;
661653
}
662654

663655
EVP_KDF_CTX_free(kctx);
656+
fail_kdf_ctx_new:
657+
crypto_kdf_hkdf_free(kdf);
664658

665659
returnrv;
666660
#else/* !(OPENSSL_VERSION_NUMBER >= 0x30000000L) */

0 commit comments

Comments
Β (0)