[openssh-commits] [openssh] 01/02: upstream: Unit test for kex_proposal_populate_entries.

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Mar 7 17:32:23 AEDT 2023


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 03acc50d0ccb78fc91d1570de1cd0fdfea646028
Author: dtucker at openbsd.org <dtucker at openbsd.org>
Date:   Mon Mar 6 12:15:47 2023 +0000

    upstream: Unit test for kex_proposal_populate_entries.
    
    OpenBSD-Regress-ID: bdb211d80d572a08bf14b49fe2a58b9ff265c006
---
 regress/unittests/kex/test_proposal.c | 40 ++++++++++++++++++++++++++++++++++-
 regress/unittests/kex/tests.c         |  8 ++++---
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/regress/unittests/kex/test_proposal.c b/regress/unittests/kex/test_proposal.c
index d6cf0f5d..a5f92b54 100644
--- a/regress/unittests/kex/test_proposal.c
+++ b/regress/unittests/kex/test_proposal.c
@@ -1,4 +1,4 @@
-/* 	$OpenBSD: test_proposal.c,v 1.1 2023/02/02 12:12:52 djm Exp $ */
+/* 	$OpenBSD: test_proposal.c,v 1.2 2023/03/06 12:15:47 dtucker Exp $ */
 /*
  * Regress test KEX
  *
@@ -81,3 +81,41 @@ kex_proposal(void)
 	}
 	TEST_DONE();
 }
+
+void
+kex_proposal_populate_tests(void)
+{
+	char *prop[PROPOSAL_MAX], *kexalgs, *ciphers, *macs, *hkalgs;
+	const char *comp = compression_alg_list(0);
+	int i;
+	struct ssh ssh;
+	struct kex kex;
+
+	kexalgs = kex_alg_list(',');
+	ciphers = cipher_alg_list(',', 0);
+	macs = mac_alg_list(',');
+	hkalgs = kex_alg_list(',');
+
+	ssh.kex = &kex;
+	TEST_START("compat_kex_proposal_populate");
+	for (i = 0; i <= 1; i++) {
+		kex.server = i;
+		for (ssh.compat = 0; ssh.compat < 0x40000000; ) {
+			kex_proposal_populate_entries(&ssh, prop, NULL, NULL,
+			    NULL, NULL, NULL);
+			kex_proposal_free_entries(prop);
+			kex_proposal_populate_entries(&ssh, prop, kexalgs,
+			    ciphers, macs, hkalgs, comp);
+			kex_proposal_free_entries(prop);
+			if (ssh.compat == 0)
+				ssh.compat = 1;
+			else
+				ssh.compat <<= 1;
+		}
+	}
+
+	free(kexalgs);
+	free(ciphers);
+	free(macs);
+	free(hkalgs);
+}
diff --git a/regress/unittests/kex/tests.c b/regress/unittests/kex/tests.c
index 2a83dafb..d3044f03 100644
--- a/regress/unittests/kex/tests.c
+++ b/regress/unittests/kex/tests.c
@@ -1,4 +1,4 @@
-/* 	$OpenBSD: tests.c,v 1.2 2023/02/02 12:12:52 djm Exp $ */
+/* 	$OpenBSD: tests.c,v 1.3 2023/03/06 12:15:47 dtucker Exp $ */
 /*
  * Placed in the public domain
  */
@@ -6,11 +6,13 @@
 #include "../test_helper/test_helper.h"
 
 void kex_tests(void);
-void kex_proposal(void);
+void kex_proposal_tests(void);
+void kex_proposal_populate_tests(void);
 
 void
 tests(void)
 {
 	kex_tests();
-	kex_proposal();
+	kex_proposal_tests();
+	kex_proposal_populate_tests();
 }

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list