mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-06 21:45:07 -05:00
nts: improve NTS-KE server/client code
Add more assertions and comments, refactor initialization of the helper, and make other changes to make the code more robust.
This commit is contained in:
@@ -35,7 +35,7 @@ prepare_response(NKSN_Instance session, int valid)
|
||||
if (valid)
|
||||
index = -1;
|
||||
else
|
||||
index = random() % 9;
|
||||
index = random() % 10;
|
||||
DEBUG_LOG("index=%d", index);
|
||||
|
||||
NKSN_BeginMessage(session);
|
||||
@@ -89,8 +89,12 @@ prepare_response(NKSN_Instance session, int valid)
|
||||
}
|
||||
|
||||
if (index != 8) {
|
||||
for (i = 0; i < NKE_MAX_COOKIES; i++)
|
||||
for (i = 0; i < NKE_MAX_COOKIES; i++) {
|
||||
length = (random() % sizeof (data) + 1) / 4 * 4;
|
||||
if (index == 9)
|
||||
length += random() % 3 + 1;
|
||||
TEST_CHECK(NKSN_AddRecord(session, 0, NKE_RECORD_COOKIE, data, length));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CHECK(NKSN_EndMessage(session));
|
||||
|
||||
@@ -154,7 +154,8 @@ test_unit(void)
|
||||
SCH_Initialise();
|
||||
|
||||
unlink("ntskeys");
|
||||
NKS_Initialise(0);
|
||||
NKS_PreInitialise(0, 0, 0);
|
||||
NKS_Initialise();
|
||||
|
||||
session = NKSN_CreateInstance(1, NULL, handle_message, NULL);
|
||||
|
||||
|
||||
@@ -126,7 +126,8 @@ test_unit(void)
|
||||
LCL_Initialise();
|
||||
TST_RegisterDummyDrivers();
|
||||
SCH_Initialise();
|
||||
NKS_Initialise(0);
|
||||
NKS_PreInitialise(0, 0, 0);
|
||||
NKS_Initialise();
|
||||
NNS_Initialise();
|
||||
|
||||
for (i = 0; i < 50000; i++) {
|
||||
|
||||
Reference in New Issue
Block a user