From: "plaisthos (Code Review)" Date: Fri, 22 Nov 2024 16:29:27 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="XCHrnby7wOk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: [TEST-ONLY] Mess with internal logic to test epoch data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --XCHrnby7wOk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/818?usp=3Demail to review the following change. Change subject: [TEST-ONLY] Mess with internal logic to test epoch data ...................................................................... [TEST-ONLY] Mess with internal logic to test epoch data This rotates/invalidates keys extremely quickly and also jumps forward 1-8 keys instead of always one to test that part of the logic. Change-Id: I7cdf992eb6031315c4978c6a1fbbecfa723fca91 Signed-off-by: Arne Schwabe --- M src/openvpn/crypto.c M src/openvpn/crypto_epoch.c M tests/unit_tests/openvpn/test_ssl.c 3 files changed, 18 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/818/1 diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 9166707..e990d80 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -352,6 +352,9 @@ int64_t cipher_get_aead_limits(const char *ciphername) { + /* TESTING: Make AEAD key limits really really really small to force + * key rollever super quickly */ + return 256; if (!cipher_kt_mode_aead(ciphername)) { return 0; diff --git a/src/openvpn/crypto_epoch.c b/src/openvpn/crypto_epoch.c index 4a9a338..3df56ba 100644 --- a/src/openvpn/crypto_epoch.c +++ b/src/openvpn/crypto_epoch.c @@ -413,8 +413,13 @@ if (aead_usage_limit_reached(opt->aead_usage_limit, &opt->key_ctx_= bi.encrypt, opt->packet_id.send.id)) { - /* Send key limit reached */ - epoch_iterate_send_key(opt); + int forward =3D rand() % 8 + 1; + /* Send key limit reached, go one key forward or in this TEST + * gremlin mode, 1 to 8 to test the other side future key stuf= f */ + for (int i =3D 0; i < forward; i++) + { + epoch_iterate_send_key(opt); + } } /* draft 8 of the aead usage limit still had but draft 9 complete * dropped this statement: @@ -436,7 +441,13 @@ /* Receive key limit reached. Increase our own send key to sig= nal * that we want to use a new epoch. Peer should then also move= its * key but is not required to do this */ - epoch_iterate_send_key(opt); + int forward =3D rand() % 8 + 1; + /* gremlin mode, 1 to 8 to test the other side future key stuf= f */ + for (int i =3D 0; i < forward; i++) + { + epoch_iterate_send_key(opt); + } + } } diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn= /test_ssl.c index 842c944..0d4d8be 100644 --- a/tests/unit_tests/openvpn/test_ssl.c +++ b/tests/unit_tests/openvpn/test_ssl.c @@ -398,7 +398,7 @@ struct epoch_key e1 =3D { .epoch =3D 1, .epoch_key =3D { 0 }}; memcpy(e1.epoch_key, key2.keys[0].cipher, sizeof(e1.epoch_key)); co.flags |=3D CO_EPOCH_DATA_KEY_FORMAT; - epoch_init_key_ctx(&co, &kt, &e1, &e1, 5); + epoch_init_key_ctx(&co, &kt, &e1, &e1, 9); /* Do a little of dancing for the epoch_send_key_iterate to test * that this works too */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/818?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I7cdf992eb6031315c4978c6a1fbbecfa723fca91 Gerrit-Change-Number: 818 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --XCHrnby7wOk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

[TEST-ONLY] Mess with internal logic to test epoch data
This rotates/invalidates keys extremely quickly and also jumps forward1-8 keys instead of always one to test that part of the logic.

Chan= ge-Id: I7cdf992eb6031315c4978c6a1fbbecfa723fca91
Signed-off-by: Arne Sch= wabe <arne@...1227...>
---
M src/openvpn/crypto.c
M src/open= vpn/crypto_epoch.c
M tests/unit_tests/openvpn/test_ssl.c
3 files chan= ged, 18 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openv=
pn.net:29418/openvpn refs/changes/18/818/1
diff --git a/src/openvpn=
/crypto.c b/src/openvpn/crypto.c
index 9166707..e990d80 100= 644
--- a/src/openvpn/crypto.c
+++ b/src/op= envpn/crypto.c
@@ -352,6 +352,9 @@
int64_t=
cipher_get_aead_limits(const char *ciphername)
= {
+ /* TEST= ING: Make AEAD key limits really really really small to force
+ * key rollever super quickly= */
+ return 256;<= /span>
if (!cipher_kt_mode_aead(ciphername))
= {
return 0;
diff --git a/src/= openvpn/crypto_epoch.c b/src/openvpn/crypto_epoch.c
index 4= a9a338..3df56ba 100644
--- a/src/openvpn/crypto_epoch.c

+++ b/src/openvpn/crypto_epoch.c
@@ -413,8 +41= 3,13 @@
if (aead_usage_limit_reached(opt->aead_= usage_limit, &opt->key_ctx_bi.encrypt,
= opt->packet_id.send.id))
= {
- /* Se= nd key limit reached */
- epoch_iterate_send_key(opt);
+ int forward =3D rand() % 8 + 1;+ /* Send key limi= t reached, go one key forward or in this TEST
+ * gremlin mode, 1 to 8 to test the o= ther side future key stuff */
+ for (int i =3D 0; i < forward; i++)
+ {
+ epoch_iterate_send_key(o= pt);
+ }
}
/* draft 8 of the aead u= sage limit still had but draft 9 complete
* dropp= ed this statement:
@@ -436,7 +441,13 @@
= /* Receive key limit reached. Increase our own send key to signal=
* that we want to use a new epoch. Peer shou= ld then also move its
* key but is not requir= ed to do this */
- = epoch_iterate_send_key(opt);
+ int forward =3D rand() % 8 + 1;
+ /* gremlin mode, 1 to 8= to test the other side future key stuff */

+ for (int i =3D 0; i < forward; i++)<= /span>
+ {=
+ epoch_iter= ate_send_key(opt);
+ = }
+=
}
}

diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/open= vpn/test_ssl.c

index 842c944..0d4d8be 100644
--- a/tests/unit_tests/openvpn/test_ssl.c
+++ b/tests/uni= t_tests/openvpn/test_ssl.c
@@ -398,7 +398,7 @@
struct epoch_key e1 =3D { .epoch =3D 1, .epoch_key =3D { 0 }};=
memcpy(e1.epoch_key, key2.keys[0].cipher, sizeof(= e1.epoch_key));
co.flags |=3D CO_EPOCH_DATA_KEY_FO= RMAT;
- epoch_in= it_key_ctx(&co, &kt, &e1, &e1, 5);
+ epoch_init_key_ctx(&co, &kt,= &e1, &e1, 9);

/* Do a l= ittle of dancing for the epoch_send_key_iterate to test
= * that this works too */

To view= , visit c= hange 818. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cdf992eb6031315c4978c6a1fb= becfa723fca91
Gerrit-Change-Number: 818
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--XCHrnby7wOk=--