[Git][NTPsec/ntpsec][working] 23 commits: Add ntp_random64
Ian Bruene
gitlab at mg.gitlab.com
Thu Jul 12 14:39:12 UTC 2018
Ian Bruene pushed to branch working at NTPsec / ntpsec
Commits:
3aca5b79 by Hal Murray at 2018-07-09T01:12:02Z
Add ntp_random64
- - - - -
ec804bc4 by Hal Murray at 2018-07-09T05:50:36Z
Cleanup peer_xmit - should be no visible change
- - - - -
a745d41a by Hal Murray at 2018-07-09T07:25:23Z
First cut at data minimization
Still sends valid time in pkt->xmt
Other fields are hidden as per draft spec.
- - - - -
60fe3b92 by Hal Murray at 2018-07-09T11:18:40Z
Rest of data minimization
randomize transmit timestamp
- - - - -
fb105e4e by Hal Murray at 2018-07-10T10:46:48Z
Update NEWS: CMAC authentication, data minimization
- - - - -
f759687f by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_ntp_to_ntp.
- - - - -
016d2194 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_daysec_to_date.
- - - - -
f8096db9 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_split_eradays.
- - - - -
7209baeb by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_time_to_date.
- - - - -
3f97e469 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_days_in_years.
- - - - -
5df20d29 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_edate_to_eradays.
- - - - -
48072de5 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_etime_to_seconds.
- - - - -
71f3bef7 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_tm_to_rd.
- - - - -
5fcd679e by Ian Bruene at 2018-07-12T14:38:34Z
Added tests for ntpcal_date_to_daysec and ntpcal_tm_to_daysec.
- - - - -
2cf232c4 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_date_to_time.
- - - - -
d9b2197c by Ian Bruene at 2018-07-12T14:38:34Z
Added tests for ntpcal_ntp64_to_date, ntpcal_ntp_to_date.
- - - - -
d7700f40 by Ian Bruene at 2018-07-12T14:38:34Z
Added test for ntpcal_periodic_event.
- - - - -
a29ff1e4 by Ian Bruene at 2018-07-12T14:38:34Z
Fix for 32-bit error in ntpcal_date_to_time test.
- - - - -
553f9b62 by Ian Bruene at 2018-07-12T14:38:34Z
Added tests for functions in prettydate.c
- - - - -
47c43523 by Ian Bruene at 2018-07-12T14:38:34Z
Merge.
- - - - -
c39bf14a by Ian Bruene at 2018-07-12T14:38:34Z
Fixed indentation.
- - - - -
9dea1e34 by Ian Bruene at 2018-07-12T14:38:34Z
Whitespace fixes.
- - - - -
7a73029c by Ian Bruene at 2018-07-12T14:38:34Z
Whitespace fixes.
- - - - -
8 changed files:
- NEWS
- include/ntp.h
- libntp/ntp_random.c
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/ntp_util.c
- tests/libntp/ntp_calendar.c
- tests/libntp/prettydate.c
Changes:
=====================================
NEWS
=====================================
@@ -12,6 +12,12 @@ on user-visible changes.
== Repository Head ==
+Use data minimization on client requests
+ https://datatracker.ietf.org/doc/draft-ietf-ntp-data-minimization/
+
+Support AES-128-CMAC for authentication
+ https://datatracker.ietf.org/doc/draft-ietf-ntp-mac/
+
== 2018-06-11: 1.1.1 ==
Log timestamps now include the year. This is useful when
=====================================
include/ntp.h
=====================================
@@ -16,6 +16,7 @@
#include "ntp_net.h"
extern int32_t ntp_random (void);
+extern uint64_t ntp_random64 (void);
/*
* Calendar arithmetic - contributed by G. Healton
@@ -278,7 +279,8 @@ struct peer {
l_fp rec; /* receive time stamp */
l_fp xmt; /* transmit time stamp */
l_fp dst; /* destination timestamp */
- l_fp org; /* origin timestamp */
+ l_fp org_ts; /* origin real-timestamp */
+ l_fp org_rand; /* origin pseudo-timestamp */
double offset; /* peer clock offset */
double delay; /* peer roundtrip delay */
double jitter; /* peer jitter (squares) */
=====================================
libntp/ntp_random.c
=====================================
@@ -29,3 +29,17 @@ ntp_random(void)
}
return rnd;
}
+
+uint64_t
+ntp_random64(void)
+{
+ int err;
+ uint64_t rnd;
+ err = RAND_bytes((unsigned char *)&rnd, sizeof(rnd));
+ if (1 != err) {
+ msyslog(LOG_ERR, "ERR: ntp_random - RAND_bytes failed");
+ exit(1);
+ }
+ return rnd;
+}
+
=====================================
ntpd/ntp_proto.c
=====================================
@@ -494,7 +494,7 @@ handle_procpkt(
peer->flash |= BOGON3;
peer->bogusorg++;
return;
- } else if(rbufp->pkt.org != peer->org) {
+ } else if(rbufp->pkt.org != peer->org_rand) {
peer->flash |= BOGON2;
peer->bogusorg++;
return;
@@ -550,9 +550,9 @@ handle_procpkt(
scalbn((double)(rbufp->pkt.xmt - rbufp->recv_time), -32) :
-scalbn((double)(rbufp->recv_time - rbufp->pkt.xmt), -32);
const double t21 =
- (rbufp->pkt.rec >= peer->org) ?
- scalbn((double)(rbufp->pkt.rec - peer->org), -32) :
- -scalbn((double)(peer->org - rbufp->pkt.rec), -32);
+ (rbufp->pkt.rec >= peer->org_ts) ?
+ scalbn((double)(rbufp->pkt.rec - peer->org_ts), -32) :
+ -scalbn((double)(peer->org_ts - rbufp->pkt.rec), -32);
const double theta = (t21 + t34) / 2.;
const double delta = fabs(t21 - t34);
const double epsilon = LOGTOD(sys_vars.sys_precision) +
@@ -2049,87 +2049,82 @@ root_distance(
/*
- * peer_xmit - send packet for persistent association.
+ * peer_xmit - send client-mode packet for persistent association.
*/
static void
peer_xmit(
struct peer *peer /* peer structure pointer */
)
{
- struct pkt xpkt; /* transmit packet */
- size_t sendlen, authlen;
- auth_info *auth; /* !NULL for authentication */
- l_fp xmt_tx;
+ struct pkt xpkt; /* transmit packet */
+ unsigned int sendlen;
- if (!peer->dstadr) /* drop peers without interface */
+ if (!peer->dstadr) /* drop peers without interface */
return;
- xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_vars.sys_leap, peer->cfg.version,
- peer->hmode);
- xpkt.stratum = STRATUM_TO_PKT(sys_vars.sys_stratum);
- xpkt.ppoll = peer->hpoll;
- xpkt.precision = sys_vars.sys_precision;
- xpkt.refid = sys_vars.sys_refid;
- xpkt.rootdelay = HTONS_FP(DTOUFP(sys_vars.sys_rootdelay));
- xpkt.rootdisp = HTONS_FP(DTOUFP(sys_vars.sys_rootdisp));
- xpkt.reftime = htonl_fp(sys_vars.sys_reftime);
- xpkt.org = htonl_fp(peer->xmt);
- xpkt.rec = htonl_fp(peer->dst);
-
- /*
- * If the peer (aka server) was configured with a key, authenticate
- * the packet. Else, the packet is not authenticated.
- */
sendlen = LEN_PKT_NOMAC;
- if (peer->cfg.peerkey == 0) {
- /*
- * Transmit a-priori timestamps. This is paired with
- * a later call used to record transmission time.
+ if (NTP_VERSION == peer->cfg.version) {
+ /* Hide most of info for privacy
+ * RFC in progress - draft-ietf-ntp-data-minimization, 2018-Jul-07
*/
- get_systime(&xmt_tx);
- peer->org = xmt_tx;
- xpkt.xmt = htonl_fp(xmt_tx);
- sendpkt(&peer->srcadr, peer->dstadr, &xpkt, (int)sendlen);
- peer->sent++;
- peer->outcount++;
- peer->throttle += (1 << peer->cfg.minpoll) - 2;
-
- DPRINT(1, ("transmit: at %u %s->%s mode %d len %zu\n",
- current_time, peer->dstadr ?
- socktoa(&peer->dstadr->sin) : "-",
- socktoa(&peer->srcadr), peer->hmode, sendlen));
- return;
+ xpkt.li_vn_mode = PKT_LI_VN_MODE(
+ LEAP_NOWARNING, peer->cfg.version, MODE_CLIENT);
+ xpkt.stratum = 0;
+ xpkt.ppoll = 0;
+ xpkt.precision = 0x20;
+ xpkt.refid = 0;
+ xpkt.rootdelay = 0;
+ xpkt.rootdisp = 0;
+ xpkt.reftime = htonl_fp(0);
+ xpkt.org = htonl_fp(0);
+ xpkt.rec = htonl_fp(0);
+ peer->org_rand = ntp_random64();
+ get_systime(&peer->org_ts); /* as late as possible */
+ } else {
+ xpkt.li_vn_mode = PKT_LI_VN_MODE(
+ sys_vars.sys_leap, peer->cfg.version, peer->hmode);
+ xpkt.stratum = STRATUM_TO_PKT(sys_vars.sys_stratum);
+ xpkt.ppoll = peer->hpoll;
+ xpkt.precision = sys_vars.sys_precision;
+ xpkt.refid = sys_vars.sys_refid;
+ xpkt.rootdelay = HTONS_FP(DTOUFP(sys_vars.sys_rootdelay));
+ xpkt.rootdisp = HTONS_FP(DTOUFP(sys_vars.sys_rootdisp));
+ xpkt.reftime = htonl_fp(sys_vars.sys_reftime);
+ xpkt.org = htonl_fp(peer->xmt);
+ xpkt.rec = htonl_fp(peer->dst);
+ get_systime(&peer->org_ts); /* as late as possible */
+ peer->org_rand = peer->org_ts;
}
- /*
- * Authentication is enabled, so the transmitted packet must be
- * authenticated.
-` */
+ xpkt.xmt = htonl_fp(peer->org_rand); /* out in xmt, back in org */
+
/*
- * Transmit a-priori timestamps
+ * If the peer (aka server) was configured with a key, authenticate
+ * the packet. Else, the packet is not authenticated.
*/
- get_systime(&xmt_tx);
- peer->org = xmt_tx;
- xpkt.xmt = htonl_fp(xmt_tx);
- auth = authlookup(peer->cfg.peerkey, true);
- if (NULL == auth) {
- report_event(PEVNT_AUTH, peer, "no key");
- peer->flash |= BOGON5; /* auth error */
- peer->badauth++;
- return;
- }
- authlen = (size_t)authencrypt(auth, (uint32_t *)&xpkt, (int)sendlen);
- sendlen += authlen;
- if (sendlen > sizeof(xpkt)) {
- msyslog(LOG_ERR, "PROTO: buffer overflow %zu", sendlen);
- exit(1);
+ if (0 != peer->cfg.peerkey) {
+ auth_info *auth = authlookup(peer->cfg.peerkey, true);
+ if (NULL == auth) {
+ report_event(PEVNT_AUTH, peer, "no key");
+ peer->flash |= BOGON5; /* auth error */
+ peer->badauth++;
+ return;
+ }
+ /* Maybe bump peer->org_ts to account for crypto time */
+ sendlen += authencrypt(auth, (uint32_t *)&xpkt, sendlen);
+ if (sendlen > sizeof(xpkt)) {
+ msyslog(LOG_ERR, "PROTO: buffer overflow %u", sendlen);
+ exit(1);
+ }
}
- sendpkt(&peer->srcadr, peer->dstadr, &xpkt, (int)sendlen);
+
+ sendpkt(&peer->srcadr, peer->dstadr, &xpkt, sendlen);
+
peer->sent++;
peer->outcount++;
peer->throttle += (1 << peer->cfg.minpoll) - 2;
- DPRINT(1, ("transmit: at %u %s->%s mode %d keyid %08x len %zu\n",
+ DPRINT(1, ("transmit: at %u %s->%s mode %d keyid %08x len %u\n",
current_time, peer->dstadr ?
socktoa(&peer->dstadr->sin) : "-",
socktoa(&peer->srcadr), peer->hmode,
=====================================
ntpd/ntp_refclock.c
=====================================
@@ -532,7 +532,7 @@ refclock_receive(
}
peer->reach |= 1;
peer->reftime = pp->lastref;
- peer->org = pp->lastrec;
+ peer->org_ts = pp->lastrec;
peer->rootdisp = pp->disp;
get_systime(&peer->dst);
if (!refclock_sample(pp))
=====================================
ntpd/ntp_util.c
=====================================
@@ -540,7 +540,7 @@ record_raw_stats(
{
struct timespec now;
const sockaddr_u *dstaddr = peer->dstadr ? &peer->dstadr->sin : NULL;
- l_fp t1 = peer->org; /* originate timestamp */
+ l_fp t1 = peer->org_ts; /* originate timestamp */
l_fp t2 = peer->rec; /* receive timestamp */
l_fp t3 = peer->xmt; /* transmit timestamp */
l_fp t4 = peer->dst; /* destination timestamp */
=====================================
tests/libntp/ntp_calendar.c
=====================================
@@ -128,9 +128,25 @@ TEST(calendar, parse_to_unixtime) {
}
#endif
-// test the NTP to Unix time conversion
+TEST(calendar, PeriodicExtend1) {
+ // Test positive cycle, pivot > value
+ TEST_ASSERT_EQUAL(1001, ntpcal_periodic_extend(1000, 5, 2));
+ // Test positive cycle, pivot < value
+ TEST_ASSERT_EQUAL(6, ntpcal_periodic_extend(5, 1000, 2));
+ // Test negative cycle, pivot > value
+ TEST_ASSERT_EQUAL(999, ntpcal_periodic_extend(1000, 5, -2));
+ // Test negative cycle, pivot < value
+ TEST_ASSERT_EQUAL(4, ntpcal_periodic_extend(5, 1000, -2));
+}
+
+// test the NTP to 64-bit Unix scale time conversion
TEST(calendar, NtpToTime1) {
- TEST_ASSERT_EQUAL(2085978538, ntpcal_ntp_to_time(42, 23));
+ TEST_ASSERT_EQUAL(2085978538, ntpcal_ntp_to_time(42, 23));
+}
+
+// test the NTP to 64-bit NTP scale time conversion
+TEST(calendar, NtpToNtp1) {
+ TEST_ASSERT_EQUAL(4294967338, ntpcal_ntp_to_ntp(42, 23));
}
// test the day/sec join & split ops, making sure that 32bit
@@ -162,6 +178,37 @@ TEST(calendar, DaySplitMerge) {
}
}
+TEST(calendar, SplitEraDays1) {
+ ntpcal_split res;
+ int32_t isleapyear = 42;
+
+ // Test no flag, no-leap, positive
+ res = ntpcal_split_eradays(4, NULL);
+ TEST_ASSERT_EQUAL(0, res.hi);
+ TEST_ASSERT_EQUAL(4, res.lo);
+ TEST_ASSERT_EQUAL(42, isleapyear);
+
+ // Test flag, no-leap, positive
+ res = ntpcal_split_eradays(4, &isleapyear);
+ TEST_ASSERT_EQUAL(0, res.hi);
+ TEST_ASSERT_EQUAL(4, res.lo);
+ TEST_ASSERT_EQUAL(0, isleapyear);
+
+ // Test flag, leap, positive
+ res = ntpcal_split_eradays(1400, &isleapyear);
+ TEST_ASSERT_EQUAL(3, res.hi);
+ TEST_ASSERT_EQUAL(305, res.lo);
+ TEST_ASSERT_EQUAL(1, isleapyear);
+
+ isleapyear = 0;
+
+ // Test flag, leap, negative
+ res = ntpcal_split_eradays(-100, &isleapyear);
+ TEST_ASSERT_EQUAL(-1, res.hi);
+ TEST_ASSERT_EQUAL(266, res.lo);
+ TEST_ASSERT_EQUAL(1, isleapyear);
+}
+
TEST(calendar, SplitYearDays1) {
int32_t eyd;
@@ -201,6 +248,84 @@ TEST(calendar, RataDie1) {
TEST_ASSERT_TRUE(IsEqualDate(&expected, &actual));
}
+TEST(calendar, DaysecToDate1) {
+ struct calendar cal;
+ int32_t days;
+
+ // Test normal date
+ days = ntpcal_daysec_to_date(&cal, 100000);
+ TEST_ASSERT_EQUAL(days, 1);
+ TEST_ASSERT_EQUAL(cal.hour, 3);
+ TEST_ASSERT_EQUAL(cal.minute, 46);
+ TEST_ASSERT_EQUAL(cal.second, 40);
+
+ // Test negative date
+ days = ntpcal_daysec_to_date(&cal, -100000);
+ TEST_ASSERT_EQUAL(-2, days);
+ TEST_ASSERT_EQUAL(20, cal.hour);
+ TEST_ASSERT_EQUAL(13, cal.minute);
+ TEST_ASSERT_EQUAL(20, cal.second);
+}
+
+TEST(calendar, TimeToDate1) {
+ struct calendar jd = {0, 0, 0, 0, 0, 0, 0, 0};
+ int res;
+
+ res = ntpcal_time_to_date(&jd, 1000000);
+ TEST_ASSERT_EQUAL(0, res);
+ TEST_ASSERT_EQUAL(1970, jd.year);
+ TEST_ASSERT_EQUAL(12, jd.yearday);
+ TEST_ASSERT_EQUAL(1, jd.month);
+ TEST_ASSERT_EQUAL(12, jd.monthday);
+ TEST_ASSERT_EQUAL(13, jd.hour);
+ TEST_ASSERT_EQUAL(46, jd.minute);
+ TEST_ASSERT_EQUAL(40, jd.second);
+ TEST_ASSERT_EQUAL(1, jd.weekday);
+}
+
+TEST(calendar, DayJoin1) {
+ TEST_ASSERT_EQUAL(4323600, ntpcal_dayjoin(50, 3600));
+}
+
+TEST(calendar, DaysInYears1) {
+ // Test positive less than one gregorian cycle of years
+ TEST_ASSERT_EQUAL(109572, ntpcal_days_in_years(300));
+ // Test positive one gregorian cycle of years
+ TEST_ASSERT_EQUAL(146097, ntpcal_days_in_years(400));
+ // Test positive greater than one gregorian cycle of years
+ TEST_ASSERT_EQUAL(182621, ntpcal_days_in_years(500));
+ // Test negative less than one gregorian cycle of years
+ TEST_ASSERT_EQUAL(-109573, ntpcal_days_in_years(-300));
+ // Test negative one gregorian cycle of years
+ TEST_ASSERT_EQUAL(-146097, ntpcal_days_in_years(-400));
+ // Test negative greater than one gregorian cycle of years
+ TEST_ASSERT_EQUAL(-182622, ntpcal_days_in_years(-500));
+}
+
+TEST(calendar, EdateToEradays1) {
+ // Test positive, no months
+ TEST_ASSERT_EQUAL(1827, ntpcal_edate_to_eradays(5, 0, 1));
+ // Test positive, with months
+ TEST_ASSERT_EQUAL(1917, ntpcal_edate_to_eradays(5, 3, 1));
+ // Test negative, no months
+ TEST_ASSERT_EQUAL(-1828, ntpcal_edate_to_eradays(-5, 0, -1));
+ // Test negative, with months
+ TEST_ASSERT_EQUAL(-1920, ntpcal_edate_to_eradays(-5, -3, -1));
+}
+
+TEST(calendar, EtimeToSeconds1) {
+ TEST_ASSERT_EQUAL(18181, ntpcal_etime_to_seconds(5, 3, 1));
+}
+
+TEST(calendar, TmToRd1) {
+ struct tm utm;
+
+ utm.tm_year = 10;
+ utm.tm_mon = 5;
+ utm.tm_mday = 1;
+ TEST_ASSERT_EQUAL(697399, ntpcal_tm_to_rd(&utm));
+}
+
// check last day of february for first 10000 years
TEST(calendar, LeapYears1) {
struct calendar dateIn, dateOut;
@@ -263,6 +388,60 @@ TEST(calendar, RoundTripDate) {
}
}
+TEST(calendar, DateToDaysec1) {
+ struct calendar jd;
+
+ jd.hour = 18;
+ jd.minute = 45;
+ jd.second = 15;
+ TEST_ASSERT_EQUAL(67515, ntpcal_date_to_daysec(&jd));
+}
+
+TEST(calendar, TmToDaysec1) {
+ struct tm utm;
+
+ utm.tm_hour = 18;
+ utm.tm_min = 45;
+ utm.tm_sec = 15;
+ TEST_ASSERT_EQUAL(67515, ntpcal_tm_to_daysec(&utm));
+}
+
+TEST(calendar, DateToTime1) {
+ struct calendar jd;
+
+ jd.year = 2000;
+ jd.month = 2;
+ jd.monthday = 4;
+ jd.hour = 8;
+ jd.minute = 16;
+ jd.second = 32;
+ TEST_ASSERT_EQUAL(949652192, ntpcal_date_to_time(&jd));
+}
+
+TEST(calendar, Ntp64ToDate1) {
+ struct calendar jd;
+
+ TEST_ASSERT_EQUAL(0, ntpcal_ntp64_to_date(&jd, 10000000));
+ TEST_ASSERT_EQUAL(1900, jd.year);
+ TEST_ASSERT_EQUAL(4, jd.month);
+ TEST_ASSERT_EQUAL(26, jd.monthday);
+ TEST_ASSERT_EQUAL(17, jd.hour);
+ TEST_ASSERT_EQUAL(46, jd.minute);
+ TEST_ASSERT_EQUAL(40, jd.second);
+}
+
+TEST(calendar, NtpToDate1) {
+ struct calendar jd;
+
+ TEST_ASSERT_EQUAL(1, ntpcal_ntp_to_date(&jd, 86400, 1000000));
+ TEST_ASSERT_EQUAL(2036, jd.year);
+ TEST_ASSERT_EQUAL(2, jd.month);
+ TEST_ASSERT_EQUAL(8, jd.monthday);
+ TEST_ASSERT_EQUAL(6, jd.hour);
+ TEST_ASSERT_EQUAL(28, jd.minute);
+ TEST_ASSERT_EQUAL(16, jd.second);
+}
+
TEST_GROUP_RUNNER(calendar) {
RUN_TEST_CASE(calendar, is_leapyear);
@@ -271,12 +450,27 @@ TEST_GROUP_RUNNER(calendar) {
#ifdef CLOCK_GENERIC
RUN_TEST_CASE(calendar, parse_to_unixtime);
#endif
+ RUN_TEST_CASE(calendar, PeriodicExtend1);
RUN_TEST_CASE(calendar, NtpToTime1);
+ RUN_TEST_CASE(calendar, NtpToNtp1);
RUN_TEST_CASE(calendar, DaySplitMerge);
+ RUN_TEST_CASE(calendar, DaysecToDate1);
+ RUN_TEST_CASE(calendar, SplitEraDays1);
RUN_TEST_CASE(calendar, SplitYearDays1);
RUN_TEST_CASE(calendar, SplitYearDays2);
RUN_TEST_CASE(calendar, RataDie1);
+ RUN_TEST_CASE(calendar, TimeToDate1);
+ RUN_TEST_CASE(calendar, DayJoin1);
+ RUN_TEST_CASE(calendar, DaysInYears1);
+ RUN_TEST_CASE(calendar, EdateToEradays1);
+ RUN_TEST_CASE(calendar, EtimeToSeconds1);
+ RUN_TEST_CASE(calendar, TmToRd1);
RUN_TEST_CASE(calendar, LeapYears1);
RUN_TEST_CASE(calendar, LeapYears2);
RUN_TEST_CASE(calendar, RoundTripDate);
+ RUN_TEST_CASE(calendar, DateToDaysec1);
+ RUN_TEST_CASE(calendar, TmToDaysec1);
+ RUN_TEST_CASE(calendar, DateToTime1);
+ RUN_TEST_CASE(calendar, Ntp64ToDate1);
+ RUN_TEST_CASE(calendar, NtpToDate1);
}
=====================================
tests/libntp/prettydate.c
=====================================
@@ -19,6 +19,14 @@ TEST_TEAR_DOWN(prettydate) {}
static const uint32_t HALF = 2147483648UL;
+TEST(prettydate, Rfc3339Date1) {
+ TEST_ASSERT_EQUAL_STRING("2036-02-07T06:28:16.000Z", rfc3339date(0));
+}
+
+TEST(prettydate, Rfc3339Time1) {
+ TEST_ASSERT_EQUAL_STRING("2036-02-07T06:28:16.000Z", rfc3339date(0));
+}
+
TEST(prettydate, ConstantDate) {
l_fp t = lfpinit((int32_t)3485080800LL, HALF); // 2010-06-09 14:00:00.5
@@ -27,4 +35,6 @@ TEST(prettydate, ConstantDate) {
TEST_GROUP_RUNNER(prettydate) {
RUN_TEST_CASE(prettydate, ConstantDate);
+ RUN_TEST_CASE(prettydate, Rfc3339Date1);
+ RUN_TEST_CASE(prettydate, Rfc3339Time1);
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/24f1f03d315f13d543c541c410c3d4057f266a47...7a73029ce6c8b89185f4adfeae97cc7b2890f0ad
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/24f1f03d315f13d543c541c410c3d4057f266a47...7a73029ce6c8b89185f4adfeae97cc7b2890f0ad
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180712/9de04184/attachment.html>
More information about the vc
mailing list