| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,6 +39,7 @@ | |||
| 39 | 39 | #include <openssl/chacha.h> | |
| 40 | 40 | #include <openssl/rand.h> | |
| 41 | 41 | ||
| 42 | + #include "ngtcp2_macro.h" | ||
| 42 | 43 | #include "shared.h" | |
| 43 | 44 | ||
| 44 | 45 | typedef enum ngtcp2_crypto_boringssl_cipher_type { | |
@@ -419,7 +420,7 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp, | |||
| 419 | 420 | #else /* !defined(WORDS_BIGENDIAN) */ | |
| 420 | 421 | memcpy(&counter, sample, sizeof(counter)); | |
| 421 | 422 | #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, | ||
| 423 | 424 | sample + sizeof(counter), counter); | |
| 424 | 425 | return 0; | |
| 425 | 426 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -845,8 +845,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp, | |||
| 845 | 845 | (void)hp; | |
| 846 | 846 | ||
| 847 | 847 | 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)) { | ||
| 850 | 851 | return -1; | |
| 851 | 852 | } | |
| 852 | 853 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ | |||
| 35 | 35 | #include <picotls.h> | |
| 36 | 36 | #include <picotls/openssl.h> | |
| 37 | 37 | ||
| 38 | + #include "ngtcp2_macro.h" | ||
| 38 | 39 | #include "shared.h" | |
| 39 | 40 | ||
| 40 | 41 | 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, | |||
| 357 | 358 | (void)hp; | |
| 358 | 359 | ||
| 359 | 360 | 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)); | ||
| 361 | 362 | ||
| 362 | 363 | return 0; | |
| 363 | 364 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ | |||
| 40 | 40 | # include <openssl/core_names.h> | |
| 41 | 41 | #endif /* OPENSSL_VERSION_NUMBER >= 0x30000000L */ | |
| 42 | 42 | ||
| 43 | + #include "ngtcp2_macro.h" | ||
| 43 | 44 | #include "shared.h" | |
| 44 | 45 | ||
| 45 | 46 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | |
@@ -785,8 +786,9 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp, | |||
| 785 | 786 | (void)hp; | |
| 786 | 787 | ||
| 787 | 788 | 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)) { | ||
| 790 | 792 | return -1; | |
| 791 | 793 | } | |
| 792 | 794 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,9 +53,9 @@ int ngtcp2_crypto_hkdf_expand_label(uint8_t *dest, size_t destlen, | |||
| 53 | 53 | ||
| 54 | 54 | *p++ = (uint8_t)(destlen / 256); | |
| 55 | 55 | *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); | ||
| 59 | 59 | memcpy(p, label, labellen); | |
| 60 | 60 | p += labellen; | |
| 61 | 61 | *p++ = 0; | |
@@ -88,11 +88,11 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret, | |||
| 88 | 88 | case NGTCP2_PROTO_VER_V1: | |
| 89 | 89 | default: | |
| 90 | 90 | salt = (const uint8_t *)NGTCP2_INITIAL_SALT_V1; | |
| 91 | - saltlen = sizeof(NGTCP2_INITIAL_SALT_V1) - 1; | ||
| 91 | + saltlen = ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V1); | ||
| 92 | 92 | break; | |
| 93 | 93 | case NGTCP2_PROTO_VER_V2: | |
| 94 | 94 | salt = (const uint8_t *)NGTCP2_INITIAL_SALT_V2; | |
| 95 | - saltlen = sizeof(NGTCP2_INITIAL_SALT_V2) - 1; | ||
| 95 | + saltlen = ngtcp2_strlen_lit(NGTCP2_INITIAL_SALT_V2); | ||
| 96 | 96 | break; | |
| 97 | 97 | } | |
| 98 | 98 | ||
@@ -111,10 +111,12 @@ int ngtcp2_crypto_derive_initial_secrets(uint8_t *rx_secret, uint8_t *tx_secret, | |||
| 111 | 111 | ||
| 112 | 112 | if (ngtcp2_crypto_hkdf_expand_label( | |
| 113 | 113 | 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 || | ||
| 115 | 116 | ngtcp2_crypto_hkdf_expand_label( | |
| 116 | 117 | 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) { | ||
| 118 | 120 | return -1; | |
| 119 | 121 | } | |
| 120 | 122 | ||
@@ -148,19 +150,19 @@ int ngtcp2_crypto_derive_packet_protection_key( | |||
| 148 | 150 | switch (version) { | |
| 149 | 151 | case NGTCP2_PROTO_VER_V2: | |
| 150 | 152 | key_label = KEY_LABEL_V2; | |
| 151 | - key_labellen = sizeof(KEY_LABEL_V2) - 1; | ||
| 153 | + key_labellen = ngtcp2_strlen_lit(KEY_LABEL_V2); | ||
| 152 | 154 | iv_label = IV_LABEL_V2; | |
| 153 | - iv_labellen = sizeof(IV_LABEL_V2) - 1; | ||
| 155 | + iv_labellen = ngtcp2_strlen_lit(IV_LABEL_V2); | ||
| 154 | 156 | 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); | ||
| 156 | 158 | break; | |
| 157 | 159 | default: | |
| 158 | 160 | key_label = KEY_LABEL_V1; | |
| 159 | - key_labellen = sizeof(KEY_LABEL_V1) - 1; | ||
| 161 | + key_labellen = ngtcp2_strlen_lit(KEY_LABEL_V1); | ||
| 160 | 162 | iv_label = IV_LABEL_V1; | |
| 161 | - iv_labellen = sizeof(IV_LABEL_V1) - 1; | ||
| 163 | + iv_labellen = ngtcp2_strlen_lit(IV_LABEL_V1); | ||
| 162 | 164 | 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); | ||
| 164 | 166 | } | |
| 165 | 167 | ||
| 166 | 168 | 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, | |||
| 194 | 196 | switch (version) { | |
| 195 | 197 | case NGTCP2_PROTO_VER_V2: | |
| 196 | 198 | label = LABEL_V2; | |
| 197 | - labellen = sizeof(LABEL_V2) - 1; | ||
| 199 | + labellen = ngtcp2_strlen_lit(LABEL_V2); | ||
| 198 | 200 | break; | |
| 199 | 201 | default: | |
| 200 | 202 | label = LABEL; | |
| 201 | - labellen = sizeof(LABEL) - 1; | ||
| 203 | + labellen = ngtcp2_strlen_lit(LABEL); | ||
| 202 | 204 | } | |
| 203 | 205 | ||
| 204 | 206 | if (ngtcp2_crypto_hkdf_expand_label(dest, secretlen, md, secret, secretlen, | |
@@ -592,11 +594,11 @@ int ngtcp2_crypto_derive_and_install_initial_key( | |||
| 592 | 594 | case NGTCP2_PROTO_VER_V1: | |
| 593 | 595 | default: | |
| 594 | 596 | retry_key = (const uint8_t *)NGTCP2_RETRY_KEY_V1; | |
| 595 | - retry_noncelen = sizeof(NGTCP2_RETRY_NONCE_V1) - 1; | ||
| 597 | + retry_noncelen = ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1); | ||
| 596 | 598 | break; | |
| 597 | 599 | case NGTCP2_PROTO_VER_V2: | |
| 598 | 600 | retry_key = (const uint8_t *)NGTCP2_RETRY_KEY_V2; | |
| 599 | - retry_noncelen = sizeof(NGTCP2_RETRY_NONCE_V2) - 1; | ||
| 601 | + retry_noncelen = ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2); | ||
| 600 | 602 | break; | |
| 601 | 603 | } | |
| 602 | 604 | ||
@@ -845,7 +847,7 @@ int ngtcp2_crypto_generate_stateless_reset_token(uint8_t *token, | |||
| 845 | 847 | if (ngtcp2_crypto_hkdf(token, NGTCP2_STATELESS_RESET_TOKENLEN, | |
| 846 | 848 | ngtcp2_crypto_md_sha256(&md), secret, secretlen, | |
| 847 | 849 | cid->data, cid->datalen, info, | |
| 848 | - sizeof(info) - 1) != 0) { | ||
| 850 | + ngtcp2_strlen_lit(info)) != 0) { | ||
| 849 | 851 | return -1; | |
| 850 | 852 | } | |
| 851 | 853 | ||
@@ -865,8 +867,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv, | |||
| 865 | 867 | uint8_t *p; | |
| 866 | 868 | ||
| 867 | 869 | 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)); | ||
| 870 | 872 | ||
| 871 | 873 | if (ngtcp2_crypto_hkdf_extract(intsecret, md, secret, secretlen, salt, | |
| 872 | 874 | saltlen) != 0) { | |
@@ -876,8 +878,8 @@ static int crypto_derive_token_key(uint8_t *key, size_t keylen, uint8_t *iv, | |||
| 876 | 878 | memcpy(info, info_prefix, info_prefixlen); | |
| 877 | 879 | p = info + info_prefixlen; | |
| 878 | 880 | ||
| 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); | ||
| 881 | 883 | ||
| 882 | 884 | if (ngtcp2_crypto_hkdf_expand(key, keylen, md, intsecret, sizeof(intsecret), | |
| 883 | 885 | 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, | |||
| 886 | 888 | ||
| 887 | 889 | p = info + info_prefixlen; | |
| 888 | 890 | ||
| 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); | ||
| 891 | 893 | ||
| 892 | 894 | if (ngtcp2_crypto_hkdf_expand(iv, ivlen, md, intsecret, sizeof(intsecret), | |
| 893 | 895 | info, (size_t)(p - info)) != 0) { | |
@@ -963,10 +965,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token( | |||
| 963 | 965 | assert(sizeof(key) == keylen); | |
| 964 | 966 | assert(sizeof(iv) == ivlen); | |
| 965 | 967 | ||
| 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) { | ||
| 970 | 972 | return -1; | |
| 971 | 973 | } | |
| 972 | 974 | ||
@@ -1040,10 +1042,10 @@ int ngtcp2_crypto_verify_retry_token( | |||
| 1040 | 1042 | assert(sizeof(key) == keylen); | |
| 1041 | 1043 | assert(sizeof(iv) == ivlen); | |
| 1042 | 1044 | ||
| 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) { | ||
| 1047 | 1049 | return -1; | |
| 1048 | 1050 | } | |
| 1049 | 1051 | ||
@@ -1143,10 +1145,10 @@ ngtcp2_ssize ngtcp2_crypto_generate_retry_token2( | |||
| 1143 | 1145 | assert(sizeof(key) == keylen); | |
| 1144 | 1146 | assert(sizeof(iv) == ivlen); | |
| 1145 | 1147 | ||
| 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) { | ||
| 1150 | 1152 | return -1; | |
| 1151 | 1153 | } | |
| 1152 | 1154 | ||
@@ -1221,10 +1223,10 @@ int ngtcp2_crypto_verify_retry_token2( | |||
| 1221 | 1223 | assert(sizeof(key) == keylen); | |
| 1222 | 1224 | assert(sizeof(iv) == ivlen); | |
| 1223 | 1225 | ||
| 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) { | ||
| 1228 | 1230 | return NGTCP2_CRYPTO_ERR_INTERNAL; | |
| 1229 | 1231 | } | |
| 1230 | 1232 | ||
@@ -1366,10 +1368,10 @@ static ngtcp2_ssize crypto_generate_regular_token( | |||
| 1366 | 1368 | assert(sizeof(key) == keylen); | |
| 1367 | 1369 | assert(sizeof(iv) == ivlen); | |
| 1368 | 1370 | ||
| 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) { | ||
| 1373 | 1375 | return -1; | |
| 1374 | 1376 | } | |
| 1375 | 1377 | ||
@@ -1442,10 +1444,10 @@ static ngtcp2_ssize crypto_verify_regular_token( | |||
| 1442 | 1444 | assert(sizeof(key) == keylen); | |
| 1443 | 1445 | assert(sizeof(iv) == ivlen); | |
| 1444 | 1446 | ||
| 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) { | ||
| 1449 | 1451 | return NGTCP2_CRYPTO_ERR_INTERNAL; | |
| 1450 | 1452 | } | |
| 1451 | 1453 | ||
@@ -1601,11 +1603,11 @@ ngtcp2_ssize ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen, | |||
| 1601 | 1603 | case NGTCP2_PROTO_VER_V1: | |
| 1602 | 1604 | default: | |
| 1603 | 1605 | key = (const uint8_t *)NGTCP2_RETRY_KEY_V1; | |
| 1604 | - noncelen = sizeof(NGTCP2_RETRY_NONCE_V1) - 1; | ||
| 1606 | + noncelen = ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V1); | ||
| 1605 | 1607 | break; | |
| 1606 | 1608 | case NGTCP2_PROTO_VER_V2: | |
| 1607 | 1609 | key = (const uint8_t *)NGTCP2_RETRY_KEY_V2; | |
| 1608 | - noncelen = sizeof(NGTCP2_RETRY_NONCE_V2) - 1; | ||
| 1610 | + noncelen = ngtcp2_strlen_lit(NGTCP2_RETRY_NONCE_V2); | ||
| 1609 | 1611 | break; | |
| 1610 | 1612 | } | |
| 1611 | 1613 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ | |||
| 34 | 34 | #include <wolfssl/ssl.h> | |
| 35 | 35 | #include <wolfssl/quic.h> | |
| 36 | 36 | ||
| 37 | + #include "ngtcp2_macro.h" | ||
| 37 | 38 | #include "shared.h" | |
| 38 | 39 | ||
| 39 | 40 | #define PRINTF_DEBUG 0 | |
@@ -297,9 +298,10 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp, | |||
| 297 | 298 | if (wolfSSL_EVP_EncryptInit_ex(actx, NULL, NULL, NULL, sample) != | |
| 298 | 299 | WOLFSSL_SUCCESS || | |
| 299 | 300 | 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) { | ||
| 303 | 305 | DEBUG_MSG("WOLFSSL: hp_mask FAILED\n"); | |
| 304 | 306 | return -1; | |
| 305 | 307 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1049,16 +1049,17 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path, | |||
| 1049 | 1049 | ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi, | |
| 1050 | 1050 | uint8_t *dest, size_t destlen, | |
| 1051 | 1051 | ngtcp2_tstamp ts) { | |
| 1052 | - std::array<nghttp3_vec, 16> vec; | ||
| 1052 | + std::array<SharedVec, 16> vec; | ||
| 1053 | 1053 | ||
| 1054 | 1054 | for (;;) { | |
| 1055 | 1055 | int64_t stream_id = -1; | |
| 1056 | 1056 | int fin = 0; | |
| 1057 | 1057 | nghttp3_ssize sveccnt = 0; | |
| 1058 | 1058 | ||
| 1059 | 1059 | 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()); | ||
| 1062 | 1063 | if (sveccnt < 0) { | |
| 1063 | 1064 | std::cerr << "nghttp3_conn_writev_stream: " | |
| 1064 | 1065 | << nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl; | |
@@ -1071,7 +1072,6 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi, | |||
| 1071 | 1072 | } | |
| 1072 | 1073 | ||
| 1073 | 1074 | ngtcp2_ssize ndatalen; | |
| 1074 | - auto v = vec.data(); | ||
| 1075 | 1075 | auto vcnt = static_cast<size_t>(sveccnt); | |
| 1076 | 1076 | ||
| 1077 | 1077 | uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE; | |
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi, | |||
| 1081 | 1081 | ||
| 1082 | 1082 | auto nwrite = ngtcp2_conn_writev_stream( | |
| 1083 | 1083 | 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); | ||
| 1085 | 1085 | if (nwrite < 0) { | |
| 1086 | 1086 | switch (nwrite) { | |
| 1087 | 1087 | case NGTCP2_ERR_STREAM_DATA_BLOCKED: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments