]> git.kaiwu.me - nginx.git/commitdiff
QUIC: renamed protection functions.
authorSergey Kandaurov <pluknet@nginx.com>
Fri, 20 Oct 2023 14:05:07 +0000 (18:05 +0400)
committerSergey Kandaurov <pluknet@nginx.com>
Fri, 20 Oct 2023 14:05:07 +0000 (18:05 +0400)
Now these functions have names ngx_quic_crypto_XXX():

  - ngx_quic_tls_open() -> ngx_quic_crypto_open()
  - ngx_quic_tls_seal() -> ngx_quic_crypto_seal()
  - ngx_quic_tls_hp() -> ngx_quic_crypto_hp()

src/event/quic/ngx_event_quic_openssl_compat.c
src/event/quic/ngx_event_quic_protection.c
src/event/quic/ngx_event_quic_protection.h

index cc6b95d482d1670b636bc4128a2342b4e18ad573..75981338bf356f81f7ede932f723e640409b139f 100644 (file)
@@ -578,8 +578,8 @@ ngx_quic_compat_create_record(ngx_quic_compat_record_t *rec, ngx_str_t *res)
     ngx_memcpy(nonce, secret->iv.data, secret->iv.len);
     ngx_quic_compute_nonce(nonce, sizeof(nonce), rec->number);
 
-    if (ngx_quic_tls_seal(ciphers.c, secret, &out,
-                          nonce, &rec->payload, &ad, rec->log)
+    if (ngx_quic_crypto_seal(ciphers.c, secret, &out,
+                             nonce, &rec->payload, &ad, rec->log)
         != NGX_OK)
     {
         return NGX_ERROR;
index 9f8169988a651c2ee89e3075044972a6d3da6106..54ee585983e85c943c8eefbce69adb51b3e3019d 100644 (file)
@@ -26,10 +26,10 @@ static ngx_int_t ngx_hkdf_extract(u_char *out_key, size_t *out_len,
 static uint64_t ngx_quic_parse_pn(u_char **pos, ngx_int_t len, u_char *mask,
     uint64_t *largest_pn);
 
-static ngx_int_t ngx_quic_tls_open(const ngx_quic_cipher_t *cipher,
+static ngx_int_t ngx_quic_crypto_open(const ngx_quic_cipher_t *cipher,
     ngx_quic_secret_t *s, ngx_str_t *out, u_char *nonce, ngx_str_t *in,
     ngx_str_t *ad, ngx_log_t *log);
-static ngx_int_t ngx_quic_tls_hp(ngx_log_t *log, const EVP_CIPHER *cipher,
+static ngx_int_t ngx_quic_crypto_hp(ngx_log_t *log, const EVP_CIPHER *cipher,
     ngx_quic_secret_t *s, u_char *out, u_char *in);
 
 static ngx_int_t ngx_quic_create_packet(ngx_quic_header_t *pkt,
@@ -344,7 +344,7 @@ failed:
 
 
 static ngx_int_t
-ngx_quic_tls_open(const ngx_quic_cipher_t *cipher, ngx_quic_secret_t *s,
+ngx_quic_crypto_open(const ngx_quic_cipher_t *cipher, ngx_quic_secret_t *s,
     ngx_str_t *out, u_char *nonce, ngx_str_t *in, ngx_str_t *ad, ngx_log_t *log)
 {
 
@@ -449,7 +449,7 @@ ngx_quic_tls_open(const ngx_quic_cipher_t *cipher, ngx_quic_secret_t *s,
 
 
 ngx_int_t
-ngx_quic_tls_seal(const ngx_quic_cipher_t *cipher, ngx_quic_secret_t *s,
+ngx_quic_crypto_seal(const ngx_quic_cipher_t *cipher, ngx_quic_secret_t *s,
     ngx_str_t *out, u_char *nonce, ngx_str_t *in, ngx_str_t *ad, ngx_log_t *log)
 {
 
@@ -565,7 +565,7 @@ ngx_quic_tls_seal(const ngx_quic_cipher_t *cipher, ngx_quic_secret_t *s,
 
 
 static ngx_int_t
-ngx_quic_tls_hp(ngx_log_t *log, const EVP_CIPHER *cipher,
+ngx_quic_crypto_hp(ngx_log_t *log, const EVP_CIPHER *cipher,
     ngx_quic_secret_t *s, u_char *out, u_char *in)
 {
     int              outlen;
@@ -801,15 +801,15 @@ ngx_quic_create_packet(ngx_quic_header_t *pkt, ngx_str_t *res)
     ngx_memcpy(nonce, secret->iv.data, secret->iv.len);
     ngx_quic_compute_nonce(nonce, sizeof(nonce), pkt->number);
 
-    if (ngx_quic_tls_seal(ciphers.c, secret, &out,
-                          nonce, &pkt->payload, &ad, pkt->log)
+    if (ngx_quic_crypto_seal(ciphers.c, secret, &out,
+                             nonce, &pkt->payload, &ad, pkt->log)
         != NGX_OK)
     {
         return NGX_ERROR;
     }
 
     sample = &out.data[4 - pkt->num_len];
-    if (ngx_quic_tls_hp(pkt->log, ciphers.hp, secret, mask, sample)
+    if (ngx_quic_crypto_hp(pkt->log, ciphers.hp, secret, mask, sample)
         != NGX_OK)
     {
         return NGX_ERROR;
@@ -862,7 +862,8 @@ ngx_quic_create_retry_packet(ngx_quic_header_t *pkt, ngx_str_t *res)
     ngx_memcpy(secret.key.data, key, sizeof(key));
     secret.iv.len = NGX_QUIC_IV_LEN;
 
-    if (ngx_quic_tls_seal(ciphers.c, &secret, &itag, nonce, &in, &ad, pkt->log)
+    if (ngx_quic_crypto_seal(ciphers.c, &secret, &itag, nonce, &in, &ad,
+                             pkt->log)
         != NGX_OK)
     {
         return NGX_ERROR;
@@ -1032,7 +1033,7 @@ ngx_quic_decrypt(ngx_quic_header_t *pkt, uint64_t *largest_pn)
 
     /* header protection */
 
-    if (ngx_quic_tls_hp(pkt->log, ciphers.hp, secret, mask, sample)
+    if (ngx_quic_crypto_hp(pkt->log, ciphers.hp, secret, mask, sample)
         != NGX_OK)
     {
         return NGX_DECLINED;
@@ -1087,8 +1088,8 @@ ngx_quic_decrypt(ngx_quic_header_t *pkt, uint64_t *largest_pn)
     pkt->payload.len = in.len - NGX_QUIC_TAG_LEN;
     pkt->payload.data = pkt->plaintext + ad.len;
 
-    rc = ngx_quic_tls_open(ciphers.c, secret, &pkt->payload,
-                           nonce, &in, &ad, pkt->log);
+    rc = ngx_quic_crypto_open(ciphers.c, secret, &pkt->payload,
+                              nonce, &in, &ad, pkt->log);
     if (rc != NGX_OK) {
         return NGX_DECLINED;
     }
index be76714225c42078f40c9a3923443e90934ab130..3c415d6957aa1246d4d356856bf9ef67500889fc 100644 (file)
@@ -105,7 +105,7 @@ ngx_int_t ngx_quic_decrypt(ngx_quic_header_t *pkt, uint64_t *largest_pn);
 void ngx_quic_compute_nonce(u_char *nonce, size_t len, uint64_t pn);
 ngx_int_t ngx_quic_ciphers(ngx_uint_t id, ngx_quic_ciphers_t *ciphers,
     enum ssl_encryption_level_t level);
-ngx_int_t ngx_quic_tls_seal(const ngx_quic_cipher_t *cipher,
+ngx_int_t ngx_quic_crypto_seal(const ngx_quic_cipher_t *cipher,
     ngx_quic_secret_t *s, ngx_str_t *out, u_char *nonce, ngx_str_t *in,
     ngx_str_t *ad, ngx_log_t *log);
 ngx_int_t ngx_quic_hkdf_expand(ngx_quic_hkdf_t *hkdf, const EVP_MD *digest,