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

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



Hal Murray pushed to branch scanner 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...

- - - - -
b2ca71a7 by Gary E. Miller at 2026-08-06T10:14:33-07:00
ntpd/nts_server.c: Remove tabs, Single line /* comments to //

- - - - -
4d7554c9 by Gary E. Miller at 2026-08-06T10:15:46-07:00
attic/aes-siv-timing.c: Remove tabs, Single line /* comments to //

No functional changes.

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

No functional changes.

- - - - -
2255add0 by Gary E. Miller at 2026-08-06T10:16:50-07:00
tests/ntpd/nts_cookie.c: restore previous comment indents

No functional changes.

- - - - -
e69a219e by Gary E. Miller at 2026-08-06T10:17:37-07:00
tests/ntpd/nts.c: Remove tabs, Single line /* comments to //

No functional changes.

- - - - -
d9279df1 by Gary E. Miller at 2026-08-06T10:22:00-07:00
include/nts.h: Remove tabs, Single line /* comments to //

- - - - -
98e2af01 by Gary E. Miller at 2026-08-06T10:29:38-07:00
ntpd/ntp_scanner.c: Remove tabs, Single line /* comments to //

No functional changes.

- - - - -


7 changed files:

- attic/aes-siv-timing.c
- include/nts.h
- ntpd/ntp_scanner.c
- ntpd/nts_server.c
- ntpd/refclock_jjy.c
- tests/ntpd/nts.c
- tests/ntpd/nts_cookie.c


Changes:

=====================================
attic/aes-siv-timing.c
=====================================
@@ -4,7 +4,7 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-/* Last modified on Sat Aug 28 14:30:11 PDT 1999 by murray */
+// Last modified on Sat Aug 28 14:30:11 PDT 1999 by murray
 
 /*
  * Hack to time aead routines from libaes_siv
@@ -44,7 +44,7 @@ int     key_K_length;
 pthread_mutex_t cookie_lock = PTHREAD_MUTEX_INITIALIZER;
 
 
-/* sizeof(key_I) + sizeof(NONCE) */
+// sizeof(key_I) + sizeof(NONCE)
 #define AD_LENGTH 20
 
 static void ssl_init(void)
@@ -85,44 +85,44 @@ static void ntp_RAND_bytes(unsigned char *buf, int num) {
 
 static void DoLock(void)
 {
-	struct timespec start, stop;
-	double fast;
-	int samplesize = SAMPLESIZE;
+        struct timespec start, stop;
+        double fast;
+        int samplesize = SAMPLESIZE;
 
-	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < samplesize; i++) {
+        clock_gettime(CLOCK_MONOTONIC, &start);
+        for (int i = 0; i < samplesize; i++) {
           nts_lock_cookielock();
           nts_unlock_cookielock();
-	}
-	clock_gettime(CLOCK_MONOTONIC, &stop);
-	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
-	printf("LocK          %6.0f %7.3f",
-	       fast/samplesize,  fast/1E9);
-	printf("\n");
+        }
+        clock_gettime(CLOCK_MONOTONIC, &stop);
+        fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
+        printf("LocK          %6.0f %7.3f",
+               fast/samplesize,  fast/1E9);
+        printf("\n");
 }
 
 
 static void DoNonce(void)
 {
         uint8_t nonce[NONCE_LENGTH];
-	struct timespec start, stop;
-	double fast;
-	int samplesize = SAMPLESIZE;
+        struct timespec start, stop;
+        double fast;
+        int samplesize = SAMPLESIZE;
 
-	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < samplesize; i++) {
+        clock_gettime(CLOCK_MONOTONIC, &start);
+        for (int i = 0; i < samplesize; i++) {
           ntp_RAND_bytes(nonce, NONCE_LENGTH);
-	}
-	clock_gettime(CLOCK_MONOTONIC, &stop);
-	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
-	printf("Nonce     %3d %6.0f %7.3f",
-	       NONCE_LENGTH, fast/samplesize,  fast/1E9);
-	printf("\n");
+        }
+        clock_gettime(CLOCK_MONOTONIC, &stop);
+        fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
+        printf("Nonce     %3d %6.0f %7.3f",
+               NONCE_LENGTH, fast/samplesize,  fast/1E9);
+        printf("\n");
 }
 
 
