Welcome! Log In Create A New Profile

Advanced

[PATCH 8 of 8] QUIC: explicitly zero out unused keying material

Sergey Kandaurov
September 07, 2023 11:18AM
# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1694099425 -14400
# Thu Sep 07 19:10:25 2023 +0400
# Node ID 813128cee322830435a95903993b17fb24683da7
# Parent 8bd0104b7e6b658a1696fe7f3e2f1868ac2ae1f9
QUIC: explicitly zero out unused keying material.

diff --git a/src/event/quic/ngx_event_quic_openssl_compat.c b/src/event/quic/ngx_event_quic_openssl_compat.c
--- a/src/event/quic/ngx_event_quic_openssl_compat.c
+++ b/src/event/quic/ngx_event_quic_openssl_compat.c
@@ -245,15 +245,6 @@ ngx_quic_compat_set_encryption_secret(ng
return NGX_ERROR;
}

- if (sizeof(peer_secret->secret.data) < secret_len) {
- ngx_log_error(NGX_LOG_ALERT, c->log, 0,
- "unexpected secret len: %uz", secret_len);
- return NGX_ERROR;
- }
-
- peer_secret->secret.len = secret_len;
- ngx_memcpy(peer_secret->secret.data, secret, secret_len);
-
peer_secret->key.len = key_len;
peer_secret->iv.len = NGX_QUIC_IV_LEN;

@@ -275,6 +266,9 @@ ngx_quic_compat_set_encryption_secret(ng
return NGX_ERROR;
}

+ ngx_explicit_memzero(secret_str.data, secret_str.len);
+ ngx_explicit_memzero(peer_secret->key.data, peer_secret->key.len);
+
/* register cleanup handler once */

if (level == ssl_encryption_handshake) {
diff --git a/src/event/quic/ngx_event_quic_protection.c b/src/event/quic/ngx_event_quic_protection.c
--- a/src/event/quic/ngx_event_quic_protection.c
+++ b/src/event/quic/ngx_event_quic_protection.c
@@ -719,6 +719,8 @@ ngx_quic_keys_set_encryption_secret(ngx_
return NGX_ERROR;
}

+ ngx_explicit_memzero(peer_secret->key.data, peer_secret->key.len);
+
return NGX_OK;
}

@@ -749,6 +751,12 @@ ngx_quic_keys_discard(ngx_quic_keys_t *k

ngx_quic_crypto_hp_cleanup(client);
ngx_quic_crypto_hp_cleanup(server);
+
+ ngx_explicit_memzero(client->secret.data, client->secret.len);
+ ngx_explicit_memzero(client->key.data, client->key.len);
+
+ ngx_explicit_memzero(server->secret.data, server->secret.len);
+ ngx_explicit_memzero(server->key.data, server->key.len);
}


@@ -838,6 +846,14 @@ ngx_quic_keys_update(ngx_event_t *ev)
goto failed;
}

+ ngx_explicit_memzero(current->client.secret.data,
+ current->client.secret.len);
+ ngx_explicit_memzero(current->server.secret.data,
+ current->server.secret.len);
+
+ ngx_explicit_memzero(next->client.key.data, next->client.key.len);
+ ngx_explicit_memzero(next->server.key.data, next->server.key.len);
+
return;

failed:
@@ -866,6 +882,12 @@ ngx_quic_keys_cleanup(void *data)
secrets = &keys->next_key;
ngx_quic_crypto_cleanup(&secrets->client);
ngx_quic_crypto_cleanup(&secrets->server);
+
+ ngx_explicit_memzero(secrets->client.secret.data,
+ secrets->client.secret.len);
+
+ ngx_explicit_memzero(secrets->server.secret.data,
+ secrets->server.secret.len);
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 8] [quic] reusing crypto contexts, and more

Sergey Kandaurov 387 September 07, 2023 11:18AM

[PATCH 1 of 8] QUIC: split keys availability checks to read and write sides

Sergey Kandaurov 41 September 07, 2023 11:18AM

Re: [PATCH 1 of 8] QUIC: split keys availability checks to read and write sides

Roman Arutyunyan 41 September 21, 2023 09:30AM

[PATCH 2 of 8] QUIC: added check to prevent packet output with discarded keys

Sergey Kandaurov 38 September 07, 2023 11:18AM

Re: [PATCH 2 of 8] QUIC: added check to prevent packet output with discarded keys

Roman Arutyunyan 46 September 18, 2023 03:10AM

Re: [PATCH 2 of 8] QUIC: added check to prevent packet output with discarded keys

Sergey Kandaurov 43 October 13, 2023 11:10AM

