diff src/event/quic/ngx_event_quic_protection.c @ 8926:3341e4089c6c quic

QUIC: converted ngx_quic_keys_set_encryption_secret() to NGX codes. While here, removed check for encryption level zero, redundant by its nature.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 07 Dec 2021 15:42:10 +0300
parents de7b9af30fc6
children d8865baab732
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic_protection.c
+++ b/src/event/quic/ngx_event_quic_protection.c
@@ -649,7 +649,8 @@ failed:
 }
 
 
-int ngx_quic_keys_set_encryption_secret(ngx_pool_t *pool, ngx_uint_t is_write,
+ngx_int_t
+ngx_quic_keys_set_encryption_secret(ngx_pool_t *pool, ngx_uint_t is_write,
     ngx_quic_keys_t *keys, enum ssl_encryption_level_t level,
     const SSL_CIPHER *cipher, const uint8_t *secret, size_t secret_len)
 {
@@ -667,11 +668,7 @@ int ngx_quic_keys_set_encryption_secret(
 
     if (key_len == NGX_ERROR) {
         ngx_ssl_error(NGX_LOG_INFO, pool->log, 0, "unexpected cipher");
-        return 0;
-    }
-
-    if (level == ssl_encryption_initial) {
-        return 0;
+        return NGX_ERROR;
     }
 
     peer_secret->secret.data = ngx_pnalloc(pool, secret_len);
@@ -702,11 +699,11 @@ int ngx_quic_keys_set_encryption_secret(
                                  seq[i].secret, secret_len)
             != NGX_OK)
         {
-            return 0;
+            return NGX_ERROR;
         }
     }
 
-    return 1;
+    return NGX_OK;
 }