]> git.ipfire.org Git - thirdparty/chrony.git/blame - nts_ke.h
examples: harden systemd services
[thirdparty/chrony.git] / nts_ke.h
CommitLineData
a420ed57
ML
1/*
2 chronyd/chronyc - Programs for keeping computer clocks accurate.
3
4 **********************************************************************
5 * Copyright (C) Miroslav Lichvar 2020
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 **********************************************************************
21
22 =======================================================================
23
24 Header file for the NTS Key Establishment protocol
25 */
26
27#ifndef GOT_NTS_KE_H
28#define GOT_NTS_KE_H
29
30#include "siv.h"
31
e3cd248f
ML
32#define NKE_PORT 4460
33
a420ed57
ML
34#define NKE_RECORD_CRITICAL_BIT (1U << 15)
35#define NKE_RECORD_END_OF_MESSAGE 0
36#define NKE_RECORD_NEXT_PROTOCOL 1
37#define NKE_RECORD_ERROR 2
38#define NKE_RECORD_WARNING 3
39#define NKE_RECORD_AEAD_ALGORITHM 4
40#define NKE_RECORD_COOKIE 5
41#define NKE_RECORD_NTPV4_SERVER_NEGOTIATION 6
42#define NKE_RECORD_NTPV4_PORT_NEGOTIATION 7
43
44#define NKE_NEXT_PROTOCOL_NTPV4 0
45
46#define NKE_ERROR_UNRECOGNIZED_CRITICAL_RECORD 0
47#define NKE_ERROR_BAD_REQUEST 1
48#define NKE_ERROR_INTERNAL_SERVER_ERROR 2
49
50#define NKE_ALPN_NAME "ntske/1"
2a4fd0a5 51#define NKE_EXPORTER_LABEL "EXPORTER-network-time-security"
a420ed57
ML
52#define NKE_EXPORTER_CONTEXT_C2S "\x0\x0\x0\xf\x0"
53#define NKE_EXPORTER_CONTEXT_S2C "\x0\x0\x0\xf\x1"
54
55#define NKE_MAX_MESSAGE_LENGTH 16384
56#define NKE_MAX_RECORD_BODY_LENGTH 256
57#define NKE_MAX_COOKIE_LENGTH 256
58#define NKE_MAX_COOKIES 8
59#define NKE_MAX_KEY_LENGTH SIV_MAX_KEY_LENGTH
60
66dc2b6d
ML
61#define NKE_RETRY_FACTOR2_CONNECT 4
62#define NKE_RETRY_FACTOR2_TLS 10
63#define NKE_MAX_RETRY_INTERVAL2 19
64
a420ed57
ML
65typedef struct {
66 int length;
67 unsigned char key[NKE_MAX_KEY_LENGTH];
68} NKE_Key;
69
adcf0734
ML
70typedef struct {
71 SIV_Algorithm algorithm;
72 NKE_Key c2s;
73 NKE_Key s2c;
74} NKE_Context;
75
a420ed57
ML
76typedef struct {
77 int length;
78 unsigned char cookie[NKE_MAX_COOKIE_LENGTH];
79} NKE_Cookie;
80
81#endif