adjust_timestamp(NTP_AuthMode mode, uint32_t key_id, struct timespec *ts)
{
switch (mode) {
- case AUTH_SYMMETRIC:
+ case NTP_AUTH_SYMMETRIC:
ts->tv_nsec += KEY_GetAuthDelay(key_id);
UTI_NormaliseTimespec(ts);
break;
- case AUTH_MSSNTP:
+ case NTP_AUTH_MSSNTP:
ts->tv_nsec += NSD_GetAuthDelay(key_id);
UTI_NormaliseTimespec(ts);
default:
NAU_Instance
NAU_CreateNoneInstance(void)
{
- return create_instance(AUTH_NONE);
+ return create_instance(NTP_AUTH_NONE);
}
/* ================================================== */
NAU_Instance
NAU_CreateSymmetricInstance(uint32_t key_id)
{
- NAU_Instance instance = create_instance(AUTH_SYMMETRIC);
+ NAU_Instance instance = create_instance(NTP_AUTH_SYMMETRIC);
instance->key_id = key_id;
int
NAU_IsAuthEnabled(NAU_Instance instance)
{
- return instance->mode != AUTH_NONE;
+ return instance->mode != NTP_AUTH_NONE;
}
/* ================================================== */
{
/* If the MAC in NTPv4 packets would be truncated, prefer NTPv3 for
compatibility with older chronyd servers */
- if (instance->mode == AUTH_SYMMETRIC &&
+ if (instance->mode == NTP_AUTH_SYMMETRIC &&
KEY_GetAuthLength(instance->key_id) + sizeof (instance->key_id) > NTP_MAX_V4_MAC_LENGTH)
return 3;
NAU_GenerateRequestAuth(NAU_Instance instance, NTP_Packet *request, NTP_PacketInfo *info)
{
switch (instance->mode) {
- case AUTH_NONE:
+ case NTP_AUTH_NONE:
break;
- case AUTH_SYMMETRIC:
+ case NTP_AUTH_SYMMETRIC:
if (!generate_symmetric_auth(instance->key_id, request, info))
return 0;
break;
/* In NTPv3 and older packets don't have extension fields. Anything after
the header is assumed to be a MAC. */
if (info->version <= 3) {
- info->auth.mode = AUTH_SYMMETRIC;
+ info->auth.mode = NTP_AUTH_SYMMETRIC;
info->auth.mac.start = parsed;
info->auth.mac.length = remainder;
info->auth.mac.key_id = ntohl(*(uint32_t *)(data + parsed));
field with zeroes as digest */
if (info->version == 3 && info->auth.mac.key_id) {
if (remainder == 20 && is_zero_data(data + parsed + 4, remainder - 4))
- info->auth.mode = AUTH_MSSNTP;
+ info->auth.mode = NTP_AUTH_MSSNTP;
else if (remainder == 72 && is_zero_data(data + parsed + 8, remainder - 8))
- info->auth.mode = AUTH_MSSNTP_EXT;
+ info->auth.mode = NTP_AUTH_MSSNTP_EXT;
}
return 1;
/* Check for a crypto NAK */
if (remainder == 4 && ntohl(*(uint32_t *)(data + parsed)) == 0) {
- info->auth.mode = AUTH_SYMMETRIC;
+ info->auth.mode = NTP_AUTH_SYMMETRIC;
info->auth.mac.start = parsed;
info->auth.mac.length = remainder;
info->auth.mac.key_id = 0;
/* This is not 100% reliable as a MAC could fail to authenticate and could
pass as an extension field, leaving reminder smaller than the minimum MAC
length */
- info->auth.mode = AUTH_SYMMETRIC;
+ info->auth.mode = NTP_AUTH_SYMMETRIC;
info->auth.mac.start = parsed;
info->auth.mac.length = remainder;
info->auth.mac.key_id = ntohl(*(uint32_t *)(data + parsed));
NAU_CheckRequestAuth(NTP_Packet *request, NTP_PacketInfo *info)
{
switch (info->auth.mode) {
- case AUTH_NONE:
+ case NTP_AUTH_NONE:
break;
- case AUTH_SYMMETRIC:
+ case NTP_AUTH_SYMMETRIC:
if (!check_symmetric_auth(request, info))
return 0;
break;
- case AUTH_MSSNTP:
+ case NTP_AUTH_MSSNTP:
/* MS-SNTP requests are not authenticated */
break;
default:
NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr)
{
switch (request_info->auth.mode) {
- case AUTH_NONE:
+ case NTP_AUTH_NONE:
break;
- case AUTH_SYMMETRIC:
+ case NTP_AUTH_SYMMETRIC:
if (!generate_symmetric_auth(request_info->auth.mac.key_id, response, response_info))
return 0;
break;
- case AUTH_MSSNTP:
+ case NTP_AUTH_MSSNTP:
/* Sign the packet asynchronously by ntp_signd */
if (!NSD_SignAndSendPacket(request_info->auth.mac.key_id, response, response_info,
remote_addr, local_addr))
{
/* If we don't expect the packet to be authenticated, ignore any
authentication data in the packet */
- if (instance->mode == AUTH_NONE)
+ if (instance->mode == NTP_AUTH_NONE)
return 1;
/* The authentication must match the expected mode */
return 0;
switch (info->auth.mode) {
- case AUTH_NONE:
+ case NTP_AUTH_NONE:
break;
- case AUTH_SYMMETRIC:
+ case NTP_AUTH_SYMMETRIC:
/* Check if it is authenticated with the specified key */
if (info->auth.mac.key_id != instance->key_id)
return 0;