[Git][NTPsec/ntpsec][test_cookie] 3 commits: ntpd/refclock_jjy.c: Just remove tabs. Weird comments...

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Thu Aug 6 17:10:26 UTC 2026



Hal Murray pushed to branch test_cookie at NTPsec / ntpsec


Commits:
676d82c4 by Gary E. Miller at 2026-08-04T22:13:07-07:00
ntpd/refclock_jjy.c: Just remove tabs.  Weird comments...

- - - - -
de2709b8 by Gary E. Miller at 2026-08-06T10:10:22-07:00
tests/ntpd/nts_cookie.c: Remove tabs, Single line /* comments to //

No functional changes.

- - - - -
20bbe1e1 by Gary E. Miller at 2026-08-06T10:10:22-07:00
tests/ntpd/nts_cookie.c: restore previous comment indents

No functional changes.

- - - - -


2 changed files:

- ntpd/refclock_jjy.c
- tests/ntpd/nts_cookie.c


Changes:

=====================================
ntpd/refclock_jjy.c
=====================================
The diff for this file was not included because it is too large.

=====================================
tests/ntpd/nts_cookie.c
=====================================
@@ -22,99 +22,99 @@ TEST_SETUP(nts_cookie) {}
 TEST_TEAR_DOWN(nts_cookie) {}
 
 TEST(nts_cookie, nts_make_cookie_key) {
-	/* init */
-	struct NTS_Key k0 = {.K={1, 2, 3, 4, 5}, .I=123};
-	struct NTS_Key k1 = {.K={10, 20, 30, 40, 50}, .I=456};
-	/* copy to key variables */
-	nts_keys[0] = k0;
-	nts_keys[1] = k1;
-	/* run test */
-	nts_nKeys = 2;
-	nts_make_cookie_key();  /* push k0 to k1 */
-	/* check that K[1] now equals former-K[0] */
-	TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[1].K, k0.K, NTS_MAX_KEYLEN);
-	TEST_ASSERT_EQUAL(nts_keys[1].I, k0.I);
-	/* check that K[0] does not equal former-K[0] */
-	/* There is no "TEST UNEQUAL", do it manually */
-	bool equal = true;
-	for (unsigned int i = 0; i < NTS_MAX_KEYLEN; i++) {
-		if (nts_keys[0].K[i] != k0.K[i]) {
-			equal = false;
-			break;
-		}
-	}
-	TEST_ASSERT_EQUAL(false, equal);
-	/* Check that I[0] does not equal former-I[0] */
-	TEST_ASSERT_NOT_EQUAL(nts_keys[0].I, k0.I);
+        // init
+        struct NTS_Key k0 = {.K={1, 2, 3, 4, 5}, .I=123};
+        struct NTS_Key k1 = {.K={10, 20, 30, 40, 50}, .I=456};
+        // copy to key variables
+        nts_keys[0] = k0;
+        nts_keys[1] = k1;
+        // run test
+        nts_nKeys = 2;
+        nts_make_cookie_key();  // push k0 to k1
+        // check that K[1] now equals former-K[0]
+        TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[1].K, k0.K, NTS_MAX_KEYLEN);
+        TEST_ASSERT_EQUAL(nts_keys[1].I, k0.I);
+        // check that K[0] does not equal former-K[0]
+        // There is no "TEST UNEQUAL", do it manually
+        bool equal = true;
+        for (unsigned int i = 0; i < NTS_MAX_KEYLEN; i++) {
+                if (nts_keys[0].K[i] != k0.K[i]) {
+                        equal = false;
+                        break;
+                }
+        }
+        TEST_ASSERT_EQUAL(false, equal);
+        // Check that I[0] does not equal former-I[0]
+        TEST_ASSERT_NOT_EQUAL(nts_keys[0].I, k0.I);
 }
 
 TEST(nts_cookie, nts_make_unpack_cookie) {
-	/* init */
-	uint8_t cookie[NTS_MAX_COOKIELEN];
-	/* Using 16 bytes in test for ease of handling */
-	uint8_t c2s[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
-	uint8_t s2c[16] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
-	uint8_t c2s_2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-	uint8_t s2c_2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-	int len;
-	int keylen;
-	bool ok;
-	uint16_t aead; /* retrieved on unpack */
-	/* Init for cookie_ctx */
-	nts_cookie_init();
-	nts_nKeys = 0;
-	nts_make_cookie_key();
-	/* Test */
-	len = nts_make_cookie(cookie, AEAD_AES_SIV_CMAC_256, c2s, s2c, sizeof(c2s));
-	TEST_ASSERT_EQUAL(72, len);
-	/* Very limited in what data can be directly checked here */
-	/* Reverse the test */
-	ok = nts_unpack_cookie(cookie, len, &aead, c2s_2, s2c_2, &keylen);
-	TEST_ASSERT_EQUAL(true, ok);
-	TEST_ASSERT_EQUAL(AEAD_AES_SIV_CMAC_256, aead);
-	TEST_ASSERT_EQUAL(16, keylen);
-	TEST_ASSERT_EQUAL_UINT8_ARRAY(c2s, c2s_2, 16);
-	TEST_ASSERT_EQUAL_UINT8_ARRAY(s2c, s2c_2, 16);
+        // init
+        uint8_t cookie[NTS_MAX_COOKIELEN];
+        // Using 16 bytes in test for ease of handling
+        uint8_t c2s[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+        uint8_t s2c[16] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+        uint8_t c2s_2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        uint8_t s2c_2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        int len;
+        int keylen;
+        bool ok;
+        uint16_t aead;  // retrieved on unpack
+        // Init for cookie_ctx
+        nts_cookie_init();
+        nts_nKeys = 0;
+        nts_make_cookie_key();
+        // Test
+        len = nts_make_cookie(cookie, AEAD_AES_SIV_CMAC_256, c2s, s2c, sizeof(c2s));
+        TEST_ASSERT_EQUAL(72, len);
+        // Very limited in what data can be directly checked here
+        // Reverse the test
+        ok = nts_unpack_cookie(cookie, len, &aead, c2s_2, s2c_2, &keylen);
+        TEST_ASSERT_EQUAL(true, ok);
+        TEST_ASSERT_EQUAL(AEAD_AES_SIV_CMAC_256, aead);
+        TEST_ASSERT_EQUAL(16, keylen);
+        TEST_ASSERT_EQUAL_UINT8_ARRAY(c2s, c2s_2, 16);
+        TEST_ASSERT_EQUAL_UINT8_ARRAY(s2c, s2c_2, 16);
 }
 
 const char *cookie_file_name = "test-cookie-keys";
 
 TEST(nts_cookie, nts_read_write_cookies) {
-	struct NTS_Key k0, k1, k2;
-	bool ok;
-	ntsconfig.KI = cookie_file_name;
-	nts_nKeys = 0;
-	nts_make_cookie_key();
-	nts_make_cookie_key();
-	nts_make_cookie_key();
-	k0 = nts_keys[0];
-	k1 = nts_keys[1];
-	k2 = nts_keys[2];
-	TEST_ASSERT_EQUAL(nts_nKeys, 3);
-	ok = nts_write_cookie_keys();
-	TEST_ASSERT_EQUAL(true, ok);
-	nts_make_cookie_key();    /* scramble things */
-	ZERO(nts_keys);
-	nts_nKeys = 377;
-	ok = nts_read_cookie_keys();
-	TEST_ASSERT_EQUAL(true, ok);
-	TEST_ASSERT_EQUAL(nts_nKeys, 3);
-	TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[0].K, k0.K, NTS_MAX_KEYLEN);
-	TEST_ASSERT_EQUAL(nts_keys[0].I, k0.I);
-	TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[1].K, k1.K, NTS_MAX_KEYLEN);
-	TEST_ASSERT_EQUAL(nts_keys[1].I, k1.I);
-	TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[2].K, k2.K, NTS_MAX_KEYLEN);
-	TEST_ASSERT_EQUAL(nts_keys[2].I, k2.I);
+        struct NTS_Key k0, k1, k2;
+        bool ok;
+        ntsconfig.KI = cookie_file_name;
+        nts_nKeys = 0;
+        nts_make_cookie_key();
+        nts_make_cookie_key();
+        nts_make_cookie_key();
+        k0 = nts_keys[0];
+        k1 = nts_keys[1];
+        k2 = nts_keys[2];
+        TEST_ASSERT_EQUAL(nts_nKeys, 3);
+        ok = nts_write_cookie_keys();
+        TEST_ASSERT_EQUAL(true, ok);
+        nts_make_cookie_key();    // scramble things
+        ZERO(nts_keys);
+        nts_nKeys = 377;
+        ok = nts_read_cookie_keys();
+        TEST_ASSERT_EQUAL(true, ok);
+        TEST_ASSERT_EQUAL(nts_nKeys, 3);
+        TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[0].K, k0.K, NTS_MAX_KEYLEN);
+        TEST_ASSERT_EQUAL(nts_keys[0].I, k0.I);
+        TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[1].K, k1.K, NTS_MAX_KEYLEN);
+        TEST_ASSERT_EQUAL(nts_keys[1].I, k1.I);
+        TEST_ASSERT_EQUAL_UINT8_ARRAY(nts_keys[2].K, k2.K, NTS_MAX_KEYLEN);
+        TEST_ASSERT_EQUAL(nts_keys[2].I, k2.I);
 }
 
 TEST_GROUP_RUNNER(nts_cookie) {
-	RUN_TEST_CASE(nts_cookie, nts_make_unpack_cookie);
-	RUN_TEST_CASE(nts_cookie, nts_make_cookie_key);
-	RUN_TEST_CASE(nts_cookie, nts_read_write_cookies);
-	/* This test gets run as root during install
-	 * that leaves the cookie file that we can't read/write
-	 * so clean it up now.
-	 * If we crash, we don't get here so the evidence is still
-	 * left around in case it helps debugging.  */
-	unlink(cookie_file_name);
+        RUN_TEST_CASE(nts_cookie, nts_make_unpack_cookie);
+        RUN_TEST_CASE(nts_cookie, nts_make_cookie_key);
+        RUN_TEST_CASE(nts_cookie, nts_read_write_cookies);
+        /* This test gets run as root during install
+         * that leaves the cookie file that we can't read/write
+         * so clean it up now.
+         * If we crash, we don't get here so the evidence is still
+         * left around in case it helps debugging.  */
+        unlink(cookie_file_name);
 }



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/7ab47ab822a8319619867b09e4c167f6be41c093...20bbe1e186d990e02899f954e950061b53a40479

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/7ab47ab822a8319619867b09e4c167f6be41c093...20bbe1e186d990e02899f954e950061b53a40479
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20260806/361a0f82/attachment-0001.htm>


More information about the vc mailing list