-/* Clone of nts_make_cookie() from ntpd/nts_cookie.c */
-/* returns actual length */
+// Clone of nts_make_cookie() from ntpd/nts_cookie.c
+// returns actual length
 int nts_make_cookie(uint8_t *cookie,
   uint16_t aead,
   uint8_t *c2s, uint8_t *s2c, int keylen) {
@@ -131,11 +131,11 @@ int nts_make_cookie(uint8_t *cookie,
         int used, plainlength;
         bool ok;
         uint8_t * finger;
-        uint32_t temp;  /* keep 4 byte alignment */
+        uint32_t temp;  // keep 4 byte alignment
         size_t left;
 
         if (NULL == cookie_ctx)
-                return 0;               /* We aren't initialized yet. */
+                return 0;               // We aren't initialized yet.
 
 //        nts_cookie_make++;
 
@@ -151,7 +151,7 @@ int nts_make_cookie(uint8_t *cookie,
         finger += keylen;
         plainlength = finger-plaintext;
 
-        /* collect associated data */
+        // collect associated data
         finger = cookie;
 
         memcpy(finger, &key_I, sizeof(key_I));
@@ -166,7 +166,7 @@ int nts_make_cookie(uint8_t *cookie,
 
         nts_lock_cookielock();
         ok = AES_SIV_Encrypt(cookie_ctx,
-                             finger, &left,   /* left: in: max out length, out: length used */
+                             finger, &left,   // left: in: max out length, out: length used
                              key_K, key_K_length,
                              nonce, NONCE_LENGTH,
                              plaintext, plainlength,
@@ -186,84 +186,84 @@ int nts_make_cookie(uint8_t *cookie,
 
 
 static void DoMakeCookie(
-  const char *name,       /* name of aead */
-  int     aead,		  /* algorithm used to make cookie */
-  int     keylength       /* length of c2s and s2c */
+  const char *name,       // name of aead
+  int     aead,           // algorithm used to make cookie
+  int     keylength       // length of c2s and s2c
 )
 {
-	uint8_t cookie[NTS_MAX_COOKIELEN];
-	uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
-	struct timespec start, stop;
-	double fast;
-	int cookielength = 0;
-	int samplesize = SAMPLESIZE;
-
-	switch (aead) {
-	  case AEAD_AES_SIV_CMAC_256:
-		key_K_length = AEAD_AES_SIV_CMAC_256_KEYLEN;
-		break;
-	  case AEAD_AES_SIV_CMAC_384:
-		key_K_length = AEAD_AES_SIV_CMAC_384_KEYLEN;
-		break;
-	  case AEAD_AES_SIV_CMAC_512:
-		key_K_length = AEAD_AES_SIV_CMAC_512_KEYLEN;
-		break;
-	  default:
-		printf("Bogus aead\n");
-		exit(1);
-	}
+        uint8_t cookie[NTS_MAX_COOKIELEN];
+        uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
+        struct timespec start, stop;
+        double fast;
+        int cookielength = 0;
+        int samplesize = SAMPLESIZE;
+
+        switch (aead) {
+          case AEAD_AES_SIV_CMAC_256:
+                key_K_length = AEAD_AES_SIV_CMAC_256_KEYLEN;
+                break;
+          case AEAD_AES_SIV_CMAC_384:
+                key_K_length = AEAD_AES_SIV_CMAC_384_KEYLEN;
+                break;
+          case AEAD_AES_SIV_CMAC_512:
+                key_K_length = AEAD_AES_SIV_CMAC_512_KEYLEN;
+                break;
+          default:
+                printf("Bogus aead\n");
+                exit(1);
+        }
 
         ntp_RAND_bytes(c2s, NTS_MAX_KEYLEN);
         ntp_RAND_bytes(s2c, NTS_MAX_KEYLEN);
 
-	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < samplesize; i++) {
-		cookielength = nts_make_cookie(
-			cookie, aead, c2s, s2c, keylength);
-	}
-	clock_gettime(CLOCK_MONOTONIC, &stop);
-	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
-	printf("%12s  %2d %4d %6.0f %7.3f",
-	       name, keylength, cookielength, fast/samplesize,  fast/1E9);
-	printf("\n");
+        clock_gettime(CLOCK_MONOTONIC, &start);
+        for (int i = 0; i < samplesize; i++) {
+                cookielength = nts_make_cookie(
+                        cookie, aead, c2s, s2c, keylength);
+        }
+        clock_gettime(CLOCK_MONOTONIC, &stop);
+        fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
+        printf("%12s  %2d %4d %6.0f %7.3f",
+               name, keylength, cookielength, fast/samplesize,  fast/1E9);
+        printf("\n");
 }
 
 
 static void DoMakeCrypto(
-  const char *name,       /* name of aead */
-  int     aead,		  /* algorithm used to make cookie */
-  int     keylen          /* length of c2s and s2c */
+  const char *name,       // name of aead
+  int     aead,           // algorithm used to make cookie
+  int     keylen          // length of c2s and s2c
 )
 {
-	uint8_t cookie[NTS_MAX_COOKIELEN];
-	uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
-	struct timespec start, stop;
-	double fast;
-	int cookielength = 0;
-	int samplesize = SAMPLESIZE;
+        uint8_t cookie[NTS_MAX_COOKIELEN];
+        uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
+        struct timespec start, stop;
+        double fast;
+        int cookielength = 0;
+        int samplesize = SAMPLESIZE;
 
         uint8_t plaintext[NTS_MAX_COOKIELEN];
         uint8_t *nonce;
         int used, plainlength;
         int ok = 0;
         uint8_t * finger;
-        uint32_t temp;  /* keep 4 byte alignment */
+        uint32_t temp;  // keep 4 byte alignment
         size_t left;
 
-	switch (aead) {
-	  case AEAD_AES_SIV_CMAC_256:
-		key_K_length = AEAD_AES_SIV_CMAC_256_KEYLEN;
-		break;
-	  case AEAD_AES_SIV_CMAC_384:
-		key_K_length = AEAD_AES_SIV_CMAC_384_KEYLEN;
-		break;
-	  case AEAD_AES_SIV_CMAC_512:
-		key_K_length = AEAD_AES_SIV_CMAC_512_KEYLEN;
-		break;
-	  default:
-		printf("Bogus aead\n");
-		exit(1);
-	}
+        switch (aead) {
+          case AEAD_AES_SIV_CMAC_256:
+                key_K_length = AEAD_AES_SIV_CMAC_256_KEYLEN;
+                break;
+          case AEAD_AES_SIV_CMAC_384:
+                key_K_length = AEAD_AES_SIV_CMAC_384_KEYLEN;
+                break;
+          case AEAD_AES_SIV_CMAC_512:
+                key_K_length = AEAD_AES_SIV_CMAC_512_KEYLEN;
+                break;
+          default:
+                printf("Bogus aead\n");
+                exit(1);
+        }
 
         ntp_RAND_bytes(c2s, NTS_MAX_KEYLEN);
         ntp_RAND_bytes(s2c, NTS_MAX_KEYLEN);
@@ -278,7 +278,7 @@ static void DoMakeCrypto(
         finger += keylen;
         plainlength = finger-plaintext;
 
-        /* collect associated data */
+        // collect associated data
         finger = cookie;
 
         memcpy(finger, &key_I, sizeof(key_I));
@@ -291,16 +291,16 @@ static void DoMakeCrypto(
         used = finger-cookie;
         left = NTS_MAX_COOKIELEN-used;
 
-	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < samplesize; i++) {
+        clock_gettime(CLOCK_MONOTONIC, &start);
+        for (int i = 0; i < samplesize; i++) {
           ok += AES_SIV_Encrypt(cookie_ctx,
-             finger, &left,   /* left: in: max out length, out: length used */
+             finger, &left,   // left: in: max out length, out: length used
              key_K, key_K_length,
              nonce, NONCE_LENGTH,
              plaintext, plainlength,
              cookie, AD_LENGTH);
-	}
-	clock_gettime(CLOCK_MONOTONIC, &stop);
+        }
+        clock_gettime(CLOCK_MONOTONIC, &stop);
 
         if (samplesize != ok) {
                 printf("NTS: nts_make_cookie - Error from AES_SIV_Encrypt\n");
@@ -310,69 +310,69 @@ static void DoMakeCrypto(
         used += left;
         INSIST(used <= NTS_MAX_COOKIELEN);
 
-	cookielength = used;
+        cookielength = used;
 
-	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
-	printf("%12s  %2d %4d %6.0f %7.3f",
-	       name, keylen, cookielength, fast/samplesize,  fast/1E9);
-	printf("\n");
+        fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
+        printf("%12s  %2d %4d %6.0f %7.3f",
+               name, keylen, cookielength, fast/samplesize,  fast/1E9);
+        printf("\n");
 }
 
 int main(int argc, char *argv[])
 {
-	char *ctimetxt;
-	time_t now;
-	char buff[256];
+        char *ctimetxt;
+        time_t now;
+        char buff[256];
 
-	UNUSED_ARG(argc);
-	UNUSED_ARG(argv);
+        UNUSED_ARG(argc);
+        UNUSED_ARG(argv);
 
-	setlinebuf(stdout);
+        setlinebuf(stdout);
 
-	ssl_init();
+        ssl_init();
 
         ntp_RAND_bytes(key_K, NTS_MAX_KEYLEN);
 
-	now = time(NULL);
-	ctimetxt = ctime(&now);
-	ctimetxt[24] = 0;	/* Hack: smash return */
-	gethostname(buff, sizeof(buff));
-	printf("# %s on %s\n", ctimetxt, buff);
-	printf("# %s\n", OPENSSL_VERSION_TEXT);
+        now = time(NULL);
+        ctimetxt = ctime(&now);
+        ctimetxt[24] = 0;       // Hack: smash return
+        gethostname(buff, sizeof(buff));
+        printf("# %s on %s\n", ctimetxt, buff);
+        printf("# %s\n", OPENSSL_VERSION_TEXT);
 
-	printf("\n");
-	printf("#       bytes  ns/op sec/run\n");
-	DoLock();
-	DoNonce();
+        printf("\n");
+        printf("#       bytes  ns/op sec/run\n");
+        DoLock();
+        DoNonce();
 
-	printf("\n");
-	printf("# wKL=sizeof(c2s), CL=sizeof(cookie)\n");
-	printf("# Make cookie    wKL   CL  ns/op sec/run\n");
+        printf("\n");
+        printf("# wKL=sizeof(c2s), CL=sizeof(cookie)\n");
+        printf("# Make cookie    wKL   CL  ns/op sec/run\n");
 
 // Sample numbers using old cmac.h
 // run on a Dell 9020/MT with Intel i7-4790 @ 3.60GHz
-	/* 3rd arg is length of c2s and s2c */
-	DoMakeCookie("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 32);
-	DoMakeCookie("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 48);
-	DoMakeCookie("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 64);
+        // 3rd arg is length of c2s and s2c
+        DoMakeCookie("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 32);
+        DoMakeCookie("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 48);
+        DoMakeCookie("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 64);
 // AES_SIV_CMAC_256  32  104   3127   3.127
 // AES_SIV_CMAC_256  48  136   3186   3.186
 // AES_SIV_CMAC_256  64  168   3220   3.220
-	DoMakeCookie("AES_SIV_CMAC_512", AEAD_AES_SIV_CMAC_512, 32);
-	DoMakeCookie("AES_SIV_CMAC_512", AEAD_AES_SIV_CMAC_512, 48);
-	DoMakeCookie("AES_SIV_CMAC_512", AEAD_AES_SIV_CMAC_512, 64);
+        DoMakeCookie("AES_SIV_CMAC_512", AEAD_AES_SIV_CMAC_512, 32);
+        DoMakeCookie("AES_SIV_CMAC_512", AEAD_AES_SIV_CMAC_512, 48);
+        DoMakeCookie("AES_SIV_CMAC_512", AEAD_AES_SIV_CMAC_512, 64);
 // AES_SIV_CMAC_512  32  104   3183   3.183
 // AES_SIV_CMAC_512  48  136   3247   3.247
 // AES_SIV_CMAC_512  64  168   3303   3.303
-	printf("\n");
+        printf("\n");
 
-	printf("# Cookie Crypto  wKL   CL  ns/op sec/run\n");
-	DoMakeCrypto("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 32);
-	DoMakeCrypto("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 48);
-	DoMakeCrypto("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 64);
+        printf("# Cookie Crypto  wKL   CL  ns/op sec/run\n");
+        DoMakeCrypto("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 32);
+        DoMakeCrypto("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 48);
+        DoMakeCrypto("AES_SIV_CMAC_256", AEAD_AES_SIV_CMAC_256, 64);
 // AES_SIV_CMAC_256  32  104   2066   2.066
 // AES_SIV_CMAC_256  48  136   2119   2.119
 // AES_SIV_CMAC_256  64  168   2157   2.157
 
-	return 0;
+        return 0;
 }


=====================================
include/nts.h
=====================================
@@ -12,20 +12,20 @@
 
 #include "ntp_fp.h"
 
-/* default file names */
+// default file names
 #define NTS_CERT_FILE "/etc/ntp/cert-chain.pem"
 #define NTS_KEY_FILE "/etc/ntp/key.pem"
 #define NTS_COOKIE_KEY_FILE "/var/lib/ntp/nts-keys"
 
-#define NTS_KE_PORT		4460
-#define NTS_KE_PORTA		"4460"
+#define NTS_KE_PORT             4460
+#define NTS_KE_PORTA            "4460"
 
-#define NTS_KE_TIMEOUT		3
+#define NTS_KE_TIMEOUT          3
 
 bool nts_server_init(void);
 bool nts_client_init(void);
 bool nts_cookie_init(void);
-bool nts_server_init2(void);    /* after sandbox */
+bool nts_server_init2(void);    // after sandbox
 bool nts_cookie_init2(void);
 
 void nts_cert_timer(void);
@@ -42,18 +42,18 @@ bool nts_unpack_cookie(uint8_t *cookie, int cookielen,
   uint16_t *aead,
   uint8_t *c2s, uint8_t *s2c, int *keylen);
 
-/* working finger into a buffer - updated by append/unpack routines */
+// working finger into a buffer - updated by append/unpack routines
 struct BufCtl_t {
-    uint8_t *next;  /* pointer to next data/space */
-    int left;       /* data left or space available */
+    uint8_t *next;  // pointer to next data/space
+    int left;       // data left or space available
 };
 typedef struct BufCtl_t BufCtl;
 
-/* Here for test routines */
+// Here for test routines
 bool nts_ke_process_receive(struct BufCtl_t *buf, int *aead,
   char *errbuf, int errlng, const char **errtxt);
 
-/***********************************************************/
+// *********************************************************
 
 /* buffer packing/unpacking routines.
  * NB: The length field in NTP extensions includes the header
@@ -67,12 +67,12 @@ bool nts_ke_process_receive(struct BufCtl_t *buf, int *aead,
  */
 
 
-/* 2 byte type, 2 byte length */
+// 2 byte type, 2 byte length
 #define NTS_KE_HDR_LNG 4
 #define NTS_KE_U16_LNG 2
 
-/* xxx_append_record_foo makes whole record with one foo */
-/* append_foo appends foo to existing partial record */
+// xxx_append_record_foo makes whole record with one foo
+// append_foo appends foo to existing partial record
 void ke_append_record_null(BufCtl* buf, uint16_t type);
 void ke_append_record_uint16(BufCtl* buf, uint16_t type, uint16_t data);
 void ke_append_record_bytes(BufCtl* buf, uint16_t type, uint8_t *data, int length);
@@ -87,19 +87,19 @@ void append_uint16(BufCtl* buf, uint16_t data);
 void append_bytes(BufCtl* buf, uint8_t *data, int length);
 
 uint16_t ke_next_record(BufCtl* buf, int *length);
-uint16_t ex_next_record(BufCtl* buf, int *length);  /* body length */
+uint16_t ex_next_record(BufCtl* buf, int *length);  // body length
 uint16_t next_uint16(BufCtl* buf);
 uint16_t next_bytes(BufCtl* buf, uint8_t *data, int length);
 
-/***********************************************************/
+// *********************************************************
 
-#define NTS_MAX_KEYLEN		64	/* used in cookies */
-#define NTS_MAX_COOKIELEN	192	/* see nts_cookie.c */
-#define NTS_MAX_COOKIES		8	/* RFC 4.1.6 */
-#define NTS_UID_LENGTH		32	/* RFC 5.3 */
-#define NTS_UID_MAX_LENGTH	64
+#define NTS_MAX_KEYLEN          64      // used in cookies
+#define NTS_MAX_COOKIELEN       192     // see nts_cookie.c
+#define NTS_MAX_COOKIES         8       // RFC 4.1.6
+#define NTS_UID_LENGTH          32      // RFC 5.3
+#define NTS_UID_MAX_LENGTH      64
 
-/* Here for tester */
+// Here for tester
 struct NTS_Key {
   uint8_t K[NTS_MAX_KEYLEN];
   uint32_t I;
@@ -108,87 +108,87 @@ struct NTS_Key {
   #define NTS_nKEYS 10
 #endif
 extern struct NTS_Key nts_keys[NTS_nKEYS];
-extern int nts_nKeys;		/* for tester */
+extern int nts_nKeys;           // for tester
 
 
 /* Client side configuration data for an NTS association
  * All are optional.
  * part of peer struct */
 struct ntscfg_t {
-	char *ca;		/* root/trusted certificates */
-	char *aead;		/* AEAD algorithms on wire */
+        char *ca;               // root/trusted certificates
+        char *aead;             // AEAD algorithms on wire
 };
 
-/* Client-side state per connection to server */
+// Client-side state per connection to server
 struct ntsclient_t {
-	/* wire connection */
-	uint16_t aead;	/* AEAD algorithm used on wire */
-	int keylen;
-	uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
-	/* UID of last request sent - RFC 5.3 */
-	uint8_t UID[NTS_UID_LENGTH];
-	/* cookies */
-	int readIdx, writeIdx;
-	int count;			/* -1 if not in NTS mode */
-	int cookielen;
-	uint8_t cookies[NTS_MAX_COOKIES][NTS_MAX_COOKIELEN];
+        // wire connection
+        uint16_t aead;  // AEAD algorithm used on wire
+        int keylen;
+        uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
+        // UID of last request sent - RFC 5.3
+        uint8_t UID[NTS_UID_LENGTH];
+        // cookies
+        int readIdx, writeIdx;
+        int count;                      // -1 if not in NTS mode
+        int cookielen;
+        uint8_t cookies[NTS_MAX_COOKIES][NTS_MAX_COOKIELEN];
 };
 
-/* Server-side state per packet */
+// Server-side state per packet
 struct ntspacket_t {
-	bool valid;
-	int uidlen;
-	uint8_t UID[NTS_UID_MAX_LENGTH];
-	int needed;
-	uint16_t aead;
-	int keylen;
-	uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
+        bool valid;
+        int uidlen;
+        uint8_t UID[NTS_UID_MAX_LENGTH];
+        int needed;
+        uint16_t aead;
+        int keylen;
+        uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
 };
 
 
-/* Configuration data for an NTS server or client instance */
+// Configuration data for an NTS server or client instance
 struct ntsconfig_t {
-	bool ntsenable; 	/* enable NTS KE server on this ntpd */
-	const char * mintls;	/* minimum TLS version allowed */
-	const char * maxtls;	/* maximum TLS version allowed */
-	const char *tlsciphersuites;/* allowed TLS 1.3 ciphersuites */
-	const char *tlsecdhcurves; /* allowed ecdhcurves list*/
-	const char *cert;	/* file holding server certificate key */
-	const char *key;	/* file holding server private key */
-	const char *KI;		/* file holding K/I for making cookies */
-	const char *ca;		/* root cert dir/file */
-	const char *aead;	/* AEAD algorithms on wire */
-	bool tlscipherserverpreference;  /* OpenSSL 3.0 default is client */
+        bool ntsenable;         // enable NTS KE server on this ntpd
+        const char * mintls;    // minimum TLS version allowed
+        const char * maxtls;    // maximum TLS version allowed
+        const char *tlsciphersuites;  // allowed TLS 1.3 ciphersuites
+        const char *tlsecdhcurves;  // allowed ecdhcurves list
+        const char *cert;       // file holding server certificate key
+        const char *key;        // file holding server private key
+        const char *KI;         // file holding K/I for making cookies
+        const char *ca;         // root cert dir/file
+        const char *aead;       // AEAD algorithms on wire
+        bool tlscipherserverpreference;  // OpenSSL 3.0 default is client
 };
 
 
-/* CMAC length is wired into AEAD_AES_SIV_CMAC_nnn. */
+// CMAC length is wired into AEAD_AES_SIV_CMAC_nnn.
 #define CMAC_LENGTH 16
-/* The NONCE length comes from RFC 5116 and/or 5297. */
+// The NONCE length comes from RFC 5116 and/or 5297.
 #define NONCE_LENGTH 16
 
-/* NTS protocol constants */
+// NTS protocol constants
 
 #define NTS_CRITICAL 0x8000
 enum nts_record_type {
-	nts_end_of_message = 0,		/* CRITICAL */
-	nts_next_protocol_negotiation = 1,	/* CRITICAL */
-	nts_error = 2,			/* CRITICAL */
-	nts_warning = 3,
-	nts_algorithm_negotiation = 4,
-	nts_new_cookie = 5,
-	nts_server_negotiation = 6,
-	nts_port_negotiation = 7
+        nts_end_of_message = 0,         // CRITICAL
+        nts_next_protocol_negotiation = 1,      // CRITICAL
+        nts_error = 2,                  // CRITICAL
+        nts_warning = 3,
+        nts_algorithm_negotiation = 4,
+        nts_new_cookie = 5,
+        nts_server_negotiation = 6,
+        nts_port_negotiation = 7
 };
 
 enum nts_protocol_type {
-	nts_protocol_NTP = 0,
+        nts_protocol_NTP = 0,
 };
 
 
 enum nts_errors_type {
-	nts_unrecognized_critical_section = 0,
-	nts_bad_request = 1
+        nts_unrecognized_critical_section = 0,
+        nts_bad_request = 1
 };
 
 
@@ -197,50 +197,50 @@ enum nts_errors_type {
  */
 enum aead_ciphers {
 #define NO_AEAD 0xffff
-	AEAD_AES_128_GCM = 1,
-	AEAD_AES_256_GCM = 2,
-	AEAD_AES_128_CCM = 3,
-	AEAD_AES_256_CCM = 4,
-
-	AEAD_AES_128_GCM_8 = 5,
-	AEAD_AES_256_GCM_8 = 6,
-	AEAD_AES_128_GCM_12 = 7,
-	AEAD_AES_256_GCM_12 = 8,
-
-	AEAD_AES_128_CCM_SHORT = 9,
-	AEAD_AES_256_CCM_SHORT = 10,
-	AEAD_AES_128_CCM_SHORT_8 = 11,
-	AEAD_AES_256_CCM_SHORT_8 = 12,
-	AEAD_AES_128_CCM_SHORT_12 = 13,
-	AEAD_AES_256_CCM_SHORT_12 = 14,
-
-	AEAD_AES_SIV_CMAC_256 = 15,     /* RFC 5297 */
-	AEAD_AES_SIV_CMAC_384 = 16,     /* These 3 are the ones we use */
-	AEAD_AES_SIV_CMAC_512 = 17,
+        AEAD_AES_128_GCM = 1,
+        AEAD_AES_256_GCM = 2,
+        AEAD_AES_128_CCM = 3,
+        AEAD_AES_256_CCM = 4,
+
+        AEAD_AES_128_GCM_8 = 5,
+        AEAD_AES_256_GCM_8 = 6,
+        AEAD_AES_128_GCM_12 = 7,
+        AEAD_AES_256_GCM_12 = 8,
+
+        AEAD_AES_128_CCM_SHORT = 9,
+        AEAD_AES_256_CCM_SHORT = 10,
+        AEAD_AES_128_CCM_SHORT_8 = 11,
+        AEAD_AES_256_CCM_SHORT_8 = 12,
+        AEAD_AES_128_CCM_SHORT_12 = 13,
+        AEAD_AES_256_CCM_SHORT_12 = 14,
+
+        AEAD_AES_SIV_CMAC_256 = 15,     // RFC 5297
+        AEAD_AES_SIV_CMAC_384 = 16,     // These 3 are the ones we use
+        AEAD_AES_SIV_CMAC_512 = 17,
 #define AEAD_AES_SIV_CMAC_256_KEYLEN 32
 #define AEAD_AES_SIV_CMAC_384_KEYLEN 48
 #define AEAD_AES_SIV_CMAC_512_KEYLEN 64
 
-	AEAD_AES_128_CCM_8 = 18,
-	AEAD_AES_256_CCM_8 = 19,
+        AEAD_AES_128_CCM_8 = 18,
+        AEAD_AES_256_CCM_8 = 19,
 
-	AEAD_AES_128_OCB_TAGLEN128 = 20,
-	AEAD_AES_128_OCB_TAGLEN96 = 21,
-	AEAD_AES_128_OCB_TAGLEN64 = 22,
-	AEAD_AES_192_OCB_TAGLEN128 = 23,
-	AEAD_AES_192_OCB_TAGLEN96 = 24,
-	AEAD_AES_192_OCB_TAGLEN64 = 25,
-	AEAD_AES_256_OCB_TAGLEN128 = 26,
-	AEAD_AES_256_OCB_TAGLEN96 = 27,
-	AEAD_AES_256_OCB_TAGLEN64 = 28,
+        AEAD_AES_128_OCB_TAGLEN128 = 20,
+        AEAD_AES_128_OCB_TAGLEN96 = 21,
+        AEAD_AES_128_OCB_TAGLEN64 = 22,
+        AEAD_AES_192_OCB_TAGLEN128 = 23,
+        AEAD_AES_192_OCB_TAGLEN96 = 24,
+        AEAD_AES_192_OCB_TAGLEN64 = 25,
+        AEAD_AES_256_OCB_TAGLEN128 = 26,
+        AEAD_AES_256_OCB_TAGLEN96 = 27,
+        AEAD_AES_256_OCB_TAGLEN64 = 28,
 
-	AEAD_CHACHA20_POLY1305 = 29,
+        AEAD_CHACHA20_POLY1305 = 29,
 
-	AEAD_AES_128_GCM_SIV = 30,
-	AEAD_AES_256_GCM_SIV = 31,
+        AEAD_AES_128_GCM_SIV = 30,
+        AEAD_AES_256_GCM_SIV = 31,
 
-	AEAD_AEGIS128L = 32,
-	AEAD_AEGIS256 = 33
+        AEAD_AEGIS128L = 32,
+        AEAD_AEGIS256 = 33
 };
 
 
@@ -249,7 +249,7 @@ extern struct ntsconfig_t ntsconfig;
 
 
 
-/* NTS-related statistics visible via ntpq -c nts */
+// NTS-related statistics visible via ntpq -c nts
 struct nts_counters {
   uint64_t client_send;
   uint64_t client_recv_good;
@@ -258,17 +258,17 @@ struct nts_counters {
   uint64_t server_recv_good;
   uint64_t server_recv_bad;
   uint64_t cookie_make;
-  uint64_t cookie_not_server;   /* we are not a NTS server */
-  uint64_t cookie_decode_total; /* total attempts, includes too old */
+  uint64_t cookie_not_server;   // we are not a NTS server
+  uint64_t cookie_decode_total;  // total attempts, includes too old
   uint64_t cookie_decode_current;
   uint64_t cookie_decode_old;
   uint64_t cookie_decode_old2;
   uint64_t cookie_decode_older;
-  uint64_t cookie_decode_too_old; /* or garbage */
+  uint64_t cookie_decode_too_old;  // or garbage
   uint64_t cookie_decode_error;
 };
 struct ntske_counters {
-  /* Server */
+  // Server
   uint64_t serves_nossl;
   l_fp     serves_nossl_wall;
   l_fp     serves_nossl_cpu;
@@ -278,7 +278,7 @@ struct ntske_counters {
   uint64_t serves_good;
   l_fp     serves_good_wall;
   l_fp     serves_good_cpu;
-  /* Client */
+  // Client
   uint64_t probes_good;
   uint64_t probes_bad;
 };
@@ -286,4 +286,4 @@ extern struct nts_counters nts_cnt, old_nts_cnt;
 extern struct ntske_counters ntske_cnt, old_ntske_cnt;
 
 
-#endif /* GUARD_NTS_H */
+#endif  // GUARD_NTS_H


=====================================
ntpd/ntp_scanner.c
=====================================
@@ -3,9 +3,9 @@
  *
  * The source code for a simple lexical analyzer.
  *
- * Written By:	Sachin Kamboj
- *		University of Delaware
- *		Newark, DE 19711
+ * Written By:  Sachin Kamboj
+ *              University of Delaware
+ *              Newark, DE 19711
  * Copyright Sachin Kamboj
  * Copyright the NTPsec project contributors
  * SPDX-License-Identifier: BSD-2-Clause
@@ -29,24 +29,24 @@
 #include "ntp_scanner.h"
 #include "ntp_debug.h"
 #include "ntp_parser.tab.h"
-#include "timespecops.h"      /* for D_ISZERO_NS() */
+#include "timespecops.h"  // for D_ISZERO_NS()
 
-/* ntp_keyword.h declares finite state machine and token text */
+// ntp_keyword.h declares finite state machine and token text
 #include "ntp_keyword.h"
 
-/* used to implement g and G suffixes for numeric literals in fudge offset declarations */
-#define SECONDS_IN_WEEK	(unsigned long long)(7 * 24 * 60 * 60) /* 32bit systems*/
-#define GPS_ERA_10BIT	(1024L * SECONDS_IN_WEEK)
-#define GPS_ERA_13BIT	(8192L * SECONDS_IN_WEEK)
-#define ERA_SUFFIX(c)	((c) == 'g' || (c) == 'G')
+// used to implement g and G suffixes for numeric literals in fudge offset declarations
+#define SECONDS_IN_WEEK (unsigned long long)(7 * 24 * 60 * 60)  // 32bit systems
+#define GPS_ERA_10BIT   (1024L * SECONDS_IN_WEEK)
+#define GPS_ERA_13BIT   (8192L * SECONDS_IN_WEEK)
+#define ERA_SUFFIX(c)   ((c) == 'g' || (c) == 'G')
 
 /* SCANNER GLOBAL VARIABLES
  * ------------------------
  */
 
-#define MAX_LEXEME (1024 + 1)	/* The maximum size of a lexeme */
-static char yytext[MAX_LEXEME];	/* Buffer for storing the input text/lexeme */
-static uint32_t conf_file_sum;	/* Simple sum of characters read */
+#define MAX_LEXEME (1024 + 1)  // The maximum size of a lexeme
+static char yytext[MAX_LEXEME];  // Buffer for storing the input text/lexeme
+static uint32_t conf_file_sum;  // Simple sum of characters read
 
 static struct FILE_INFO * lex_stack = NULL;
 
@@ -54,7 +54,7 @@ static struct FILE_INFO * lex_stack = NULL;
  * --------------------
  */
 #define ENDSWITH(str, suff) (strcmp(str + strlen(str) - strlen(suff), suff)==0)
-#define CONF_ENABLE(s)	ENDSWITH(s, ".conf")
+#define CONF_ENABLE(s)  ENDSWITH(s, ".conf")
 
 
 /* SCANNER GLOBAL VARIABLES
@@ -72,29 +72,29 @@ static int is_keyword(char *lexeme, follby *pfollowedby);
 
 /*
  * keyword() - Return the keyword associated with token T_ identifier.
- *	       See also token_name() for the string-ized T_ identifier.
- *	       Example: keyword(T_Server) returns "server"
- *			token_name(T_Server) returns "T_Server"
+ *             See also token_name() for the string-ized T_ identifier.
+ *             Example: keyword(T_Server) returns "server"
+ *                      token_name(T_Server) returns "T_Server"
  */
 const char *
 keyword(
-	int token
-	)
+        int token
+        )
 {
-	size_t i;
-	const char *text;
+        size_t i;
+        const char *text;
 
-	i = (size_t)(token - LOWEST_KEYWORD_ID);
+        i = (size_t)(token - LOWEST_KEYWORD_ID);
 
-	if (i < COUNTOF(keyword_text)) {
-		text = keyword_text[i];
-	} else {
-		text = NULL;
-	}
+        if (i < COUNTOF(keyword_text)) {
+                text = keyword_text[i];
+        } else {
+                text = NULL;
+        }
 
-	return (text != NULL)
-		   ? text
-		   : "(keyword not found)";
+        return (text != NULL)
+                   ? text
+                   : "(keyword not found)";
 }
 
 
@@ -135,30 +135,30 @@ keyword(
  */
 static struct FILE_INFO *
 lex_open(
-	const char *path,
-	const char *mode
-	)
+        const char *path,
+        const char *mode
+        )
 {
-	struct FILE_INFO *stream;
-	size_t            nnambuf;
-
-	nnambuf = strlen(path);
-	stream = emalloc_zero(sizeof(*stream) + nnambuf);
-	stream->curpos.nline = 1;
-	stream->backch = EOF;
-	/* copy name with memcpy -- trailing NUL already there! */
-	memcpy(stream->fname, path, nnambuf);
-
-	if (NULL != mode) {
-		stream->fpi = fopen(path, mode);
-		if (NULL == stream->fpi) {
-			free(stream);
-			msyslog(LOG_ERR, "CONFIG: failed to open \'%s\': %s",
-				path, strerror(errno));
-			stream = NULL;
-		}
-	}
-	return stream;
+        struct FILE_INFO *stream;
+        size_t            nnambuf;
+
+        nnambuf = strlen(path);
+        stream = emalloc_zero(sizeof(*stream) + nnambuf);
+        stream->curpos.nline = 1;
+        stream->backch = EOF;
+        // copy name with memcpy -- trailing NUL already there!
+        memcpy(stream->fname, path, nnambuf);
+
+        if (NULL != mode) {
+                stream->fpi = fopen(path, mode);
+                if (NULL == stream->fpi) {
+                        free(stream);
+                        msyslog(LOG_ERR, "CONFIG: failed to open \'%s\': %s",
+                                path, strerror(errno));
+                        stream = NULL;
+                }
+        }
+        return stream;
 }
 
 /* get next character from buffer or file. This will return any putback
@@ -167,62 +167,62 @@ lex_open(
  */
 static int
 lex_getch(
-	struct FILE_INFO *stream
-	)
+        struct FILE_INFO *stream
+        )
 {
-	int ch;
-
-	if (NULL == stream || stream->force_eof)
-		return EOF;
-
-	if (EOF != stream->backch) {
-		ch = stream->backch;
-		stream->backch = EOF;
-		if (stream->fpi)
-			conf_file_sum += (unsigned int)ch;
-	} else if (stream->fpi) {
-		/* fetch next 7-bit ASCII char (or EOF) from file */
-		/* coverity[tainted_scalar] */
-		while ((ch = fgetc(stream->fpi)) != EOF && ch > SCHAR_MAX) {
-			stream->curpos.ncol++;
-		}
-		if (EOF != ch) {
-			conf_file_sum += (unsigned int)ch;
-			stream->curpos.ncol++;
-		}
-	} else {
-		/* fetch next 7-bit ASCII char from buffer */
-		const char * scan;
-		scan = &remote_config.buffer[remote_config.pos];
-		while ((ch = (uint8_t)*scan) > SCHAR_MAX) {
-			scan++;
-			stream->curpos.ncol++;
-		}
-		if ('\0' != ch) {
-			scan++;
-			stream->curpos.ncol++;
-		} else {
-			ch = EOF;
-		}
-		remote_config.pos = (int)(scan - remote_config.buffer);
-	}
-
-	/* If the last line ends without '\n', generate one. This
-	 * happens most likely on Windows, where editors often have a
-	 * sloppy concept of a line.
-	 */
-	if (EOF == ch && stream->curpos.ncol != 0) {
-		ch = '\n';
-	}
-
-	/* update scan position tallies */
-	if (ch == '\n') {
-		stream->bakpos = stream->curpos;
-		stream->curpos.nline++;
-		stream->curpos.ncol = 0;
-	}
-
-	return ch;
+        int ch;
+
+        if (NULL == stream || stream->force_eof)
+                return EOF;
+
+        if (EOF != stream->backch) {
+                ch = stream->backch;
+                stream->backch = EOF;
+                if (stream->fpi)
+                        conf_file_sum += (unsigned int)ch;
+        } else if (stream->fpi) {
+                // fetch next 7-bit ASCII char (or EOF) from file
+                // coverity[tainted_scalar]
+                while ((ch = fgetc(stream->fpi)) != EOF && ch > SCHAR_MAX) {
+                        stream->curpos.ncol++;
+                }
+                if (EOF != ch) {
+                        conf_file_sum += (unsigned int)ch;
+                        stream->curpos.ncol++;
+                }
+        } else {
+                // fetch next 7-bit ASCII char from buffer
+                const char * scan;
+                scan = &remote_config.buffer[remote_config.pos];
+                while ((ch = (uint8_t)*scan) > SCHAR_MAX) {
+                        scan++;
+                        stream->curpos.ncol++;
+                }
+                if ('\0' != ch) {
+                        scan++;
+                        stream->curpos.ncol++;
+                } else {
+                        ch = EOF;
+                }
+                remote_config.pos = (int)(scan - remote_config.buffer);
+        }
+
+        /* If the last line ends without '\n', generate one. This
+         * happens most likely on Windows, where editors often have a
+         * sloppy concept of a line.
+         */
+        if (EOF == ch && stream->curpos.ncol != 0) {
+                ch = '\n';
+        }
+
+        // update scan position tallies
+        if (ch == '\n') {
+                stream->bakpos = stream->curpos;
+                stream->curpos.nline++;
+                stream->curpos.ncol = 0;
+        }
+
+        return ch;
 }
 
 /* Note: lex_ungetch will fail to track more than one line of push
@@ -231,29 +231,29 @@ lex_getch(
  */
 static int
 lex_ungetch(
-	int ch,
-	struct FILE_INFO *stream
-	)
+        int ch,
+        struct FILE_INFO *stream
+        )
 {
-	/* check preconditions */
-	if (NULL == stream || stream->force_eof)
-		return EOF;
-	if (EOF != stream->backch || EOF == ch) {
-		return EOF;
-	}
-
-	/* keep for later reference and update checksum */
-	stream->backch = (uint8_t)ch;
-	if (stream->fpi)
-		conf_file_sum -= (unsigned int)stream->backch;
-
-	/* update position */
-	if (stream->backch == '\n') {
-	    stream->curpos = stream->bakpos;
-	    stream->bakpos.ncol = -1;
-	}
-	stream->curpos.ncol--;
-	return stream->backch;
+        // check preconditions
+        if (NULL == stream || stream->force_eof)
+                return EOF;
+        if (EOF != stream->backch || EOF == ch) {
+                return EOF;
+        }
+
+        // keep for later reference and update checksum
+        stream->backch = (uint8_t)ch;
+        if (stream->fpi)
+                conf_file_sum -= (unsigned int)stream->backch;
+
+        // update position
+        if (stream->backch == '\n') {
+            stream->curpos = stream->bakpos;
+            stream->bakpos.ncol = -1;
+        }
+        stream->curpos.ncol--;
+        return stream->backch;
 }
 
 /* dispose of an input structure. If the file pointer is not NULL, close
@@ -261,15 +261,15 @@ lex_ungetch(
  */
 static void
 lex_close(
-	struct FILE_INFO *stream
-	)
+        struct FILE_INFO *stream
+        )
 {
-	if (NULL != stream) {
-		if (NULL != stream->fpi) {
-			fclose(stream->fpi);
-		}
-		free(stream);
-	}
+        if (NULL != stream) {
+                if (NULL != stream->fpi) {
+                        fclose(stream->fpi);
+                }
+                free(stream);
+        }
 }
 
 /* INPUT STACK
@@ -287,16 +287,16 @@ lex_close(
 
 static struct FILE_INFO *
 _drop_stack_do(
-	struct FILE_INFO * head
-	)
+        struct FILE_INFO * head
+        )
 {
-	struct FILE_INFO * tail;
-	while (NULL != head) {
-		tail = head->st_next;
-		lex_close(head);
-		head = tail;
-	}
-	return head;
+        struct FILE_INFO * tail;
+        while (NULL != head) {
+                tail = head->st_next;
+                lex_close(head);
+                head = tail;
+        }
+        return head;
 }
 
 
@@ -309,16 +309,16 @@ _drop_stack_do(
  */
 bool
 lex_init_stack(
-	const char * path,
-	const char * mode
-	)
+        const char * path,
+        const char * mode
+        )
 {
-	if (NULL != lex_stack || NULL == path)
-		return false;
+        if (NULL != lex_stack || NULL == path)
+                return false;
 
-	//fprintf(stderr, "lex_init_stack(%s)\n", path);
-	lex_stack = lex_open(path, mode);
-	return (NULL != lex_stack);
+        //fprintf(stderr, "lex_init_stack(%s)\n", path);
+        lex_stack = lex_open(path, mode);
+        return (NULL != lex_stack);
 }
 
 /* This removes *all* input sources from the stack, leaving the head
@@ -331,7 +331,7 @@ lex_init_stack(
 void
 lex_drop_stack(void)
 {
-	lex_stack = _drop_stack_do(lex_stack);
+        lex_stack = _drop_stack_do(lex_stack);
 }
 
 /* Flush the lexer input stack: This will nip all input objects on the
@@ -344,43 +344,43 @@ lex_drop_stack(void)
  */
 bool
 lex_flush_stack(void) {
-	bool retv = false;
-
-	if (NULL != lex_stack) {
-		retv = !lex_stack->force_eof;
-		lex_stack->force_eof = true;
-		lex_stack->st_next = _drop_stack_do(
-					lex_stack->st_next);
-	}
-	return retv;
+        bool retv = false;
+
+        if (NULL != lex_stack) {
+                retv = !lex_stack->force_eof;
+                lex_stack->force_eof = true;
+                lex_stack->st_next = _drop_stack_do(
+                                        lex_stack->st_next);
+        }
+        return retv;
 }
 
 /* Reversed string comparison - we want to LIFO directory subfiles so they
  * actually get evaluated in sort order.
  */
 static int rcmpstring(const void *p1, const void *p2) {
-	return strcmp(*(const char * const *)p1, *(const char * const *)p2);
+        return strcmp(*(const char * const *)p1, *(const char * const *)p2);
 }
 
 bool is_directory(const char *path) {
-	struct stat sb;
-	return stat(path, &sb) == 0 && S_ISDIR(sb.st_mode);
+        struct stat sb;
+        return stat(path, &sb) == 0 && S_ISDIR(sb.st_mode);
 }
 
 void reparent(char *fullpath, size_t fullpathsize,
-	      const char *dir, const char *base)
+              const char *dir, const char *base)
 {
-	fullpath[0] = '\0';
-	if (base[0] != DIR_SEP) {
-		char *dirpart = strdup(dir);
-		char *end;
-		strlcpy(fullpath, dirname(dirpart), fullpathsize-2);
-		end = fullpath + strlen(fullpath);
-		*end++ = DIR_SEP;
-		*end++ = '\0';
-		free(dirpart);
-	}
-	strlcat(fullpath, base, fullpathsize);
+        fullpath[0] = '\0';
+        if (base[0] != DIR_SEP) {
+                char *dirpart = strdup(dir);
+                char *end;
+                strlcpy(fullpath, dirname(dirpart), fullpathsize-2);
+                end = fullpath + strlen(fullpath);
+                *end++ = DIR_SEP;
+                *end++ = '\0';
+                free(dirpart);
+        }
+        strlcat(fullpath, base, fullpathsize);
 }
 
 /* Push another file on the parsing stack. If the mode is NULL, create a
@@ -400,40 +400,40 @@ void reparent(char *fullpath, size_t fullpathsize,
  * Returns true if a new info record was pushed onto the stack.
  */
 bool lex_push_file(
-	const char * path
-	)
+        const char * path
+        )
 {
-	struct FILE_INFO * next = NULL;
-
-	if (NULL != path) {
-		char fullpath[PATH_MAX];
-		if (lex_stack != NULL) {
-			reparent(fullpath, sizeof(fullpath), lex_stack->fname, path);
-		} else {
-			strlcpy(fullpath, path, sizeof(fullpath));
-		}
-		//fprintf(stderr, "lex_push_file(%s)\n", fullpath);
-		if (is_directory(fullpath)) {
-			/* directory scanning */
-			DIR *dfd;
-			struct dirent *dp;
-			char **baselist;
-			int basecount = 0;
-			if ((dfd = opendir(fullpath)) == NULL)
-				return false;
-			baselist = (char **)malloc(sizeof(char *));
-			if (NULL == baselist) {
-				msyslog(LOG_ERR,
+        struct FILE_INFO * next = NULL;
+
+        if (NULL != path) {
+                char fullpath[PATH_MAX];
+                if (lex_stack != NULL) {
+                        reparent(fullpath, sizeof(fullpath), lex_stack->fname, path);
+                } else {
+                        strlcpy(fullpath, path, sizeof(fullpath));
+                }
+                //fprintf(stderr, "lex_push_file(%s)\n", fullpath);
+                if (is_directory(fullpath)) {
+                        // directory scanning
+                        DIR *dfd;
+                        struct dirent *dp;
+                        char **baselist;
+                        int basecount = 0;
+                        if ((dfd = opendir(fullpath)) == NULL)
+                                return false;
+                        baselist = (char **)malloc(sizeof(char *));
+                        if (NULL == baselist) {
+                                msyslog(LOG_ERR,
                                     "CONFIG: lex_push_file: NULL from malloc");
-				exit(3);
-			}
-			while ((dp = readdir(dfd)) != NULL)
-			{
-				if (!CONF_ENABLE(dp->d_name)) {
-					continue;
-				}
-				baselist[basecount++] = strdup(dp->d_name);
-				baselist = realloc(baselist,
+                                exit(3);
+                        }
+                        while ((dp = readdir(dfd)) != NULL)
+                        {
+                                if (!CONF_ENABLE(dp->d_name)) {
+                                        continue;
+                                }
+                                baselist[basecount++] = strdup(dp->d_name);
+                                baselist = realloc(baselist,
                                        (size_t)(basecount+1) * sizeof(char *));
                                 if (NULL == baselist) {
                                         msyslog(LOG_ERR,
@@ -441,43 +441,43 @@ bool lex_push_file(
                                             "NULL from realloc");
                                         exit(3);
                                 }
-			}
-			closedir(dfd);
-			qsort(baselist, (size_t)basecount, sizeof(char *),
+                        }
+                        closedir(dfd);
+                        qsort(baselist, (size_t)basecount, sizeof(char *),
                               rcmpstring);
-			for (int i = 0; i < basecount; i++) {
-				char subpath[PATH_MAX];
-				size_t pathlen = strlcpy(subpath, fullpath, PATH_MAX);
-				if ((pathlen < PATH_MAX - 1) &&
-					(subpath[pathlen -1] != DIR_SEP)
-				) {
-					char *ep = subpath + strlen(subpath);
-					*ep++ = DIR_SEP;
-					*ep = '\0';
-				}
-				strlcat(subpath, baselist[i], PATH_MAX);
-				/* This should barf safely if the complete
-				 * filename was too long to fit in the buffer.
-				 */
-				msyslog(LOG_NOTICE,
-					"CONFIG: opening <%s> from dir <%s>",
-					subpath, fullpath);
-				lex_push_file(subpath);
-			}
-			for (int i = 0; i < basecount; i++) {
-				free(baselist[i]);
-			}
-			free(baselist);
-			return basecount > 0;
-		} else {
-			next = lex_open(fullpath, "r");
-			if (NULL != next) {
-				next->st_next = lex_stack;
-				lex_stack = next;
-			}
-		}
-	}
-	return (NULL != next);
+                        for (int i = 0; i < basecount; i++) {
+                                char subpath[PATH_MAX];
+                                size_t pathlen = strlcpy(subpath, fullpath, PATH_MAX);
+                                if ((pathlen < PATH_MAX - 1) &&
+                                        (subpath[pathlen -1] != DIR_SEP)
+                                ) {
+                                        char *ep = subpath + strlen(subpath);
+                                        *ep++ = DIR_SEP;
+                                        *ep = '\0';
+                                }
+                                strlcat(subpath, baselist[i], PATH_MAX);
+                                /* This should barf safely if the complete
+                                 * filename was too long to fit in the buffer.
+                                 */
+                                msyslog(LOG_NOTICE,
+                                        "CONFIG: opening <%s> from dir <%s>",
+                                        subpath, fullpath);
+                                lex_push_file(subpath);
+                        }
+                        for (int i = 0; i < basecount; i++) {
+                                free(baselist[i]);
+                        }
+                        free(baselist);
+                        return basecount > 0;
+                } else {
+                        next = lex_open(fullpath, "r");
+                        if (NULL != next) {
+                                next->st_next = lex_stack;
+                                lex_stack = next;
+                        }
+                }
+        }
+        return (NULL != next);
 }
 
 /* Pop, close & free the top of the include stack, unless the stack
@@ -490,17 +490,17 @@ bool lex_push_file(
 bool
 lex_pop_file(void)
 {
-	struct FILE_INFO * head = lex_stack;
-	struct FILE_INFO * tail = NULL;
-
-	if (NULL != head) {
-		tail = head->st_next;
-		if (NULL != tail) {
-			lex_stack = tail;
-			lex_close(head);
-		}
-	}
-	return (NULL != tail);
+        struct FILE_INFO * head = lex_stack;
+        struct FILE_INFO * tail = NULL;
+
+        if (NULL != head) {
+                tail = head->st_next;
+                if (NULL != tail) {
+                        lex_stack = tail;
+                        lex_close(head);
+                }
+        }
+        return (NULL != tail);
 }
 
 /* Get include nesting level. This currently loops over the stack and
@@ -516,30 +516,30 @@ lex_pop_file(void)
 size_t
 lex_level(void)
 {
-	size_t            cnt = 0;
-	struct FILE_INFO *ipf = lex_stack;
-
-	while (NULL != ipf) {
-		cnt++;
-		ipf = ipf->st_next;
-	}
-	return cnt;
+        size_t            cnt = 0;
+        struct FILE_INFO *ipf = lex_stack;
+
+        while (NULL != ipf) {
+                cnt++;
+                ipf = ipf->st_next;
+        }
+        return cnt;
 }
 
-/* check if the current input is from a file */
+// check if the current input is from a file
 bool
 lex_from_file(void)
 {
-	return (NULL != lex_stack) && (NULL != lex_stack->fpi);
+        return (NULL != lex_stack) && (NULL != lex_stack->fpi);
 }
 
 struct FILE_INFO *
 lex_current(void)
 {
-	/* this became so simple, it could be a macro. But then,
-	 * lex_stack needed to be global...
-	 */
-	return lex_stack;
+        /* this became so simple, it could be a macro. But then,
+         * lex_stack needed to be global...
+         */
+        return lex_stack;
 }
 
 
@@ -547,239 +547,239 @@ lex_current(void)
  * --------------
  */
 
-/* Keywords */
+// Keywords
 static int
 is_keyword(
-	char *lexeme,
-	follby *pfollowedby
-	)
+        char *lexeme,
+        follby *pfollowedby
+        )
 {
-	follby fb;
-	int curr_s;		/* current state index */
-	int token;
-
-	curr_s = SCANNER_INIT_S;
-	token = 0;
-
-	for (int i = 0; lexeme[i]; i++) {
-		while (curr_s && (lexeme[i] != SS_CH(sst[curr_s])))
-			curr_s = (int)SS_OTHER_N(sst[curr_s]);
-
-		if (curr_s && (lexeme[i] == SS_CH(sst[curr_s]))) {
-			if ('\0' == lexeme[i + 1]
-			    && FOLLBY_NON_ACCEPTING
-			       != SS_FB(sst[curr_s])) {
-				fb = SS_FB(sst[curr_s]);
-				*pfollowedby = fb;
-				token = curr_s;
-				break;
-			}
-			curr_s = SS_MATCH_N(sst[curr_s]);
-		} else
-			break;
-	}
-
-	return token;
+        follby fb;
+        int curr_s;  // current state index
+        int token;
+
+        curr_s = SCANNER_INIT_S;
+        token = 0;
+
+        for (int i = 0; lexeme[i]; i++) {
+                while (curr_s && (lexeme[i] != SS_CH(sst[curr_s])))
+                        curr_s = (int)SS_OTHER_N(sst[curr_s]);
+
+                if (curr_s && (lexeme[i] == SS_CH(sst[curr_s]))) {
+                        if ('\0' == lexeme[i + 1]
+                            && FOLLBY_NON_ACCEPTING
+                               != SS_FB(sst[curr_s])) {
+                                fb = SS_FB(sst[curr_s]);
+                                *pfollowedby = fb;
+                                token = curr_s;
+                                break;
+                        }
+                        curr_s = SS_MATCH_N(sst[curr_s]);
+                } else
+                        break;
+        }
+
+        return token;
 }
 
 
-/* Integer */
+// Integer
 static int
 is_integer(
-	char *lexeme
-	)
+        char *lexeme
+        )
 {
-	int	i;
-	int	is_neg;
-	unsigned int	u_val;
-
-	i = 0;
-
-	/* Allow a leading minus sign */
-	if (lexeme[i] == '-') {
-		i++;
-		is_neg = true;
-	} else {
-		is_neg = false;
-	}
-
-	/* Check that all the remaining characters are digits */
-	for (; lexeme[i] != '\0'; i++) {
-		if (!isdigit((uint8_t)lexeme[i]))
-			return false;
-	}
-
-	if (is_neg)
-		return true;
-
-	/* Reject numbers that fit in unsigned but not in signed int */
-	if (1 == sscanf(lexeme, "%u", &u_val)) {
-		return (u_val <= INT_MAX);
-	} else {
-		return false;
-	}
+        int     i;
+        int     is_neg;
+        unsigned int    u_val;
+
+        i = 0;
+
+        // Allow a leading minus sign
+        if (lexeme[i] == '-') {
+                i++;
+                is_neg = true;
+        } else {
+                is_neg = false;
+        }
+
+        // Check that all the remaining characters are digits
+        for (; lexeme[i] != '\0'; i++) {
+                if (!isdigit((uint8_t)lexeme[i]))
+                        return false;
+        }
+
+        if (is_neg)
+                return true;
+
+        // Reject numbers that fit in unsigned but not in signed int
+        if (1 == sscanf(lexeme, "%u", &u_val)) {
+                return (u_val <= INT_MAX);
+        } else {
+                return false;
+        }
 }
 
 
-/* unsigned int -- assumes is_integer() has returned false */
+// unsigned int -- assumes is_integer() has returned false
 static int
 is_u_int(
-	char *lexeme
-	)
+        char *lexeme
+        )
 {
-	int	i;
-	int	is_hex;
-
-	i = 0;
-	if ('0' == lexeme[i] && 'x' == tolower((uint8_t)lexeme[i + 1])) {
-		i += 2;
-		is_hex = true;
-	} else {
-		is_hex = false;
-	}
-
-	/* Check that all the remaining characters are digits */
-	for (; lexeme[i] != '\0'; i++) {
-		if (is_hex && !isxdigit((uint8_t)lexeme[i]))
-			return false;
-		if (!is_hex && !isdigit((uint8_t)lexeme[i]))
-			return false;
-	}
-
-	return true;
+        int     i;
+        int     is_hex;
+
+        i = 0;
+        if ('0' == lexeme[i] && 'x' == tolower((uint8_t)lexeme[i + 1])) {
+                i += 2;
+                is_hex = true;
+        } else {
+                is_hex = false;
+        }
+
+        // Check that all the remaining characters are digits
+        for (; lexeme[i] != '\0'; i++) {
+                if (is_hex && !isxdigit((uint8_t)lexeme[i]))
+                        return false;
+                if (!is_hex && !isdigit((uint8_t)lexeme[i]))
+                        return false;
+        }
+
+        return true;
 }
 
 
-/* Double */
+// Double
 static bool
 is_double(
-	char *lexeme
-	)
+        char *lexeme
+        )
 {
-	unsigned int num_digits = 0;  /* Number of digits read */
-	unsigned int i;
-
-	i = 0;
-
-	/* Check for an optional '+' or '-' */
-	if ('+' == lexeme[i] || '-' == lexeme[i]) {
-		i++;
-	}
-
-	/* Read the integer part */
-	for (; lexeme[i] && isdigit((uint8_t)lexeme[i]); i++)
-		num_digits++;
-
-	/* Check for the optional decimal point */
-	if ('.' == lexeme[i]) {
-		i++;
-		/* Check for any digits after the decimal point */
-		for (; lexeme[i] && isdigit((uint8_t)lexeme[i]); i++)
-			num_digits++;
-	}
-
-	/*
-	 * The number of digits in both the decimal part and the
-	 * fraction part must not be zero at this point
-	 */
-	if (!num_digits)
-		return false;
-
-	/* Check if we are done */
-	if (!lexeme[i])
-		return true;
-
-	/* There is still more input, read the exponent */
-	if ('e' == tolower((uint8_t)lexeme[i])) {
-		i++;
-
-		/* Read an optional Sign */
-		if ('+' == lexeme[i] || '-' == lexeme[i]) {
-			i++;
-		}
-
-		/* Now read the exponent part */
-		while (lexeme[i] && isdigit((uint8_t)lexeme[i]))
-			i++;
-
-	}
-
-	/* Allow trailing multipliers */
-	while (lexeme[i] && ERA_SUFFIX(lexeme[i])) {
-	    i++;
-	}
-
-	/* Check if we are done */
-	if (!lexeme[i])
-		return true;
-	else
-		return false;
+        unsigned int num_digits = 0;  // Number of digits read
+        unsigned int i;
+
+        i = 0;
+
+        // Check for an optional '+' or '-'
+        if ('+' == lexeme[i] || '-' == lexeme[i]) {
+                i++;
+        }
+
+        // Read the integer part
+        for (; lexeme[i] && isdigit((uint8_t)lexeme[i]); i++)
+                num_digits++;
+
+        // Check for the optional decimal point
+        if ('.' == lexeme[i]) {
+                i++;
+                // Check for any digits after the decimal point
+                for (; lexeme[i] && isdigit((uint8_t)lexeme[i]); i++)
+                        num_digits++;
+        }
+
+        /*
+         * The number of digits in both the decimal part and the
+         * fraction part must not be zero at this point
+         */
+        if (!num_digits)
+                return false;
+
+        // Check if we are done
+        if (!lexeme[i])
+                return true;
+
+        // There is still more input, read the exponent
+        if ('e' == tolower((uint8_t)lexeme[i])) {
+                i++;
+
+                // Read an optional Sign
+                if ('+' == lexeme[i] || '-' == lexeme[i]) {
+                        i++;
+                }
+
+                // Now read the exponent part
+                while (lexeme[i] && isdigit((uint8_t)lexeme[i]))
+                        i++;
+
+        }
+
+        // Allow trailing multipliers
+        while (lexeme[i] && ERA_SUFFIX(lexeme[i])) {
+            i++;
+        }
+
+        // Check if we are done
+        if (!lexeme[i])
+                return true;
+        else
+                return false;
 }
 
 
-/* is_special() - Test whether a character is a token */
+// is_special() - Test whether a character is a token
 static inline bool
 is_special(
-	int ch
-	)
+        int ch
+        )
 {
-	return strchr(special_chars, ch) != NULL;
+        return strchr(special_chars, ch) != NULL;
 }
 
 
 static bool
 is_EOC(
-	int ch
-	)
+        int ch
+        )
 {
-	if ( ch == '\n')
-		return true;
-	return false;
+        if ( ch == '\n')
+                return true;
+        return false;
 }
 
 
 char *
 quote_if_needed(char *str) {
-	char *ret;
-	size_t len;
-	size_t octets;
-
-	len = strlen(str);
-	octets = len + 2 + 1;
-	ret = emalloc(octets);
-	if ('"' != str[0]
-	    && (strcspn(str, special_chars) < len
-		|| strchr(str, ' ') != NULL)) {
-		snprintf(ret, octets, "\"%s\"", str);
-	} else {
-		strlcpy(ret, str, octets);
-	}
-
-	return ret;
+        char *ret;
+        size_t len;
+        size_t octets;
+
+        len = strlen(str);
+        octets = len + 2 + 1;
+        ret = emalloc(octets);
+        if ('"' != str[0]
+            && (strcspn(str, special_chars) < len
+                || strchr(str, ' ') != NULL)) {
+                snprintf(ret, octets, "\"%s\"", str);
+        } else {
+                strlcpy(ret, str, octets);
+        }
+
+        return ret;
 }
 
 
 static int
 create_string_token(
-	char *lexeme
-	)
+        char *lexeme
+        )
 {
-	char *pch;
-
-	/*
-	 * ignore end of line whitespace
-	 */
-	pch = lexeme;
-	while (*pch && isspace((uint8_t)*pch))
-		pch++;
-
-	if (!*pch) {
-		yylval.Integer = T_EOC;
-		return yylval.Integer;
-	}
-
-	yylval.String = estrdup(lexeme);
-	return T_String;
+        char *pch;
+
+        /*
+         * ignore end of line whitespace
+         */
+        pch = lexeme;
+        while (*pch && isspace((uint8_t)*pch))
+                pch++;
+
+        if (!*pch) {
+                yylval.Integer = T_EOC;
+                return yylval.Integer;
+        }
+
+        yylval.String = estrdup(lexeme);
+        return T_String;
 }
 
 
@@ -793,277 +793,277 @@ create_string_token(
 int
 yylex(void)
 {
-	static follby	followedby = FOLLBY_TOKEN;
-	int		i;
-	bool		instring;
-	bool		yylval_was_set;
-	int		converted;
-	int		token;		/* The return value */
-	int		ch;
-
-	instring = false;
-	yylval_was_set = false;
-
-	do {
-		/* Ignore whitespace at the beginning */
-		while (EOF != (ch = lex_getch(lex_stack)) &&
-		       isspace(ch) &&
-		       !is_EOC(ch))
-
-			; /* Null Statement */
-
-		if (EOF == ch) {
-
-			if ( ! lex_pop_file())
-				return 0;
-			token = T_EOC;
-			goto normal_return;
-
-		} else if (is_EOC(ch)) {
-
-			/* end FOLLBY_STRINGS_TO_EOC effect */
-			followedby = FOLLBY_TOKEN;
-			token = T_EOC;
-			goto normal_return;
-
-		} else if (is_special(ch) && FOLLBY_TOKEN == followedby) {
-			/* special chars are their own token values */
-			token = ch;
-			/*
-			 * '=' outside simulator configuration implies
-			 * a single string following as in:
-			 * setvar Owner = "The Boss" default
-			 */
-			if ('=' == ch ) {
-				followedby = FOLLBY_STRING;
-			}
-			yytext[0] = (char)ch;
-			yytext[1] = '\0';
-			goto normal_return;
-		} else
-			lex_ungetch(ch, lex_stack);
-
-		/* save the position of start of the token */
-		lex_stack->tokpos = lex_stack->curpos;
-
-		/* Read in the lexeme */
-		i = 0;
-		while (EOF != (ch = lex_getch(lex_stack))) {
-
-			yytext[i] = (char)ch;
-
-			/* Break on whitespace or a special character */
-			if (isspace(ch) || is_EOC(ch)
-			    || '"' == ch
-			    || (FOLLBY_TOKEN == followedby
-				&& is_special(ch)))
-				break;
-
-			/* Read the rest of the line on reading a start
-			   of comment character */
-			if ('#' == ch) {
-				while (EOF != (ch = lex_getch(lex_stack))
-				       && '\n' != ch) {
-					; /* Null Statement */
-				}
-				break;
-			}
-
-			i++;
-			if (i >= (int)COUNTOF(yytext)) {
-				goto lex_too_long;
-			}
-		}
-		/* Pick up all of the string inside between " marks, to
-		 * end of line.  If we make it to EOL without a
-		 * terminating " assume it for them.
-		 *
-		 * XXX - HMS: I'm not sure we want to assume the closing "
-		 */
-		if ('"' == ch) {
-			instring = true;
-			while (EOF != (ch = lex_getch(lex_stack)) &&
-			       ch != '"' && ch != '\n') {
-				yytext[i++] = (char)ch;
-				if (i >= (int)COUNTOF(yytext)) {
-					goto lex_too_long;
-				}
-			}
-			/*
-			 * yytext[i] will be pushed back as not part of
-			 * this lexeme, but any closing quote should
-			 * not be pushed back, so we read another char.
-			 */
-			if ('"' == ch) {
-				ch = lex_getch(lex_stack);
-			}
-		}
-		/* Pushback the last character read that is not a part
-		 * of this lexeme. This fails silently if ch is EOF,
-		 * but then the EOF condition persists and is handled on
-		 * the next turn by the include stack mechanism.
-		 */
-		lex_ungetch(ch, lex_stack);
-
-		yytext[i] = '\0';
-	} while (i == 0);
-
-	/* Now return the desired token */
-
-	/* First make sure that the parser is *not* expecting a string
-	 * as the next token (based on the previous token that was
-	 * returned) and that we haven't read a string.
-	 */
-
-	if (followedby == FOLLBY_TOKEN && !instring) {
-		token = is_keyword(yytext, &followedby);
-		if (token) {
-			goto normal_return;
-		} else if (is_integer(yytext)) {
-			yylval_was_set = true;
-			errno = 0;
-			yylval.Integer = (int)strtol(yytext, NULL, 10);
-			if (yylval.Integer == 0
-			    && ((errno == EINVAL) || (errno == ERANGE))) {
-				msyslog(LOG_ERR,
-					"CONFIG: Integer cannot be represented: %s",
-					yytext);
-				if (lex_from_file()) {
-					exit(1);
-				} else {
-					/* force end of parsing */
-					yylval.Integer = 0;
-					return 0;
-				}
-			}
-			token = T_Integer;
-			goto normal_return;
-		} else if (is_u_int(yytext)) {
-			yylval_was_set = true;
-			if ('0' == yytext[0] &&
-			    'x' == tolower((int)yytext[1]))
-				converted = sscanf(&yytext[2], "%x",
-						   &yylval.U_int);
-			else
-				converted = sscanf(yytext, "%u",
-						   &yylval.U_int);
-			if (1 != converted) {
-				msyslog(LOG_ERR,
-					"CONFIG: U_int cannot be represented: %s",
-					yytext);
-				if (lex_from_file()) {
-					exit(1);
-				} else {
-					/* force end of parsing */
-					yylval.Integer = 0;
-					return 0;
-				}
-			}
-			token = T_U_int;
-			goto normal_return;
-		} else if (is_double(yytext)) {
-		 	double era_offset = 0;
-			yylval_was_set = true;
-			errno = 0;
-			while (ERA_SUFFIX(yytext[strlen(yytext)-1])) {
-				if (yytext[strlen(yytext)-1] == 'g') {
-					era_offset += GPS_ERA_10BIT;
-				}
-				if (yytext[strlen(yytext)-1] == 'G') {
-					era_offset += GPS_ERA_13BIT;
-				}
-				yytext[strlen(yytext)-1] = '\0';
-			}
-			yylval.Double = era_offset + atof(yytext);
-			if ( D_ISZERO_NS(yylval.Double) && errno == ERANGE) {
-			    /* FIXME, POSIX says atof() never returns errors */
-			    msyslog(LOG_ERR,
-				    "CONFIG: Double too large to represent: %s",
-				    yytext);
-			    exit(1);
-			} else {
-			    token = T_Double;
-			    goto normal_return;
-			}
-		} else {
-			/* Default: Everything is a string */
-			yylval_was_set = true;
-			token = create_string_token(yytext);
-			goto normal_return;
-		}
-	}
-
-	/*
-	 * Either followedby is not FOLLBY_TOKEN or this lexeme is part
-	 * of a string.  Hence, we need to return T_String.
-	 *
-	 * _Except_ we might have a -4 or -6 flag on a an association
-	 * configuration line (server, peer, pool, etc.).
-	 *
-	 * This is a terrible hack, but the grammar is ambiguous so we
-	 * don't have a choice.  [SK]
-	 *
-	 * The ambiguity is in the keyword scanner, not ntp_parser.y.
-	 * We do not require server addresses be quoted in ntp.conf,
-	 * complicating the scanner's job.  To avoid trying (and
-	 * failing) to match an IP address or DNS name to a keyword,
-	 * the association keywords use FOLLBY_STRING in the keyword
-	 * table, which tells the scanner to force the next token to be
-	 * a T_String, so it does not try to match a keyword but rather
-	 * expects a string when -4/-6 modifiers to server, peer, etc.
-	 * are encountered.
-	 * restrict -4 and restrict -6 parsing works correctly without
-	 * this hack, as restrict uses FOLLBY_TOKEN.  [DH]
-	 */
-	if ('-' == yytext[0]) {
-		if ('4' == yytext[1]) {
-			token = T_Ipv4_flag;
-			goto normal_return;
-		} else if ('6' == yytext[1]) {
-			token = T_Ipv6_flag;
-			goto normal_return;
-		}
-	}
-
-	instring = false;
-	if (FOLLBY_STRING == followedby) {
-		followedby = FOLLBY_TOKEN;
-	}
-
-	yylval_was_set = true;
-	token = create_string_token(yytext);
+        static follby   followedby = FOLLBY_TOKEN;
+        int             i;
+        bool            instring;
+        bool            yylval_was_set;
+        int             converted;
+        int             token;  // The return value
+        int             ch;
+
+        instring = false;
+        yylval_was_set = false;
+
+        do {
+                // Ignore whitespace at the beginning
+                while (EOF != (ch = lex_getch(lex_stack)) &&
+                       isspace(ch) &&
+                       !is_EOC(ch))
+
+                        ;  // Null Statement
+
+                if (EOF == ch) {
+
+                        if ( ! lex_pop_file())
+                                return 0;
+                        token = T_EOC;
+                        goto normal_return;
+
+                } else if (is_EOC(ch)) {
+
+                        // end FOLLBY_STRINGS_TO_EOC effect
+                        followedby = FOLLBY_TOKEN;
+                        token = T_EOC;
+                        goto normal_return;
+
+                } else if (is_special(ch) && FOLLBY_TOKEN == followedby) {
+                        // special chars are their own token values
+                        token = ch;
+                        /*
+                         * '=' outside simulator configuration implies
+                         * a single string following as in:
+                         * setvar Owner = "The Boss" default
+                         */
+                        if ('=' == ch ) {
+                                followedby = FOLLBY_STRING;
+                        }
+                        yytext[0] = (char)ch;
+                        yytext[1] = '\0';
+                        goto normal_return;
+                } else
+                        lex_ungetch(ch, lex_stack);
+
+                // save the position of start of the token
+                lex_stack->tokpos = lex_stack->curpos;
+
+                // Read in the lexeme
+                i = 0;
+                while (EOF != (ch = lex_getch(lex_stack))) {
+
+                        yytext[i] = (char)ch;
+
+                        // Break on whitespace or a special character
+                        if (isspace(ch) || is_EOC(ch)
+                            || '"' == ch
+                            || (FOLLBY_TOKEN == followedby
+                                && is_special(ch)))
+                                break;
+
+                        /* Read the rest of the line on reading a start
+                           of comment character */
+                        if ('#' == ch) {
+                                while (EOF != (ch = lex_getch(lex_stack))
+                                       && '\n' != ch) {
+                                        ;  // Null Statement
+                                }
+                                break;
+                        }
+
+                        i++;
+                        if (i >= (int)COUNTOF(yytext)) {
+                                goto lex_too_long;
+                        }
+                }
+                /* Pick up all of the string inside between " marks, to
+                 * end of line.  If we make it to EOL without a
+                 * terminating " assume it for them.
+                 *
+                 * XXX - HMS: I'm not sure we want to assume the closing "
+                 */
+                if ('"' == ch) {
+                        instring = true;
+                        while (EOF != (ch = lex_getch(lex_stack)) &&
+                               ch != '"' && ch != '\n') {
+                                yytext[i++] = (char)ch;
+                                if (i >= (int)COUNTOF(yytext)) {
+                                        goto lex_too_long;
+                                }
+                        }
+                        /*
+                         * yytext[i] will be pushed back as not part of
+                         * this lexeme, but any closing quote should
+                         * not be pushed back, so we read another char.
+                         */
+                        if ('"' == ch) {
+                                ch = lex_getch(lex_stack);
+                        }
+                }
+                /* Pushback the last character read that is not a part
+                 * of this lexeme. This fails silently if ch is EOF,
+                 * but then the EOF condition persists and is handled on
+                 * the next turn by the include stack mechanism.
+                 */
+                lex_ungetch(ch, lex_stack);
+
+                yytext[i] = '\0';
+        } while (i == 0);
+
+        // Now return the desired token
+
+        /* First make sure that the parser is *not* expecting a string
+         * as the next token (based on the previous token that was
+         * returned) and that we haven't read a string.
+         */
+
+        if (followedby == FOLLBY_TOKEN && !instring) {
+                token = is_keyword(yytext, &followedby);
+                if (token) {
+                        goto normal_return;
+                } else if (is_integer(yytext)) {
+                        yylval_was_set = true;
+                        errno = 0;
+                        yylval.Integer = (int)strtol(yytext, NULL, 10);
+                        if (yylval.Integer == 0
+                            && ((errno == EINVAL) || (errno == ERANGE))) {
+                                msyslog(LOG_ERR,
+                                        "CONFIG: Integer cannot be represented: %s",
+                                        yytext);
+                                if (lex_from_file()) {
+                                        exit(1);
+                                } else {
+                                        // force end of parsing
+                                        yylval.Integer = 0;
+                                        return 0;
+                                }
+                        }
+                        token = T_Integer;
+                        goto normal_return;
+                } else if (is_u_int(yytext)) {
+                        yylval_was_set = true;
+                        if ('0' == yytext[0] &&
+                            'x' == tolower((int)yytext[1]))
+                                converted = sscanf(&yytext[2], "%x",
+                                                   &yylval.U_int);
+                        else
+                                converted = sscanf(yytext, "%u",
+                                                   &yylval.U_int);
+                        if (1 != converted) {
+                                msyslog(LOG_ERR,
+                                        "CONFIG: U_int cannot be represented: %s",
+                                        yytext);
+                                if (lex_from_file()) {
+                                        exit(1);
+                                } else {
+                                        // force end of parsing
+                                        yylval.Integer = 0;
+                                        return 0;
+                                }
+                        }
+                        token = T_U_int;
+                        goto normal_return;
+                } else if (is_double(yytext)) {
+                        double era_offset = 0;
+                        yylval_was_set = true;
+                        errno = 0;
+                        while (ERA_SUFFIX(yytext[strlen(yytext)-1])) {
+                                if (yytext[strlen(yytext)-1] == 'g') {
+                                        era_offset += GPS_ERA_10BIT;
+                                }
+                                if (yytext[strlen(yytext)-1] == 'G') {
+                                        era_offset += GPS_ERA_13BIT;
+                                }
+                                yytext[strlen(yytext)-1] = '\0';
+                        }
+                        yylval.Double = era_offset + atof(yytext);
+                        if ( D_ISZERO_NS(yylval.Double) && errno == ERANGE) {
+                            // FIXME, POSIX says atof() never returns errors
+                            msyslog(LOG_ERR,
+                                    "CONFIG: Double too large to represent: %s",
+                                    yytext);
+                            exit(1);
+                        } else {
+                            token = T_Double;
+                            goto normal_return;
+                        }
+                } else {
+                        // Default: Everything is a string
+                        yylval_was_set = true;
+                        token = create_string_token(yytext);
+                        goto normal_return;
+                }
+        }
+
+        /*
+         * Either followedby is not FOLLBY_TOKEN or this lexeme is part
+         * of a string.  Hence, we need to return T_String.
+         *
+         * _Except_ we might have a -4 or -6 flag on a an association
+         * configuration line (server, peer, pool, etc.).
+         *
+         * This is a terrible hack, but the grammar is ambiguous so we
+         * don't have a choice.  [SK]
+         *
+         * The ambiguity is in the keyword scanner, not ntp_parser.y.
+         * We do not require server addresses be quoted in ntp.conf,
+         * complicating the scanner's job.  To avoid trying (and
+         * failing) to match an IP address or DNS name to a keyword,
+         * the association keywords use FOLLBY_STRING in the keyword
+         * table, which tells the scanner to force the next token to be
+         * a T_String, so it does not try to match a keyword but rather
+         * expects a string when -4/-6 modifiers to server, peer, etc.
+         * are encountered.
+         * restrict -4 and restrict -6 parsing works correctly without
+         * this hack, as restrict uses FOLLBY_TOKEN.  [DH]
+         */
+        if ('-' == yytext[0]) {
+                if ('4' == yytext[1]) {
+                        token = T_Ipv4_flag;
+                        goto normal_return;
+                } else if ('6' == yytext[1]) {
+                        token = T_Ipv6_flag;
+                        goto normal_return;
+                }
+        }
+
+        instring = false;
+        if (FOLLBY_STRING == followedby) {
+                followedby = FOLLBY_TOKEN;
+        }
+
+        yylval_was_set = true;
+        token = create_string_token(yytext);
 
 normal_return:
-	if (T_EOC == token)
-		DPRINT(4,("\t<end of command>\n"));
-	else
-		DPRINT(4, ("yylex: lexeme '%s' -> %s\n", yytext,
-			   token_name(token)));
+        if (T_EOC == token)
+                DPRINT(4,("\t<end of command>\n"));
+        else
+                DPRINT(4, ("yylex: lexeme '%s' -> %s\n", yytext,
+                           token_name(token)));
 
-	if (!yylval_was_set)
-		yylval.Integer = token;
+        if (!yylval_was_set)
+                yylval.Integer = token;
 
-	return token;
+        return token;
 
 lex_too_long:
-	yytext[min(sizeof(yytext) - 1, 50)] = 0;
-	msyslog(LOG_ERR,
-		"CONFIG: configuration item on line %d longer than limit of %lu, began with '%s'",
-		lex_stack->curpos.nline, (unsigned long)min(sizeof(yytext) - 1, 50),
-		yytext);
-
-	/*
-	 * If we hit the length limit reading the startup configuration
-	 * file, abort.
-	 */
-	if (lex_from_file())
-		exit(sizeof(yytext) - 1);
-
-	/*
-	 * If it's runtime configuration via ntpq :config treat it as
-	 * if the configuration text ended before the too-long lexeme,
-	 * hostname, or string.
-	 */
-	yylval.Integer = 0;
-	return 0;
+        yytext[min(sizeof(yytext) - 1, 50)] = 0;
+        msyslog(LOG_ERR,
+                "CONFIG: configuration item on line %d longer than limit of %lu, began with '%s'",
+                lex_stack->curpos.nline, (unsigned long)min(sizeof(yytext) - 1, 50),
+                yytext);
+
+        /*
+         * If we hit the length limit reading the startup configuration
+         * file, abort.
+         */
+        if (lex_from_file())
+                exit(sizeof(yytext) - 1);
+
+        /*
+         * If it's runtime configuration via ntpq :config treat it as
+         * if the configuration text ended before the too-long lexeme,
+         * hostname, or string.
+         */
+        yylval.Integer = 0;
+        return 0;
 }


=====================================
ntpd/nts_server.c
=====================================
@@ -56,200 +56,200 @@ static void nts_ke_setup_send(struct BufCtl_t *buf, int aead,
 pthread_mutex_t certificate_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static int alpn_select_cb(SSL *ssl,
-			  const unsigned char **out,
-			  unsigned char *outlen,
-			  const unsigned char *in,
-			  unsigned int inlen,
-			  void *arg)
+                          const unsigned char **out,
+                          unsigned char *outlen,
+                          const unsigned char *in,
+                          unsigned int inlen,
+                          void *arg)
 {
-	static const unsigned char alpn[] = {
+        static const unsigned char alpn[] = {
             'n', 't', 's', 'k', 'e', '/', '1' };
-	unsigned i, len;
+        unsigned i, len;
 
-	UNUSED_ARG(ssl);
-	UNUSED_ARG(arg);
+        UNUSED_ARG(ssl);
+        UNUSED_ARG(arg);
 
-	for (i = 0; i < inlen; i += len+1) {
-		len = in[i]; // first byte is the length
+        for (i = 0; i < inlen; i += len+1) {
+                len = in[i]; // first byte is the length
 #if 0
-		char foo[256];
-		strlcpy(foo, (const char*)in+i+1, len);
-		msyslog(LOG_DEBUG, "DEBUG: alpn_select_cb:  %u, %u, %s", inlen-i, len, foo);
+                char foo[256];
+                strlcpy(foo, (const char*)in+i+1, len);
+                msyslog(LOG_DEBUG, "DEBUG: alpn_select_cb:  %u, %u, %s", inlen-i, len, foo);
 #endif
-		if (len+1 > inlen-i)
-			/* bogus arg: length overlaps end of in buffer */
-			return SSL_TLSEXT_ERR_ALERT_FATAL;
-		if (len == sizeof(alpn) && !memcmp(in+i+1, alpn, len)) {
-			*out = in+i+1;
-			*outlen = len;
-			return SSL_TLSEXT_ERR_OK;
-		}
-	}
-
-	return SSL_TLSEXT_ERR_NOACK;
+                if (len+1 > inlen-i)
+                        // bogus arg: length overlaps end of in buffer
+                        return SSL_TLSEXT_ERR_ALERT_FATAL;
+                if (len == sizeof(alpn) && !memcmp(in+i+1, alpn, len)) {
+                        *out = in+i+1;
+                        *outlen = len;
+                        return SSL_TLSEXT_ERR_OK;
+                }
+        }
+
+        return SSL_TLSEXT_ERR_NOACK;
 }
 
 bool nts_server_init(void) {
-	bool ok = true;
-
-	msyslog(LOG_INFO, "NTSs: starting NTS-KE server listening on port %d",
-		NTS_KE_PORT);
-
-	server_ctx = SSL_CTX_new(TLS_server_method());
-	if (NULL == server_ctx) {
-		/* Happens if no ciphers */
-		msyslog(LOG_INFO, "NTSs: NULL server_ctx");
-		nts_log_ssl_error();
-		return false;
-	}
-
-	SSL_CTX_set_alpn_select_cb(server_ctx, alpn_select_cb, NULL);
-	SSL_CTX_set_session_cache_mode(server_ctx, SSL_SESS_CACHE_OFF);
-	SSL_CTX_set_timeout(server_ctx, NTS_KE_TIMEOUT);  /* session lifetime */
-
-	ok &= nts_load_versions(server_ctx);
-	ok &= nts_load_ciphers(server_ctx);
-	ok &= nts_load_ecdhcurves(server_ctx);
-	ok &= nts_set_cipher_order(server_ctx);
-
-	if (!ok) {
-		msyslog(LOG_ERR, "NTSs: Disabling NTS-KE server");
-		SSL_CTX_free(server_ctx);
-		server_ctx = NULL;
-		return false;
-	};
-
-	msyslog(LOG_INFO, "NTSs: OpenSSL security level is %d",
-		SSL_CTX_get_security_level(server_ctx));
-
-	msyslog(LOG_INFO, "NTSs: starting NTS-KE server listening on port %d",
-		NTS_KE_PORT);
-	ok &= create_listener4(NTS_KE_PORT);
-	ok &= create_listener6(NTS_KE_PORT);
-
-	return ok;
+        bool ok = true;
+
+        msyslog(LOG_INFO, "NTSs: starting NTS-KE server listening on port %d",
+                NTS_KE_PORT);
+
+        server_ctx = SSL_CTX_new(TLS_server_method());
+        if (NULL == server_ctx) {
+                // Happens if no ciphers
+                msyslog(LOG_INFO, "NTSs: NULL server_ctx");
+                nts_log_ssl_error();
+                return false;
+        }
+
+        SSL_CTX_set_alpn_select_cb(server_ctx, alpn_select_cb, NULL);
+        SSL_CTX_set_session_cache_mode(server_ctx, SSL_SESS_CACHE_OFF);
+        SSL_CTX_set_timeout(server_ctx, NTS_KE_TIMEOUT);  // session lifetime
+
+        ok &= nts_load_versions(server_ctx);
+        ok &= nts_load_ciphers(server_ctx);
+        ok &= nts_load_ecdhcurves(server_ctx);
+        ok &= nts_set_cipher_order(server_ctx);
+
+        if (!ok) {
+                msyslog(LOG_ERR, "NTSs: Disabling NTS-KE server");
+                SSL_CTX_free(server_ctx);
+                server_ctx = NULL;
+                return false;
+        };
+
+        msyslog(LOG_INFO, "NTSs: OpenSSL security level is %d",
+                SSL_CTX_get_security_level(server_ctx));
+
+        msyslog(LOG_INFO, "NTSs: starting NTS-KE server listening on port %d",
+                NTS_KE_PORT);
+        ok &= create_listener4(NTS_KE_PORT);
+        ok &= create_listener6(NTS_KE_PORT);
+
+        return ok;
 }
 
 bool nts_server_init2(void) {
-	pthread_t worker;
-	sigset_t block_mask, saved_sig_mask;
-	int rc;
-	char errbuf[100];
-
-	if (!nts_load_certificate(server_ctx)) {
-		return false;
-	}
-
-	sigfillset(&block_mask);
-	pthread_sigmask(SIG_BLOCK, &block_mask, &saved_sig_mask);
-	if (listener4_sock != -1) {
-		rc = pthread_create(&worker, NULL, nts_ke_listener, &listener4_sock);
-		if (rc) {
-			ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-			msyslog(LOG_ERR, "NTSs: nts_start_server4: error from pthread_create: %s", errbuf);
-		}
-	}
-	if (listener6_sock != -1) {
-		rc = pthread_create(&worker, NULL, nts_ke_listener, &listener6_sock);
-		if (rc) {
-			ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-			msyslog(LOG_ERR, "NTSs: nts_start_server6: error from pthread_create: %s", errbuf);
-		}
-	}
-	pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
-
-	return true;
+        pthread_t worker;
+        sigset_t block_mask, saved_sig_mask;
+        int rc;
+        char errbuf[100];
+
+        if (!nts_load_certificate(server_ctx)) {
+                return false;
+        }
+
+        sigfillset(&block_mask);
+        pthread_sigmask(SIG_BLOCK, &block_mask, &saved_sig_mask);
+        if (listener4_sock != -1) {
+                rc = pthread_create(&worker, NULL, nts_ke_listener, &listener4_sock);
+                if (rc) {
+                        ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                        msyslog(LOG_ERR, "NTSs: nts_start_server4: error from pthread_create: %s", errbuf);
+                }
+        }
+        if (listener6_sock != -1) {
+                rc = pthread_create(&worker, NULL, nts_ke_listener, &listener6_sock);
+                if (rc) {
+                        ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                        msyslog(LOG_ERR, "NTSs: nts_start_server6: error from pthread_create: %s", errbuf);
+                }
+        }
+        pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
+
+        return true;
 }
 
-/* called every hour */
+// called every hour
 void nts_cert_timer(void) {
-	check_cert_file();
+        check_cert_file();
 }
 
-/* call hourly and by SIGHUP */
+// call hourly and by SIGHUP
 void check_cert_file(void) {
-	if (NULL == server_ctx)
-		return;
-	nts_lock_certlock();
-	nts_reload_certificate(server_ctx);
-	nts_unlock_certlock();
+        if (NULL == server_ctx)
+                return;
+        nts_lock_certlock();
+        nts_reload_certificate(server_ctx);
+        nts_unlock_certlock();
 }
 
 void nts_lock_certlock(void) {
-	int err = pthread_mutex_lock(&certificate_lock);
-	if (0 != err) {
-		msyslog(LOG_ERR, "ERR: Can't lock certificate_lock: %d", err);
-		exit(2);
-	}
+        int err = pthread_mutex_lock(&certificate_lock);
+        if (0 != err) {
+                msyslog(LOG_ERR, "ERR: Can't lock certificate_lock: %d", err);
+                exit(2);
+        }
 }
 
 void nts_unlock_certlock(void) {
-	int err = pthread_mutex_unlock(&certificate_lock);
-	if (0 != err) {
-		msyslog(LOG_ERR, "ERR: Can't unlock certificate_lock: %d", err);
-		exit(2);
-	}
+        int err = pthread_mutex_unlock(&certificate_lock);
+        if (0 != err) {
+                msyslog(LOG_ERR, "ERR: Can't unlock certificate_lock: %d", err);
+                exit(2);
+        }
 }
 
-/* lfptod goes to long double */
+// lfptod goes to long double
 static inline double lfptox(l_fp r) {
-/* l_fp to double */
+// l_fp to double
         return ldexp((double)((int64_t)r), -32);
 }
 
 
 void* nts_ke_listener(void* arg) {
-	struct timeval timeout = {.tv_sec = NTS_KE_TIMEOUT, .tv_usec = 0};
-	int sock = *(int*)arg;
-	char errbuf[100];
-	char addrbuf[100];
-	char usingbuf[100];
-	struct timespec start, finish;		/* wall clock */
-	l_fp wall, usr, sys;
-	const char *errtxt;	/* not NULL if error */
+        struct timeval timeout = {.tv_sec = NTS_KE_TIMEOUT, .tv_usec = 0};
+        int sock = *(int*)arg;
+        char errbuf[100];
+        char addrbuf[100];
+        char usingbuf[100];
+        struct timespec start, finish;          // wall clock
+        l_fp wall, usr, sys;
+        const char *errtxt;     // not NULL if error
 #ifdef RUSAGE_THREAD
-	/* Not in NetBSD 10.1, 2026-Apr-05 */
-	struct timespec start_u, finish_u;	/* CPU user */
-	struct timespec start_s, finish_s;	/* CPU system */
-	struct rusage usage;
+        // Not in NetBSD 10.1, 2026-Apr-05
+        struct timespec start_u, finish_u;      // CPU user
+        struct timespec start_s, finish_s;      // CPU system
+        struct rusage usage;
 #endif
 
 #ifdef HAVE_SECCOMP_H
-        setup_SIGSYS_trap();   /* enable trap for this thread */
+        setup_SIGSYS_trap();   // enable trap for this thread
 #endif
 
 #ifdef RUSAGE_THREAD
-	/* NB: start_u and start_s are from near the end of the previous cycle.
-	 * Thus usage timing includes the TCP accept and
-	 * writing the previous msyslog message.
-	 */
-	getrusage(RUSAGE_THREAD, &usage);
-	start_u = tval_to_tspec(usage.ru_utime);
-	start_s = tval_to_tspec(usage.ru_stime);
+        /* NB: start_u and start_s are from near the end of the previous cycle.
+         * Thus usage timing includes the TCP accept and
+         * writing the previous msyslog message.
+         */
+        getrusage(RUSAGE_THREAD, &usage);
+        start_u = tval_to_tspec(usage.ru_utime);
+        start_s = tval_to_tspec(usage.ru_stime);
 #else
-	usr = 0;
-	sys = 0;
+        usr = 0;
+        sys = 0;
 #endif
 
-	while(1) {
-		NTSKE_Status status = NTSKE_SSL_Failed;
-		sockaddr_u addr;
-		socklen_t len = sizeof(addr);
-		SSL *ssl;
-		int client, err;
-
-		sleep(1);			/* FIXME: log clutter/DoS */
-		errtxt = NULL;
-		client = accept(sock, &addr.sa, &len);
-		if (client < 0) {
-			ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-			msyslog(LOG_ERR, "NTSs: TCP accept failed: %s", errbuf);
-			if (EBADF == errno)
-				return NULL;
-			continue;
-		}
-		clock_gettime(CLOCK_MONOTONIC, &start);
-		sockporttoa_r(&addr, addrbuf, sizeof(addrbuf));
+        while(1) {
+                NTSKE_Status status = NTSKE_SSL_Failed;
+                sockaddr_u addr;
+                socklen_t len = sizeof(addr);
+                SSL *ssl;
+                int client, err;
+
+                sleep(1);                       // FIXME: log clutter/DoS
+                errtxt = NULL;
+                client = accept(sock, &addr.sa, &len);
+                if (client < 0) {
+                        ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                        msyslog(LOG_ERR, "NTSs: TCP accept failed: %s", errbuf);
+                        if (EBADF == errno)
+                                return NULL;
+                        continue;
+                }
+                clock_gettime(CLOCK_MONOTONIC, &start);
+                sockporttoa_r(&addr, addrbuf, sizeof(addrbuf));
 
 /* This is disabled in order to reduce clutter in the log file.
  * The client's address is now included in the final message.
@@ -266,85 +266,85 @@ void* nts_ke_listener(void* arg) {
  * fall into the normal (non-error) path which does include the address.
  * Enabling this might make strange cases easier to understand.
  */
-/*		msyslog(LOG_INFO, "NTSs: TCP accept-ed from %s", addrbuf); */
-
-		err = setsockopt(client, SOL_SOCKET, SO_RCVTIMEO,
-			&timeout, sizeof(timeout));
-		if (0 > err) {
-			ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-			msyslog(LOG_ERR, "NTSs: can't set recv timeout: %s", errbuf);
-			close(client);
-			ntske_cnt.serves_bad++;
-			continue;
-		}
-		err = setsockopt(client, SOL_SOCKET, SO_SNDTIMEO,
-			&timeout, sizeof(timeout));
-		if (0 > err) {
-			ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-			msyslog(LOG_ERR, "NTSs: can't set send timeout: %s", errbuf);
-			close(client);
-			ntske_cnt.serves_bad++;
-			continue;
-		}
-
-		/* WARN: For high volume servers, this should go in a new thread. */
-		nts_lock_certlock();
-		ssl = SSL_new(server_ctx);
-		nts_unlock_certlock();
-		SSL_set_fd(ssl, client);
-
-		err = SSL_accept(ssl);
-		if (0 >= err) {
-			int code = SSL_get_error(ssl, err);
-			SSL_free(ssl);
-			close(client);
-			clock_gettime(CLOCK_MONOTONIC, &finish);
-			wall = tspec_intv_to_lfp(sub_tspec(finish, start));
+// msyslog(LOG_INFO, "NTSs: TCP accept-ed from %s", addrbuf);
+
+                err = setsockopt(client, SOL_SOCKET, SO_RCVTIMEO,
+                        &timeout, sizeof(timeout));
+                if (0 > err) {
+                        ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                        msyslog(LOG_ERR, "NTSs: can't set recv timeout: %s", errbuf);
+                        close(client);
+                        ntske_cnt.serves_bad++;
+                        continue;
+                }
+                err = setsockopt(client, SOL_SOCKET, SO_SNDTIMEO,
+                        &timeout, sizeof(timeout));
+                if (0 > err) {
+                        ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                        msyslog(LOG_ERR, "NTSs: can't set send timeout: %s", errbuf);
+                        close(client);
+                        ntske_cnt.serves_bad++;
+                        continue;
+                }
+
+                // WARN: For high volume servers, this should go in a new thread.
+                nts_lock_certlock();
+                ssl = SSL_new(server_ctx);
+                nts_unlock_certlock();
+                SSL_set_fd(ssl, client);
+
+                err = SSL_accept(ssl);
+                if (0 >= err) {
+                        int code = SSL_get_error(ssl, err);
+                        SSL_free(ssl);
+                        close(client);
+                        clock_gettime(CLOCK_MONOTONIC, &finish);
+                        wall = tspec_intv_to_lfp(sub_tspec(finish, start));
 #ifdef RUSAGE_THREAD
-			getrusage(RUSAGE_THREAD, &usage);
-			finish_u = tval_to_tspec(usage.ru_utime);
-			finish_s = tval_to_tspec(usage.ru_stime);
-			usr = tspec_intv_to_lfp(sub_tspec(finish_u, start_u));
-			sys = tspec_intv_to_lfp(sub_tspec(finish_s, start_s));
-			start_u = finish_u;
-			start_s = finish_s;
+                        getrusage(RUSAGE_THREAD, &usage);
+                        finish_u = tval_to_tspec(usage.ru_utime);
+                        finish_s = tval_to_tspec(usage.ru_stime);
+                        usr = tspec_intv_to_lfp(sub_tspec(finish_u, start_u));
+                        sys = tspec_intv_to_lfp(sub_tspec(finish_s, start_s));
+                        start_u = finish_u;
+                        start_s = finish_s;
 #endif
-			nts_ke_accept_fail(addrbuf,
-			  lfptox(wall), lfptox(usr), lfptox(sys), code);
-			continue;
-		}
-
-		/* Save info for final message. */
-		snprintf(usingbuf, sizeof(usingbuf), "%s:%s(%d)",
-			SSL_get_version(ssl),
-			SSL_get_cipher_name(ssl),
-			SSL_get_cipher_bits(ssl, NULL));
-
-		status = NTSKE_Failed;
-		nts_ke_request(ssl, errbuf, sizeof(errbuf), &errtxt);
-		if (NULL==errtxt) status = NTSKE_OK;
-
-		SSL_shutdown(ssl);
-		SSL_free(ssl);
-		close(client);
-
-		clock_gettime(CLOCK_MONOTONIC, &finish);
-		wall = tspec_intv_to_lfp(sub_tspec(finish, start));
+                        nts_ke_accept_fail(addrbuf,
+                          lfptox(wall), lfptox(usr), lfptox(sys), code);
+                        continue;
+                }
+
+                // Save info for final message.
+                snprintf(usingbuf, sizeof(usingbuf), "%s:%s(%d)",
+                        SSL_get_version(ssl),
+                        SSL_get_cipher_name(ssl),
+                        SSL_get_cipher_bits(ssl, NULL));
+
+                status = NTSKE_Failed;
+                nts_ke_request(ssl, errbuf, sizeof(errbuf), &errtxt);
+                if (NULL==errtxt) status = NTSKE_OK;
+
+                SSL_shutdown(ssl);
+                SSL_free(ssl);
+                close(client);
+
+                clock_gettime(CLOCK_MONOTONIC, &finish);
+                wall = tspec_intv_to_lfp(sub_tspec(finish, start));
 #ifdef RUSAGE_THREAD
-		getrusage(RUSAGE_THREAD, &usage);
-		finish_u = tval_to_tspec(usage.ru_utime);
-		finish_s = tval_to_tspec(usage.ru_stime);
-		usr = tspec_intv_to_lfp(sub_tspec(finish_u, start_u));
-		sys = tspec_intv_to_lfp(sub_tspec(finish_s, start_s));
-		start_u = finish_u;
-		start_s = finish_s;
+                getrusage(RUSAGE_THREAD, &usage);
+                finish_u = tval_to_tspec(usage.ru_utime);
+                finish_s = tval_to_tspec(usage.ru_stime);
+                usr = tspec_intv_to_lfp(sub_tspec(finish_u, start_u));
+                sys = tspec_intv_to_lfp(sub_tspec(finish_s, start_s));
+                start_u = finish_u;
+                start_s = finish_s;
 #endif
-		record_ntske_log(status, addrbuf, usingbuf,
-		  lfptox(wall), lfptox(usr), lfptox(sys),
-		  errtxt);
-	}
+                record_ntske_log(status, addrbuf, usingbuf,
+                  lfptox(wall), lfptox(usr), lfptox(sys),
+                  errtxt);
+        }
 
-	return NULL;
+        return NULL;
 }
 
 /* Analyze failure from SSL_accept
@@ -353,329 +353,329 @@ void* nts_ke_listener(void* arg) {
  */
 void nts_ke_accept_fail(char* hostname,
     double wall, double usr, double sys, int code) {
-	unsigned long err = ERR_peek_error();
-	char errbuf[100];
-	char buff[200];
-	const char *msg = NULL;
-	const char *errmsg = NULL;
-	if (0 == err) {
-	  switch (code) {
-	    case SSL_ERROR_WANT_READ:
-	      msg = "Timeout";
-	      break;
-	    case SSL_ERROR_SYSCALL:
-	      if (ECONNRESET==errno) {
-	        msg = "Connection reset";
-	        break;
-	      }
-	      /* fall through */
-	    default:
-	      ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-	      snprintf(buff, sizeof(buff), "code %d, errno=>%d, %s",
-		code, errno, errbuf);
-	      msg = buff;
-	      break;
-	  }
-	} else {
-	  if (code==SSL_ERROR_SSL) {
-	    msg = ERR_reason_error_string(err);
-	    err = 0;
-	  } else {
-	    // Maybe we need to handle other codes
-	    ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-	    snprintf(buff, sizeof(buff), "code %d, errno=>%d, %s, %lx=>%s",
-	      code, errno, errbuf, err, ERR_reason_error_string(err));
-	    err = 0;
-	    msg = buff;
-	  }
-	}
-	record_ntske_log(NTSKE_SSL_Failed, hostname, msg,
-		wall, usr, sys, errmsg);
+        unsigned long err = ERR_peek_error();
+        char errbuf[100];
+        char buff[200];
+        const char *msg = NULL;
+        const char *errmsg = NULL;
+        if (0 == err) {
+          switch (code) {
+            case SSL_ERROR_WANT_READ:
+              msg = "Timeout";
+              break;
+            case SSL_ERROR_SYSCALL:
+              if (ECONNRESET==errno) {
+                msg = "Connection reset";
+                break;
+              }
+              // fall through
+            default:
+              ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+              snprintf(buff, sizeof(buff), "code %d, errno=>%d, %s",
+                code, errno, errbuf);
+              msg = buff;
+              break;
+          }
+        } else {
+          if (code==SSL_ERROR_SSL) {
+            msg = ERR_reason_error_string(err);
+            err = 0;
+          } else {
+            // Maybe we need to handle other codes
+            ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+            snprintf(buff, sizeof(buff), "code %d, errno=>%d, %s, %lx=>%s",
+              code, errno, errbuf, err, ERR_reason_error_string(err));
+            err = 0;
+            msg = buff;
+          }
+        }
+        record_ntske_log(NTSKE_SSL_Failed, hostname, msg,
+                wall, usr, sys, errmsg);
 }
 
 
 void nts_ke_request(SSL *ssl,
   char *errbuf, int errlng, const char **errtxt) {
-	/* RFC 4: servers must accept 1024
-	 * Our cookies can be 104, 136, or 168 for AES_SIV_CMAC_xxx
-	 * 8*168 fits comfortably into 2K.
-	 */
-	uint8_t buff[2048];
-	uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
-	int aead = NO_AEAD, keylen;
-	struct BufCtl_t buf;
-	int bytes_read, bytes_written;
-	int used;
-
-	bytes_read = nts_ssl_read(ssl, buff, sizeof(buff), errtxt);
-	if (0 >= bytes_read)
-		return;
-
-	buf.next = buff;
-	buf.left = bytes_read;
-	if (!nts_ke_process_receive(&buf, &aead, errbuf, errlng, errtxt)) {
-		return;
-	}
-
-	if ((NO_AEAD == aead) && (NULL != ntsconfig.aead))
-		aead = nts_string_to_aead(ntsconfig.aead);
-	if (NO_AEAD == aead)
-		aead = AEAD_AES_SIV_CMAC_256;    /* default */
-
-	keylen = nts_get_key_length(aead);
-	if (!nts_make_keys(ssl, aead, c2s, s2c, keylen)) {
-		*errtxt = "Can't make keys";
-		return;
-	}
-
-	buf.next = buff;
-	buf.left = sizeof(buff);
-	nts_ke_setup_send(&buf, aead, c2s, s2c, keylen);
-
-	used = sizeof(buff)-buf.left;
-	bytes_written = nts_ssl_write(ssl, buff, used, errtxt);
-	if (bytes_written != used)
-		return;
-
-/* FIXME: Need counters for AEAD */
-
-	return;
+        /* RFC 4: servers must accept 1024
+         * Our cookies can be 104, 136, or 168 for AES_SIV_CMAC_xxx
+         * 8*168 fits comfortably into 2K.
+         */
+        uint8_t buff[2048];
+        uint8_t c2s[NTS_MAX_KEYLEN], s2c[NTS_MAX_KEYLEN];
+        int aead = NO_AEAD, keylen;
+        struct BufCtl_t buf;
+        int bytes_read, bytes_written;
+        int used;
+
+        bytes_read = nts_ssl_read(ssl, buff, sizeof(buff), errtxt);
+        if (0 >= bytes_read)
+                return;
+
+        buf.next = buff;
+        buf.left = bytes_read;
+        if (!nts_ke_process_receive(&buf, &aead, errbuf, errlng, errtxt)) {
+                return;
+        }
+
+        if ((NO_AEAD == aead) && (NULL != ntsconfig.aead))
+                aead = nts_string_to_aead(ntsconfig.aead);
+        if (NO_AEAD == aead)
+                aead = AEAD_AES_SIV_CMAC_256;    // default
+
+        keylen = nts_get_key_length(aead);
+        if (!nts_make_keys(ssl, aead, c2s, s2c, keylen)) {
+                *errtxt = "Can't make keys";
+                return;
+        }
+
+        buf.next = buff;
+        buf.left = sizeof(buff);
+        nts_ke_setup_send(&buf, aead, c2s, s2c, keylen);
+
+        used = sizeof(buff)-buf.left;
+        bytes_written = nts_ssl_write(ssl, buff, used, errtxt);
+        if (bytes_written != used)
+                return;
+
+// FIXME: Need counters for AEAD
+
+        return;
 }
 
 bool create_listener4(int port) {
-	int sock = -1;
-	sockaddr_u addr;
-	int on = 1;
-	int err;
-	char errbuf[100];
-
-	addr.sa4.sin_family = AF_INET;
-	addr.sa4.sin_port = htons(port);
-	addr.sa4.sin_addr.s_addr= htonl(INADDR_ANY);
-	sock = socket(AF_INET, SOCK_STREAM, 0);
-	if (sock < 0) {
-		if (EAFNOSUPPORT == errno) {
-			msyslog(LOG_ERR, "NTSs: No IPv4 support, disabling NTS-KE listener");
-			return true;
-		}
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: Can't create socket4: %s", errbuf);
-		return false;
-	}
-	err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
-	if (0 > err) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't setsockopt4: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	err = bind(sock, &addr.sa, sizeof(addr.sa4));
-	if (0 > err) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't bind4: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	if (listen(sock, 6) < 0) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't listen4: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	msyslog(LOG_INFO, "NTSs: listen4 worked");
-
-	listener4_sock = sock;
-	return true;
+        int sock = -1;
+        sockaddr_u addr;
+        int on = 1;
+        int err;
+        char errbuf[100];
+
+        addr.sa4.sin_family = AF_INET;
+        addr.sa4.sin_port = htons(port);
+        addr.sa4.sin_addr.s_addr= htonl(INADDR_ANY);
+        sock = socket(AF_INET, SOCK_STREAM, 0);
+        if (sock < 0) {
+                if (EAFNOSUPPORT == errno) {
+                        msyslog(LOG_ERR, "NTSs: No IPv4 support, disabling NTS-KE listener");
+                        return true;
+                }
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: Can't create socket4: %s", errbuf);
+                return false;
+        }
+        err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+        if (0 > err) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't setsockopt4: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        err = bind(sock, &addr.sa, sizeof(addr.sa4));
+        if (0 > err) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't bind4: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        if (listen(sock, 6) < 0) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't listen4: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        msyslog(LOG_INFO, "NTSs: listen4 worked");
+
+        listener4_sock = sock;
+        return true;
 }
 
 bool create_listener6(int port) {
-	int sock = -1;
-	sockaddr_u addr;
-	int on = 1;
-	int err;
-	char errbuf[100];
-
-	addr.sa6.sin6_family = AF_INET6;
-	addr.sa6.sin6_port = htons(port);
-	addr.sa6.sin6_addr = in6addr_any;
-	sock = socket(AF_INET6, SOCK_STREAM, 0);
-	if (sock < 0) {
-		if (EAFNOSUPPORT == errno) {
-			msyslog(LOG_ERR, "NTSs: No IPv6 support, disabling NTS-KE listener");
-			return true;
-		}
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: Can't create socket6: %s", errbuf);
-		return false;
-	}
-	/* Hack to keep IPV6 from listening on IPV4 too */
-	err = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
-	if (0 > err) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't setsockopt6only: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
-	if (0 > err) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't setsockopt6: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	err = bind(sock, &addr.sa, sizeof(addr.sa6));
-	if (0 > err) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't bind6: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	if (listen(sock, 6) < 0) {
-		ntp_strerror_r(errno, errbuf, sizeof(errbuf));
-		msyslog(LOG_ERR, "NTSs: can't listen6: %s", errbuf);
-		close(sock);
-		return false;
-	}
-	msyslog(LOG_INFO, "NTSs: listen6 worked");
-
-	listener6_sock = sock;
-	return true;
+        int sock = -1;
+        sockaddr_u addr;
+        int on = 1;
+        int err;
+        char errbuf[100];
+
+        addr.sa6.sin6_family = AF_INET6;
+        addr.sa6.sin6_port = htons(port);
+        addr.sa6.sin6_addr = in6addr_any;
+        sock = socket(AF_INET6, SOCK_STREAM, 0);
+        if (sock < 0) {
+                if (EAFNOSUPPORT == errno) {
+                        msyslog(LOG_ERR, "NTSs: No IPv6 support, disabling NTS-KE listener");
+                        return true;
+                }
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: Can't create socket6: %s", errbuf);
+                return false;
+        }
+        // Hack to keep IPV6 from listening on IPV4 too
+        err = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
+        if (0 > err) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't setsockopt6only: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+        if (0 > err) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't setsockopt6: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        err = bind(sock, &addr.sa, sizeof(addr.sa6));
+        if (0 > err) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't bind6: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        if (listen(sock, 6) < 0) {
+                ntp_strerror_r(errno, errbuf, sizeof(errbuf));
+                msyslog(LOG_ERR, "NTSs: can't listen6: %s", errbuf);
+                close(sock);
+                return false;
+        }
+        msyslog(LOG_INFO, "NTSs: listen6 worked");
+
+        listener6_sock = sock;
+        return true;
 }
 
 bool nts_ke_process_receive(struct BufCtl_t *buf, int *aead,
   char *errbuf, int errlng, const char **errtxt) {
-	while (buf->left >= NTS_KE_HDR_LNG) {
-		uint16_t type, data;
-		int length;
-		bool critical = false;
-		type = ke_next_record(buf, &length);
+        while (buf->left >= NTS_KE_HDR_LNG) {
+                uint16_t type, data;
+                int length;
+                bool critical = false;
+                type = ke_next_record(buf, &length);
                 if (length > buf->left) {
-			snprintf(errbuf, errlng,
-				"Chunk too big: 0x%x, %d, %d",
+                        snprintf(errbuf, errlng,
+                                "Chunk too big: 0x%x, %d, %d",
                                 type, buf->left, length);
-			*errtxt = errbuf;
+                        *errtxt = errbuf;
                         return false;
                 }
-		if (NTS_CRITICAL & type) {
-			critical = true;
-			type &= ~NTS_CRITICAL;
-		}
-		if (0) // Handy for debugging but very verbose
-			msyslog(LOG_INFO, "NTSs: Record: T=%d, L=%d, C=%d", type, length, critical);
-		switch (type) {
-		    case nts_error:
-			if (sizeof(data) != length) {
-				snprintf(errbuf, errlng,
-					"Wrong length on error: %d", length);
-				*errtxt = errbuf;
-				return false;
-			}
-			data = next_uint16(buf);
-			snprintf(errbuf, errlng,
-				"Received error: %d", data);
-			*errtxt = errbuf;
-			return false;
-		    case nts_next_protocol_negotiation:
-			if (sizeof(data) != length) {
-				snprintf(errbuf, errlng,
-					"NPN-Wrong length: %d", length);
-				*errtxt = errbuf;
-				return false;
-			}
-			data = next_uint16(buf);
-			if (data != nts_protocol_NTP) {
-				snprintf(errbuf, errlng,
-					"NPN-Bad data: %d", data);
-				*errtxt = errbuf;
-				return false;
-			}
-			break;
-		    case nts_algorithm_negotiation:
-			if (length % sizeof(uint16_t) > 0) {
-				snprintf(errbuf, errlng,
-					"AN-Wrong length: %d", length);
-				*errtxt = errbuf;
-				return false;
-			}
-			for (int i=0; i<length; i+=sizeof(uint16_t)) {
-				data = next_uint16(buf);
-				if (0 == nts_get_key_length(data)) {
-					if (0)  /* for debugging */
-						msyslog(LOG_ERR, "NTSs: AN-Unsupported AEAN type: %d", data);
-					continue;     /* ignore types we don't support */
-				}
-				if (*aead != NO_AEAD)
-					continue;     /* already got one */
-				*aead = data;   /* take this one */
-			}
-			break;
-		    case nts_end_of_message:
-			if ((0 != length) || !critical) {
-				snprintf(errbuf, errlng,
-					"EOM-Wrong length or not Critical: %d, %d",
-					length, critical);
-				*errtxt = errbuf;
-				return false;
-			}
-			if (0 != buf->left) {
-				snprintf(errbuf, errlng,
-					"EOM not at end: %d", buf->left);
-				*errtxt = errbuf;
-				return false;
-			}
-			return true;
-		    default:
-			if (critical) {
-			  // This only logs the first one from a connection
-			  snprintf(errbuf, errlng,
-				"Received strange type: T=%d, C=%d, L=%d",
-				type, critical, length);
-			  // There is an error code for this
-			  return false;
-			}
-			// It might be interesting to log non-critical
-			// but that needs rate limiting
-			buf->next += length;
-			buf->left -= length;
-			break;
-		} /* case */
-	}   /* while */
-
-	/* If we get here, we ran off the end without finding an EOM.
-	 * nts_ssl_read() should have complained, so this check
-	 * should never happen.
-	 */
-	if (buf->left > 0) {
-		*errtxt = "*** Leftovers";
-		return false;
- 	}
-
-	*errtxt = "*** Missing EOM";
-	return false;
+                if (NTS_CRITICAL & type) {
+                        critical = true;
+                        type &= ~NTS_CRITICAL;
+                }
+                if (0) // Handy for debugging but very verbose
+                        msyslog(LOG_INFO, "NTSs: Record: T=%d, L=%d, C=%d", type, length, critical);
+                switch (type) {
+                    case nts_error:
+                        if (sizeof(data) != length) {
+                                snprintf(errbuf, errlng,
+                                        "Wrong length on error: %d", length);
+                                *errtxt = errbuf;
+                                return false;
+                        }
+                        data = next_uint16(buf);
+                        snprintf(errbuf, errlng,
+                                "Received error: %d", data);
+                        *errtxt = errbuf;
+                        return false;
+                    case nts_next_protocol_negotiation:
+                        if (sizeof(data) != length) {
+                                snprintf(errbuf, errlng,
+                                        "NPN-Wrong length: %d", length);
+                                *errtxt = errbuf;
+                                return false;
+                        }
+                        data = next_uint16(buf);
+                        if (data != nts_protocol_NTP) {
+                                snprintf(errbuf, errlng,
+                                        "NPN-Bad data: %d", data);
+                                *errtxt = errbuf;
+                                return false;
+                        }
+                        break;
+                    case nts_algorithm_negotiation:
+                        if (length % sizeof(uint16_t) > 0) {
+                                snprintf(errbuf, errlng,
+                                        "AN-Wrong length: %d", length);
+                                *errtxt = errbuf;
+                                return false;
+                        }
+                        for (int i=0; i<length; i+=sizeof(uint16_t)) {
+                                data = next_uint16(buf);
+                                if (0 == nts_get_key_length(data)) {
+                                        if (0)  // for debugging
+                                                msyslog(LOG_ERR, "NTSs: AN-Unsupported AEAN type: %d", data);
+                                        continue;     // ignore types we don't support
+                                }
+                                if (*aead != NO_AEAD)
+                                        continue;     // already got one
+                                *aead = data;   // take this one
+                        }
+                        break;
+                    case nts_end_of_message:
+                        if ((0 != length) || !critical) {
+                                snprintf(errbuf, errlng,
+                                        "EOM-Wrong length or not Critical: %d, %d",
+                                        length, critical);
+                                *errtxt = errbuf;
+                                return false;
+                        }
+                        if (0 != buf->left) {
+                                snprintf(errbuf, errlng,
+                                        "EOM not at end: %d", buf->left);
+                                *errtxt = errbuf;
+                                return false;
+                        }
+                        return true;
+                    default:
+                        if (critical) {
+                          // This only logs the first one from a connection
+                          snprintf(errbuf, errlng,
+                                "Received strange type: T=%d, C=%d, L=%d",
+                                type, critical, length);
+                          // There is an error code for this
+                          return false;
+                        }
+                        // It might be interesting to log non-critical
+                        // but that needs rate limiting
+                        buf->next += length;
+                        buf->left -= length;
+                        break;
+                }  // case
+        }   // while
+
+        /* If we get here, we ran off the end without finding an EOM.
+         * nts_ssl_read() should have complained, so this check
+         * should never happen.
+         */
+        if (buf->left > 0) {
+                *errtxt = "*** Leftovers";
+                return false;
+        }
+
+        *errtxt = "*** Missing EOM";
+        return false;
 
 }
 
 void nts_ke_setup_send(struct BufCtl_t *buf, int aead,
        uint8_t *c2s, uint8_t *s2c, int keylen) {
 
-	/* 4.1.2 Next Protocol */
-	ke_append_record_uint16(buf,
-				NTS_CRITICAL+nts_next_protocol_negotiation, nts_protocol_NTP);
-	/* 4.1.5 AEAD Algorithm List */
-	ke_append_record_uint16(buf, nts_algorithm_negotiation, aead);
+        // 4.1.2 Next Protocol
+        ke_append_record_uint16(buf,
+                                NTS_CRITICAL+nts_next_protocol_negotiation, nts_protocol_NTP);
+        // 4.1.5 AEAD Algorithm List
+        ke_append_record_uint16(buf, nts_algorithm_negotiation, aead);
 
-	if (extra_port)
-	        ke_append_record_uint16(buf, nts_port_negotiation, extra_port);
+        if (extra_port)
+                ke_append_record_uint16(buf, nts_port_negotiation, extra_port);
 
 
-	for (int i=0; i<NTS_MAX_COOKIES; i++) {
-		uint8_t cookie[NTS_MAX_COOKIELEN];
-		int cookielen = nts_make_cookie(cookie, aead, c2s, s2c, keylen);
-		ke_append_record_bytes(buf, nts_new_cookie, cookie, cookielen);
-	}
+        for (int i=0; i<NTS_MAX_COOKIES; i++) {
+                uint8_t cookie[NTS_MAX_COOKIELEN];
+                int cookielen = nts_make_cookie(cookie, aead, c2s, s2c, keylen);
+                ke_append_record_bytes(buf, nts_new_cookie, cookie, cookielen);
+        }
 
-	/* 4.1.1: End, Critical */
-	ke_append_record_null(buf, NTS_CRITICAL+nts_end_of_message);
+        // 4.1.1: End, Critical
+        ke_append_record_null(buf, NTS_CRITICAL+nts_end_of_message);
 }
 
-/* end */
+// end


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

=====================================
tests/ntpd/nts.c
=====================================
@@ -15,405 +15,405 @@ TEST_SETUP(nts) {}
 TEST_TEAR_DOWN(nts) {}
 
 TEST(nts, nts_translate_version) {
-	TEST_ASSERT_EQUAL_INT32(0, nts_translate_version(NULL));
-	TEST_ASSERT_EQUAL_INT32(TLS1_3_VERSION, nts_translate_version("TLS1.3"));
-	TEST_ASSERT_EQUAL_INT32(-1, nts_translate_version("blah"));
+        TEST_ASSERT_EQUAL_INT32(0, nts_translate_version(NULL));
+        TEST_ASSERT_EQUAL_INT32(TLS1_3_VERSION, nts_translate_version("TLS1.3"));
+        TEST_ASSERT_EQUAL_INT32(-1, nts_translate_version("blah"));
 }
 
 TEST(nts, nts_string_to_aead) {
-	TEST_ASSERT_EQUAL_INT16(AEAD_AES_SIV_CMAC_256,
-				nts_string_to_aead("AES_SIV_CMAC_256"));
-	TEST_ASSERT_EQUAL_INT16(AEAD_AES_SIV_CMAC_384,
-				nts_string_to_aead("AES_SIV_CMAC_384"));
-	TEST_ASSERT_EQUAL_INT16(AEAD_AES_SIV_CMAC_512,
-				nts_string_to_aead("AES_SIV_CMAC_512"));
-	TEST_ASSERT_EQUAL_INT16(NO_AEAD, nts_string_to_aead("blah"));
+        TEST_ASSERT_EQUAL_INT16(AEAD_AES_SIV_CMAC_256,
+                                nts_string_to_aead("AES_SIV_CMAC_256"));
+        TEST_ASSERT_EQUAL_INT16(AEAD_AES_SIV_CMAC_384,
+                                nts_string_to_aead("AES_SIV_CMAC_384"));
+        TEST_ASSERT_EQUAL_INT16(AEAD_AES_SIV_CMAC_512,
+                                nts_string_to_aead("AES_SIV_CMAC_512"));
+        TEST_ASSERT_EQUAL_INT16(NO_AEAD, nts_string_to_aead("blah"));
 }
 
 TEST(nts, nts_get_key_length) {
-	TEST_ASSERT_EQUAL_INT32(AEAD_AES_SIV_CMAC_256_KEYLEN,
-				nts_get_key_length(AEAD_AES_SIV_CMAC_256));
-	TEST_ASSERT_EQUAL_INT32(AEAD_AES_SIV_CMAC_384_KEYLEN,
-				nts_get_key_length(AEAD_AES_SIV_CMAC_384));
-	TEST_ASSERT_EQUAL_INT32(AEAD_AES_SIV_CMAC_512_KEYLEN,
-				nts_get_key_length(AEAD_AES_SIV_CMAC_512));
-	TEST_ASSERT_EQUAL_INT32(0, nts_get_key_length(-23));
+        TEST_ASSERT_EQUAL_INT32(AEAD_AES_SIV_CMAC_256_KEYLEN,
+                                nts_get_key_length(AEAD_AES_SIV_CMAC_256));
+        TEST_ASSERT_EQUAL_INT32(AEAD_AES_SIV_CMAC_384_KEYLEN,
+                                nts_get_key_length(AEAD_AES_SIV_CMAC_384));
+        TEST_ASSERT_EQUAL_INT32(AEAD_AES_SIV_CMAC_512_KEYLEN,
+                                nts_get_key_length(AEAD_AES_SIV_CMAC_512));
+        TEST_ASSERT_EQUAL_INT32(0, nts_get_key_length(-23));
 }
 
 TEST(nts, ke_append_record_null) {
-	/* Setup */
-	uint8_t buf[128];
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 128;
-	/* Run test */
-	ke_append_record_null(&cursor, 0xFA7E);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0x7E, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[3]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(124, cursor.left);
+        // Setup
+        uint8_t buf[128];
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 128;
+        // Run test
+        ke_append_record_null(&cursor, 0xFA7E);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0x7E, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[3]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(124, cursor.left);
 }
 
 TEST(nts, ke_append_record_uint16) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	/* Run test */
-	ke_append_record_uint16(&cursor, 0xCAFE, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xCA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xFE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0x02, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0x12, buf[4]);
-	TEST_ASSERT_EQUAL_UINT8(0x34, buf[5]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
-	TEST_ASSERT_EQUAL_INT(10, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	ke_append_record_uint16(&cursor, 0xCAFE, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        // Run test
+        ke_append_record_uint16(&cursor, 0xCAFE, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xCA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xFE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0x02, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0x12, buf[4]);
+        TEST_ASSERT_EQUAL_UINT8(0x34, buf[5]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
+        TEST_ASSERT_EQUAL_INT(10, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        ke_append_record_uint16(&cursor, 0xCAFE, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, ke_append_record_bytes) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	uint8_t data[6] = {0, 1, 2, 3, 4, 5};
-	/* Run test */
-	ke_append_record_bytes(&cursor, 0xCAFE, data, 6);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xCA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xFE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0x06, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_EQUAL_UINT8(1, buf[5]);
-	TEST_ASSERT_EQUAL_UINT8(2, buf[6]);
-	TEST_ASSERT_EQUAL_UINT8(3, buf[7]);
-	TEST_ASSERT_EQUAL_UINT8(4, buf[8]);
-	TEST_ASSERT_EQUAL_UINT8(5, buf[9]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
-	TEST_ASSERT_EQUAL_INT(6, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	ke_append_record_bytes(&cursor, 0xCAFE, data, 6);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[10]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        uint8_t data[6] = {0, 1, 2, 3, 4, 5};
+        // Run test
+        ke_append_record_bytes(&cursor, 0xCAFE, data, 6);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xCA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xFE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0x06, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_EQUAL_UINT8(1, buf[5]);
+        TEST_ASSERT_EQUAL_UINT8(2, buf[6]);
+        TEST_ASSERT_EQUAL_UINT8(3, buf[7]);
+        TEST_ASSERT_EQUAL_UINT8(4, buf[8]);
+        TEST_ASSERT_EQUAL_UINT8(5, buf[9]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
+        TEST_ASSERT_EQUAL_INT(6, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        ke_append_record_bytes(&cursor, 0xCAFE, data, 6);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[10]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, ex_append_record_null) {
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	/* Run test */
-	ex_append_record_null(&cursor, 0xFADE);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(4, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(12, cursor.left);
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        // Run test
+        ex_append_record_null(&cursor, 0xFADE);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(4, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(12, cursor.left);
 }
 
 TEST(nts, ex_append_record_uint16) {
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	/* Run test */
-	ex_append_record_uint16(&cursor, 0xFADE, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0x06, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0x12, buf[4]);
-	TEST_ASSERT_EQUAL_UINT8(0x34, buf[5]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
-	TEST_ASSERT_EQUAL_INT(10, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	ke_append_record_uint16(&cursor, 0xCAFE, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        // Run test
+        ex_append_record_uint16(&cursor, 0xFADE, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0x06, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0x12, buf[4]);
+        TEST_ASSERT_EQUAL_UINT8(0x34, buf[5]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
+        TEST_ASSERT_EQUAL_INT(10, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        ke_append_record_uint16(&cursor, 0xCAFE, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, ex_append_record_bytes) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	uint8_t data[6] = {0, 1, 2, 3, 4, 5};
-	/* Run test */
-	ex_append_record_bytes(&cursor, 0xCAFE, data, 6);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xCA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xFE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0x0A, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_EQUAL_UINT8(1, buf[5]);
-	TEST_ASSERT_EQUAL_UINT8(2, buf[6]);
-	TEST_ASSERT_EQUAL_UINT8(3, buf[7]);
-	TEST_ASSERT_EQUAL_UINT8(4, buf[8]);
-	TEST_ASSERT_EQUAL_UINT8(5, buf[9]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
-	TEST_ASSERT_EQUAL_INT(6, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	ex_append_record_bytes(&cursor, 0xCAFE, data, 6);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[10]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        uint8_t data[6] = {0, 1, 2, 3, 4, 5};
+        // Run test
+        ex_append_record_bytes(&cursor, 0xCAFE, data, 6);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xCA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xFE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0x00, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0x0A, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_EQUAL_UINT8(1, buf[5]);
+        TEST_ASSERT_EQUAL_UINT8(2, buf[6]);
+        TEST_ASSERT_EQUAL_UINT8(3, buf[7]);
+        TEST_ASSERT_EQUAL_UINT8(4, buf[8]);
+        TEST_ASSERT_EQUAL_UINT8(5, buf[9]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
+        TEST_ASSERT_EQUAL_INT(6, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        ex_append_record_bytes(&cursor, 0xCAFE, data, 6);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[10]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[10], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, ex_append_header) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	/* Run test */
-	ex_append_header(&cursor, 0xFADE, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0x12, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0x38, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(12, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	ex_append_header(&cursor, 0xFEED, 0xABCD);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        // Run test
+        ex_append_header(&cursor, 0xFADE, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0x12, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0x38, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(12, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        ex_append_header(&cursor, 0xFEED, 0xABCD);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, append_header) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	/* Run test */
-	append_header(&cursor, 0xFADE, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(0x12, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(0x34, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(12, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	append_header(&cursor, 0xFEED, 0xABCD);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        // Run test
+        append_header(&cursor, 0xFADE, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xFA, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xDE, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(0x12, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(0x34, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(12, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        append_header(&cursor, 0xFEED, 0xABCD);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[4]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, append_uint16) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	/* Run test */
-	append_uint16(&cursor, 0x1234);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0x12, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(0x34, buf[1]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[2], cursor.next);
-	TEST_ASSERT_EQUAL_INT(14, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	append_uint16(&cursor, 0x5678);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[2]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[2], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        // Run test
+        append_uint16(&cursor, 0x1234);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0x12, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(0x34, buf[1]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[2], cursor.next);
+        TEST_ASSERT_EQUAL_INT(14, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        append_uint16(&cursor, 0x5678);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[2]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[2], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, append_bytes) {
-	/* Test change */
-	/* Setup */
-	uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	uint8_t data[6] = {0, 1, 2, 3, 4, 5};
-	/* Run test */
-	append_bytes(&cursor, data, 6);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[0]);
-	TEST_ASSERT_EQUAL_UINT8(1, buf[1]);
-	TEST_ASSERT_EQUAL_UINT8(2, buf[2]);
-	TEST_ASSERT_EQUAL_UINT8(3, buf[3]);
-	TEST_ASSERT_EQUAL_UINT8(4, buf[4]);
-	TEST_ASSERT_EQUAL_UINT8(5, buf[5]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
-	TEST_ASSERT_EQUAL_INT(10, cursor.left);
-	/* Test no change */
-	/* Setup */
-	cursor.left = 0;
-	/* Run test */
-	append_bytes(&cursor, data, 6);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
-	TEST_ASSERT_EQUAL_INT(0, cursor.left);
+        // Test change
+        // Setup
+        uint8_t buf[16] = {0, 0, 0, 0, 0, 0, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        uint8_t data[6] = {0, 1, 2, 3, 4, 5};
+        // Run test
+        append_bytes(&cursor, data, 6);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[0]);
+        TEST_ASSERT_EQUAL_UINT8(1, buf[1]);
+        TEST_ASSERT_EQUAL_UINT8(2, buf[2]);
+        TEST_ASSERT_EQUAL_UINT8(3, buf[3]);
+        TEST_ASSERT_EQUAL_UINT8(4, buf[4]);
+        TEST_ASSERT_EQUAL_UINT8(5, buf[5]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
+        TEST_ASSERT_EQUAL_INT(10, cursor.left);
+        // Test no change
+        // Setup
+        cursor.left = 0;
+        // Run test
+        append_bytes(&cursor, data, 6);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0, buf[6]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[6], cursor.next);
+        TEST_ASSERT_EQUAL_INT(0, cursor.left);
 }
 
 TEST(nts, ke_next_record) {
-	/* Setup */
-	uint8_t buf[16] = {0xFA, 0xCE, 0, 4, 0xFF, 0xEE, 0xDD, 0xCC,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	int length;
-	uint16_t type;
-	/* Run test */
-	type = ke_next_record(&cursor, &length);
-	/* Check */
-	TEST_ASSERT_EQUAL_INT(4, length);
-	TEST_ASSERT_EQUAL_INT(0xFACE, type);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(12, cursor.left);
+        // Setup
+        uint8_t buf[16] = {0xFA, 0xCE, 0, 4, 0xFF, 0xEE, 0xDD, 0xCC,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        int length;
+        uint16_t type;
+        // Run test
+        type = ke_next_record(&cursor, &length);
+        // Check
+        TEST_ASSERT_EQUAL_INT(4, length);
+        TEST_ASSERT_EQUAL_INT(0xFACE, type);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(12, cursor.left);
 }
 
 TEST(nts, ex_next_record) {
-	/* Setup */
-	uint8_t buf[16] = {0xFA, 0xCE, 0, 8, 0xFF, 0xEE, 0xDD, 0xCC,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	int length;
-	uint16_t type;
-	/* Run test */
-	type = ex_next_record(&cursor, &length);
-	/* Check */
-	TEST_ASSERT_EQUAL_INT(4, length);
-	TEST_ASSERT_EQUAL_INT(0xFACE, type);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
-	TEST_ASSERT_EQUAL_INT(12, cursor.left);
+        // Setup
+        uint8_t buf[16] = {0xFA, 0xCE, 0, 8, 0xFF, 0xEE, 0xDD, 0xCC,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        int length;
+        uint16_t type;
+        // Run test
+        type = ex_next_record(&cursor, &length);
+        // Check
+        TEST_ASSERT_EQUAL_INT(4, length);
+        TEST_ASSERT_EQUAL_INT(0xFACE, type);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[4], cursor.next);
+        TEST_ASSERT_EQUAL_INT(12, cursor.left);
 }
 
 TEST(nts, next_uint16) {
-	/* Setup */
-	uint8_t buf[16] = {0xFA, 0xCE, 0, 4, 0xFF, 0xEE, 0xDD, 0xCC,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	uint16_t data;
-	/* Run test */
-	data = next_uint16(&cursor);
-	/* Check */
-	TEST_ASSERT_EQUAL_UINT8(0xFACE, data);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[2], cursor.next);
-	TEST_ASSERT_EQUAL_INT(14, cursor.left);
+        // Setup
+        uint8_t buf[16] = {0xFA, 0xCE, 0, 4, 0xFF, 0xEE, 0xDD, 0xCC,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        uint16_t data;
+        // Run test
+        data = next_uint16(&cursor);
+        // Check
+        TEST_ASSERT_EQUAL_UINT8(0xFACE, data);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[2], cursor.next);
+        TEST_ASSERT_EQUAL_INT(14, cursor.left);
 }
 
 TEST(nts, next_bytes) {
-	/* Setup */
-	uint8_t buf[16] = {0xFA, 0xCE, 0, 4, 0xFF, 0xEE, 0xDD, 0xCC,
-		0, 0, 0, 0, 0, 0, 0, 0};
-	BufCtl cursor;
-	cursor.next = buf;
-	cursor.left = 16;
-	uint8_t data[8];
-	uint16_t length;
-	/* Run test */
-	length = next_bytes(&cursor, data, 8);
-	/* Check */
-	TEST_ASSERT_EQUAL_INT(8, length);
-	TEST_ASSERT_EQUAL_UINT8(0xFA, data[0]);
-	TEST_ASSERT_EQUAL_UINT8(0xCE, data[1]);
-	TEST_ASSERT_EQUAL_UINT8(0, data[2]);
-	TEST_ASSERT_EQUAL_UINT8(4, data[3]);
-	TEST_ASSERT_EQUAL_UINT8(0xFF, data[4]);
-	TEST_ASSERT_EQUAL_UINT8(0xEE, data[5]);
-	TEST_ASSERT_EQUAL_UINT8(0xDD, data[6]);
-	TEST_ASSERT_EQUAL_UINT8(0xCC, data[7]);
-	TEST_ASSERT_POINTERS_EQUAL(&buf[8], cursor.next);
-	TEST_ASSERT_EQUAL_INT(8, cursor.left);
+        // Setup
+        uint8_t buf[16] = {0xFA, 0xCE, 0, 4, 0xFF, 0xEE, 0xDD, 0xCC,
+                0, 0, 0, 0, 0, 0, 0, 0};
+        BufCtl cursor;
+        cursor.next = buf;
+        cursor.left = 16;
+        uint8_t data[8];
+        uint16_t length;
+        // Run test
+        length = next_bytes(&cursor, data, 8);
+        // Check
+        TEST_ASSERT_EQUAL_INT(8, length);
+        TEST_ASSERT_EQUAL_UINT8(0xFA, data[0]);
+        TEST_ASSERT_EQUAL_UINT8(0xCE, data[1]);
+        TEST_ASSERT_EQUAL_UINT8(0, data[2]);
+        TEST_ASSERT_EQUAL_UINT8(4, data[3]);
+        TEST_ASSERT_EQUAL_UINT8(0xFF, data[4]);
+        TEST_ASSERT_EQUAL_UINT8(0xEE, data[5]);
+        TEST_ASSERT_EQUAL_UINT8(0xDD, data[6]);
+        TEST_ASSERT_EQUAL_UINT8(0xCC, data[7]);
+        TEST_ASSERT_POINTERS_EQUAL(&buf[8], cursor.next);
+        TEST_ASSERT_EQUAL_INT(8, cursor.left);
 }
 
 TEST_GROUP_RUNNER(nts) {
-	RUN_TEST_CASE(nts, nts_translate_version);
-	RUN_TEST_CASE(nts, nts_string_to_aead);
-	RUN_TEST_CASE(nts, nts_get_key_length);
-	RUN_TEST_CASE(nts, ke_append_record_null);
-	RUN_TEST_CASE(nts, ke_append_record_uint16);
-	RUN_TEST_CASE(nts, ke_append_record_bytes);
-	RUN_TEST_CASE(nts, ex_append_record_null);
-	RUN_TEST_CASE(nts, ex_append_record_uint16);
-	RUN_TEST_CASE(nts, ex_append_record_bytes);
-	RUN_TEST_CASE(nts, ex_append_header);
-	RUN_TEST_CASE(nts, append_header);
-	RUN_TEST_CASE(nts, append_uint16);
-	RUN_TEST_CASE(nts, append_bytes);
-	RUN_TEST_CASE(nts, ke_next_record);
-	RUN_TEST_CASE(nts, ex_next_record);
-	RUN_TEST_CASE(nts, next_uint16);
-	RUN_TEST_CASE(nts, next_bytes);
+        RUN_TEST_CASE(nts, nts_translate_version);
+        RUN_TEST_CASE(nts, nts_string_to_aead);
+        RUN_TEST_CASE(nts, nts_get_key_length);
+        RUN_TEST_CASE(nts, ke_append_record_null);
+        RUN_TEST_CASE(nts, ke_append_record_uint16);
+        RUN_TEST_CASE(nts, ke_append_record_bytes);
+        RUN_TEST_CASE(nts, ex_append_record_null);
+        RUN_TEST_CASE(nts, ex_append_record_uint16);
+        RUN_TEST_CASE(nts, ex_append_record_bytes);
+        RUN_TEST_CASE(nts, ex_append_header);
+        RUN_TEST_CASE(nts, append_header);
+        RUN_TEST_CASE(nts, append_uint16);
+        RUN_TEST_CASE(nts, append_bytes);
+        RUN_TEST_CASE(nts, ke_next_record);
+        RUN_TEST_CASE(nts, ex_next_record);
+        RUN_TEST_CASE(nts, next_uint16);
+        RUN_TEST_CASE(nts, next_bytes);
 }


=====================================
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/8c4d0c6399ad41a5e45b8d97e6872c65524ee09b...98e2af0169cc5225ecdd71903c39f30aa4fe5f4a

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/8c4d0c6399ad41a5e45b8d97e6872c65524ee09b...98e2af0169cc5225ecdd71903c39f30aa4fe5f4a
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/9a9a62ba/attachment-0001.htm>


More information about the vc mailing list