[PATCH 3 of 8] QUIC: prevented output of ACK frame when discarding handshake keys

Sergey Kandaurov 39 September 07, 2023 11:18AM

[PATCH 4 of 8] QUIC: renamed protection functions

Sergey Kandaurov 35 September 07, 2023 11:18AM

Re: [PATCH 4 of 8] QUIC: renamed protection functions

Roman Arutyunyan 44 September 21, 2023 09:32AM

[PATCH 5 of 8] QUIC: reusing crypto contexts for packet protection

Sergey Kandaurov 41 September 07, 2023 11:18AM

Re: [PATCH 5 of 8] QUIC: reusing crypto contexts for packet protection

Roman Arutyunyan 46 September 19, 2023 09:54AM

Re: [PATCH 5 of 8] QUIC: reusing crypto contexts for packet protection

Sergey Kandaurov 33 October 13, 2023 11:14AM

Re: [PATCH 5 of 8] QUIC: reusing crypto contexts for packet protection

Sergey Kandaurov 30 October 17, 2023 06:40AM

Re: [PATCH 5 of 8] QUIC: reusing crypto contexts for packet protection

Sergey Kandaurov 47 October 23, 2023 06:38PM

[PATCH 6 of 8] QUIC: reusing crypto contexts for header protection

Sergey Kandaurov 37 September 07, 2023 11:18AM

Re: [PATCH 6 of 8] QUIC: reusing crypto contexts for header protection

Roman Arutyunyan 36 September 20, 2023 08:14AM

Re: [PATCH 6 of 8] QUIC: reusing crypto contexts for header protection

Sergey Kandaurov 31 October 13, 2023 11:14AM

[PATCH 7 of 8] QUIC: cleaned up now unused ngx_quic_ciphers() calls

Sergey Kandaurov 37 September 07, 2023 11:18AM

Re: [PATCH 7 of 8] QUIC: cleaned up now unused ngx_quic_ciphers() calls

Roman Arutyunyan 44 September 20, 2023 08:28AM

Re: [PATCH 7 of 8] QUIC: cleaned up now unused ngx_quic_ciphers() calls

Sergey Kandaurov 39 October 13, 2023 11:16AM

[PATCH 8 of 8] QUIC: explicitly zero out unused keying material

Sergey Kandaurov 34 September 07, 2023 11:18AM

Re: [PATCH 8 of 8] QUIC: explicitly zero out unused keying material

Roman Arutyunyan 38 September 21, 2023 09:30AM

Re: [PATCH 8 of 8] QUIC: explicitly zero out unused keying material

Sergey Kandaurov 29 October 13, 2023 11:16AM

[PATCH 00 of 11] [quic] reusing crypto contexts, and more #2

Sergey Kandaurov 31 October 18, 2023 11:28AM

[PATCH 01 of 11] QUIC: split keys availability checks to read and write sides

Sergey Kandaurov 31 October 18, 2023 11:28AM

[PATCH 02 of 11] QUIC: added safety belt to prevent using discarded keys

Sergey Kandaurov 32 October 18, 2023 11:28AM

[PATCH 03 of 11] QUIC: prevented generating ACK frames with discarded keys

Sergey Kandaurov 32 October 18, 2023 11:28AM

[PATCH 04 of 11] QUIC: renamed protection functions

Sergey Kandaurov 30 October 18, 2023 11:28AM

[PATCH 05 of 11] QUIC: reusing crypto contexts for packet protection

Sergey Kandaurov 32 October 18, 2023 11:28AM

[PATCH 06 of 11] QUIC: common code for crypto open and seal operations

Sergey Kandaurov 29 October 18, 2023 11:28AM

[PATCH 07 of 11] QUIC: reusing crypto contexts for header protection

Sergey Kandaurov 32 October 18, 2023 11:30AM

[PATCH 08 of 11] QUIC: cleaned up now unused ngx_quic_ciphers() calls

Sergey Kandaurov 30 October 18, 2023 11:30AM

[PATCH 09 of 11] QUIC: simplified ngx_quic_ciphers() API

Sergey Kandaurov 28 October 18, 2023 11:30AM

[PATCH 10 of 11] QUIC: removed key field from ngx_quic_secret_t

Sergey Kandaurov 32 October 18, 2023 11:30AM

[PATCH 11 of 11] QUIC: explicitly zero out unused keying material

Sergey Kandaurov 30 October 18, 2023 11:38AM

Re: [PATCH 00 of 11] [quic] reusing crypto contexts, and more #2

Roman Arutyunyan 36 October 20, 2023 03:28AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 105
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready