Commit e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

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 e1f315a

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update ngtcp2 to 1.20.0
PR-URL: #61511 Backport-PR-URL: #64675 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9a3f690 commit e1f315a

28 files changed

Lines changed: 368 additions & 438 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<openssl/chacha.h>
4040
#include<openssl/rand.h>
4141

42+
#include"ngtcp2_macro.h"
4243
#include"shared.h"
4344

4445
typedefenumngtcp2_crypto_boringssl_cipher_type {
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
419420
#else/* !defined(WORDS_BIGENDIAN) */
420421
memcpy(&counter, sample, sizeof(counter));
421422
#endif/* !defined(WORDS_BIGENDIAN) */
422-
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT)-1, ctx->key,
423+
CRYPTO_chacha_20(dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT), ctx->key,
423424
sample+sizeof(counter), counter);
424425
return0;
425426
default:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
845845
(void)hp;
846846

847847
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
848-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
849-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
848+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
849+
ngtcp2_strlen_lit(PLAINTEXT)) ||
850+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
850851
return-1;
851852
}
852853

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include<picotls.h>
3636
#include<picotls/openssl.h>
3737

38+
#include"ngtcp2_macro.h"
3839
#include"shared.h"
3940

4041
ngtcp2_crypto_aead*ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead*aead) {
@@ -357,7 +358,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
357358
(void)hp;
358359

359360
ptls_cipher_init(actx, sample);
360-
ptls_cipher_encrypt(actx, dest, PLAINTEXT, sizeof(PLAINTEXT)-1);
361+
ptls_cipher_encrypt(actx, dest, PLAINTEXT, ngtcp2_strlen_lit(PLAINTEXT));
361362

362363
return0;
363364
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# include<openssl/core_names.h>
4141
#endif/* OPENSSL_VERSION_NUMBER >= 0x30000000L */
4242

43+
#include"ngtcp2_macro.h"
4344
#include"shared.h"
4445

4546
#ifOPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
785786
(void)hp;
786787

787788
if (!EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) ||
788-
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT, sizeof(PLAINTEXT) -1) ||
789-
!EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len)) {
789+
!EVP_EncryptUpdate(actx, dest, &len, PLAINTEXT,
790+
ngtcp2_strlen_lit(PLAINTEXT)) ||
791+
!EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT), &len)) {
790792
return-1;
791793
}
792794

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

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen,
5353

5454
*p++= (uint8_t)(destlen / 256);
5555
*p++= (uint8_t)(destlen % 256);
56-
*p++= (uint8_t)(sizeof(LABEL)-1+labellen);
57-
memcpy(p, LABEL, sizeof(LABEL)-1);
58-
p+=sizeof(LABEL)-1;
56+
*p++= (uint8_t)(ngtcp2_strlen_lit(LABEL) +labellen);
57+
memcpy(p, LABEL, ngtcp2_strlen_lit(LABEL));
58+
p+=ngtcp2_strlen_lit(LABEL);
5959
memcpy(p, label, labellen);
6060
p+=labellen;
6161
*p++=0;
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
8888
caseNGTCP2_PROTO_VER_V1:
8989
default:
9090
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V1;
91-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V1)-1;
91+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1);
9292
break;
9393
caseNGTCP2_PROTO_VER_V2:
9494
salt= (constuint8_t*)NGTCP2_INITIAL_SALT_V2;
95-
saltlen=sizeof(NGTCP2_INITIAL_SALT_V2)-1;
95+
saltlen=ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2);
9696
break;
9797
}
9898

@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret,
111111

112112
if (ngtcp2_crypto_hkdf_expand_label(
113113
client_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
114-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL, sizeof(CLABEL) -1) !=0||
114+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, CLABEL,
115+
ngtcp2_strlen_lit(CLABEL)) !=0||
115116
ngtcp2_crypto_hkdf_expand_label(
116117
server_secret, NGTCP2_CRYPTO_INITIAL_SECRETLEN, &ctx.md, initial_secret,
117-
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL, sizeof(SLABEL) -1) !=0) {
118+
NGTCP2_CRYPTO_INITIAL_SECRETLEN, SLABEL,
119+
ngtcp2_strlen_lit(SLABEL)) !=0) {
118120
return-1;
119121
}
120122

@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key(
148150
switch (version) {
149151
caseNGTCP2_PROTO_VER_V2:
150152
key_label=KEY_LABEL_V2;
151-
key_labellen=sizeof(KEY_LABEL_V2)-1;
153+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V2);
152154
iv_label=IV_LABEL_V2;
153-
iv_labellen=sizeof(IV_LABEL_V2)-1;
155+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V2);
154156
hp_key_label=HP_KEY_LABEL_V2;
155-
hp_key_labellen=sizeof(HP_KEY_LABEL_V2)-1;
157+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V2);
156158
break;
157159
default:
158160
key_label=KEY_LABEL_V1;
159-
key_labellen=sizeof(KEY_LABEL_V1)-1;
161+
key_labellen=ngtcp2_strlen_lit(KEY_LABEL_V1);
160162
iv_label=IV_LABEL_V1;
161-
iv_labellen=sizeof(IV_LABEL_V1)-1;
163+
iv_labellen=ngtcp2_strlen_lit(IV_LABEL_V1);
162164
hp_key_label=HP_KEY_LABEL_V1;
163-
hp_key_labellen=sizeof(HP_KEY_LABEL_V1)-1;
165+
hp_key_labellen=ngtcp2_strlen_lit(HP_KEY_LABEL_V1);
164166
}
165167

166168
if (ngtcp2_crypto_hkdf_expand_label(key, keylen, md, secret, secretlen,
@@ -194,11 +196,11 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
194196
switch (version) {
195197
caseNGTCP2_PROTO_VER_V2:
196198
label=LABEL_V2;
197-
labellen=sizeof(LABEL_V2)-1;
199+
labellen=ngtcp2_strlen_lit(LABEL_V2);
198200
break;
199201
default:
200202
label=LABEL;
201-
labellen=sizeof(LABEL)-1;
203+
labellen=ngtcp2_strlen_lit(LABEL);
202204
}
203205

204206
if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen,
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key(
592594
caseNGTCP2_PROTO_VER_V1:
593595
default:
594596
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
595-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
597+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
596598
break;
597599
caseNGTCP2_PROTO_VER_V2:
598600
retry_key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
599-
retry_noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
601+
retry_noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
600602
break;
601603
}
602604

@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token,
845847
if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN,
846848
ngtcp2_crypto_md_sha256(&md), secret, secretlen,
847849
cid->data, cid->datalen, info,
848-
sizeof(info)-1) !=0) {
850+
ngtcp2_strlen_lit(info)) !=0) {
849851
return-1;
850852
}
851853

@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
865867
uint8_t*p;
866868

867869
assert(ngtcp2_crypto_md_hashlen(md) ==sizeof(intsecret));
868-
assert(info_prefixlen+sizeof(key_info_suffix)-1 <= sizeof(info));
869-
assert(info_prefixlen+sizeof(iv_info_suffix)-1 <= sizeof(info));
870+
assert(info_prefixlen+ngtcp2_strlen_lit(key_info_suffix) <= sizeof(info));
871+
assert(info_prefixlen+ngtcp2_strlen_lit(iv_info_suffix) <= sizeof(info));
870872

871873
if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt,
872874
saltlen) !=0) {
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
876878
memcpy(info, info_prefix, info_prefixlen);
877879
p=info+info_prefixlen;
878880

879-
memcpy(p, key_info_suffix, sizeof(key_info_suffix)-1);
880-
p+=sizeof(key_info_suffix)-1;
881+
memcpy(p, key_info_suffix, ngtcp2_strlen_lit(key_info_suffix));
882+
p+=ngtcp2_strlen_lit(key_info_suffix);
881883

882884
if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret),
883885
info, (size_t)(p-info)) !=0) {
@@ -886,8 +888,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv,
886888

887889
p=info+info_prefixlen;
888890

889-
memcpy(p, iv_info_suffix, sizeof(iv_info_suffix)-1);
890-
p+=sizeof(iv_info_suffix)-1;
891+
memcpy(p, iv_info_suffix, ngtcp2_strlen_lit(iv_info_suffix));
892+
p+=ngtcp2_strlen_lit(iv_info_suffix);
891893

892894
if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret),
893895
info, (size_t)(p-info)) !=0) {
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token(
963965
assert(sizeof(key) ==keylen);
964966
assert(sizeof(iv) ==ivlen);
965967

966-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
967-
rand_data, sizeof(rand_data),
968-
retry_token_info_prefix,
969-
sizeof(retry_token_info_prefix)-1) !=0) {
968+
if (crypto_derive_token_key(
969+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
970+
sizeof(rand_data),retry_token_info_prefix,
971+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
970972
return-1;
971973
}
972974

@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token(
10401042
assert(sizeof(key) ==keylen);
10411043
assert(sizeof(iv) ==ivlen);
10421044

1043-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1044-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1045-
retry_token_info_prefix,
1046-
sizeof(retry_token_info_prefix)-1) !=0) {
1045+
if (crypto_derive_token_key(
1046+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1047+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix,
1048+
ngtcp2_strlen_lit(retry_token_info_prefix)) !=0) {
10471049
return-1;
10481050
}
10491051

@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2(
11431145
assert(sizeof(key) ==keylen);
11441146
assert(sizeof(iv) ==ivlen);
11451147

1146-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1147-
rand_data, sizeof(rand_data),
1148-
retry_token_info_prefix2,
1149-
sizeof(retry_token_info_prefix2)-1) !=0) {
1148+
if (crypto_derive_token_key(
1149+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1150+
sizeof(rand_data),retry_token_info_prefix2,
1151+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
11501152
return-1;
11511153
}
11521154

@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2(
12211223
assert(sizeof(key) ==keylen);
12221224
assert(sizeof(iv) ==ivlen);
12231225

1224-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1225-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1226-
retry_token_info_prefix2,
1227-
sizeof(retry_token_info_prefix2)-1) !=0) {
1226+
if (crypto_derive_token_key(
1227+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1228+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,retry_token_info_prefix2,
1229+
ngtcp2_strlen_lit(retry_token_info_prefix2)) !=0) {
12281230
returnNGTCP2_CRYPTO_ERR_INTERNAL;
12291231
}
12301232

@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token(
13661368
assert(sizeof(key) ==keylen);
13671369
assert(sizeof(iv) ==ivlen);
13681370

1369-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1370-
rand_data, sizeof(rand_data),
1371-
regular_token_info_prefix,
1372-
sizeof(regular_token_info_prefix)-1) !=0) {
1371+
if (crypto_derive_token_key(
1372+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1373+
sizeof(rand_data),regular_token_info_prefix,
1374+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
13731375
return-1;
13741376
}
13751377

@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token(
14421444
assert(sizeof(key) ==keylen);
14431445
assert(sizeof(iv) ==ivlen);
14441446

1445-
if (crypto_derive_token_key(key, keylen, iv, ivlen, &md, secret, secretlen,
1446-
rand_data, NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,
1447-
regular_token_info_prefix,
1448-
sizeof(regular_token_info_prefix)-1) !=0) {
1447+
if (crypto_derive_token_key(
1448+
key, keylen, iv, ivlen, &md, secret, secretlen, rand_data,
1449+
NGTCP2_CRYPTO_TOKEN_RAND_DATALEN,regular_token_info_prefix,
1450+
ngtcp2_strlen_lit(regular_token_info_prefix)) !=0) {
14491451
returnNGTCP2_CRYPTO_ERR_INTERNAL;
14501452
}
14511453

@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen,
16011603
caseNGTCP2_PROTO_VER_V1:
16021604
default:
16031605
key= (constuint8_t*)NGTCP2_RETRY_KEY_V1;
1604-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V1)-1;
1606+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1);
16051607
break;
16061608
caseNGTCP2_PROTO_VER_V2:
16071609
key= (constuint8_t*)NGTCP2_RETRY_KEY_V2;
1608-
noncelen=sizeof(NGTCP2_RETRY_NONCE_V2)-1;
1610+
noncelen=ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2);
16091611
break;
16101612
}
16111613

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include<wolfssl/ssl.h>
3535
#include<wolfssl/quic.h>
3636

37+
#include"ngtcp2_macro.h"
3738
#include"shared.h"
3839

3940
#definePRINTF_DEBUG 0
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
297298
if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) !=
298299
WOLFSSL_SUCCESS||
299300
wolfSSL_EVP_CipherUpdate(actx, dest, &len, PLAINTEXT,
300-
sizeof(PLAINTEXT) -1) !=WOLFSSL_SUCCESS||
301-
wolfSSL_EVP_EncryptFinal_ex(actx, dest+sizeof(PLAINTEXT) -1, &len) !=
302-
WOLFSSL_SUCCESS) {
301+
ngtcp2_strlen_lit(PLAINTEXT)) !=
302+
WOLFSSL_SUCCESS||
303+
wolfSSL_EVP_EncryptFinal_ex(actx, dest+ngtcp2_strlen_lit(PLAINTEXT),
304+
&len) !=WOLFSSL_SUCCESS) {
303305
DEBUG_MSG("WOLFSSL: hp_mask FAILED\n");
304306
return-1;
305307
}

β€Ždeps/ngtcp2/ngtcp2/examples/client.ccβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
10491049
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10501050
uint8_t *dest, size_t destlen,
10511051
ngtcp2_tstamp ts) {
1052-
std::array<nghttp3_vec, 16> vec;
1052+
std::array<SharedVec, 16> vec;
10531053

10541054
for (;;) {
10551055
int64_t stream_id = -1;
10561056
int fin = 0;
10571057
nghttp3_ssize sveccnt = 0;
10581058

10591059
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
1060-
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
1061-
vec.data(), vec.size());
1060+
sveccnt = nghttp3_conn_writev_stream(
1061+
httpconn_, &stream_id, &fin,
1062+
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
10621063
if (sveccnt < 0) {
10631064
std::cerr << "nghttp3_conn_writev_stream: "
10641065
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10711072
}
10721073

10731074
ngtcp2_ssize ndatalen;
1074-
auto v = vec.data();
10751075
auto vcnt = static_cast<size_t>(sveccnt);
10761076

10771077
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
10811081

10821082
auto nwrite = ngtcp2_conn_writev_stream(
10831083
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
1084-
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
1084+
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
10851085
if (nwrite < 0) {
10861086
switch (nwrite) {
10871087
caseNGTCP2_ERR_STREAM_DATA_BLOCKED:

0 commit comments

Comments
Β (0)