Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / include / ntp_crypto.h
blob7738c617ddf365eea8cf0b67cbd1f19532adb147
1 /* $NetBSD: ntp_crypto.h,v 1.2 2003/12/04 16:23:36 drochner Exp $ */
3 /*
4 * ntp_crypto.h - definitions for cryptographic operations
5 */
6 #ifdef OPENSSL
7 #include "openssl/evp.h"
8 /*
9 * The following bits are set by the CRYPTO_ASSOC message from
10 * the server and are not modified by the client.
12 #define CRYPTO_FLAG_ENAB 0x0001 /* crypto enable */
13 #define CRYPTO_FLAG_TAI 0x0002 /* leapseconds table */
15 #define CRYPTO_FLAG_PRIV 0x0010 /* PC identity scheme */
16 #define CRYPTO_FLAG_IFF 0x0020 /* IFF identity scheme */
17 #define CRYPTO_FLAG_GQ 0x0040 /* GQ identity scheme */
18 #define CRYPTO_FLAG_MV 0x0080 /* MV identity scheme */
19 #define CRYPTO_FLAG_MASK 0x00f0 /* identity scheme mask */
22 * The following bits are used by the client during the protocol
23 * exchange.
25 #define CRYPTO_FLAG_VALID 0x0100 /* public key verified */
26 #define CRYPTO_FLAG_VRFY 0x0200 /* identity verified */
27 #define CRYPTO_FLAG_PROV 0x0400 /* signature verified */
28 #define CRYPTO_FLAG_AGREE 0x0800 /* cookie verifed */
29 #define CRYPTO_FLAG_AUTO 0x1000 /* autokey verified */
30 #define CRYPTO_FLAG_SIGN 0x2000 /* certificate signed */
31 #define CRYPTO_FLAG_LEAP 0x4000 /* leapseconds table verified */
34 * Flags used for certificate management
36 #define CERT_TRUST 0x01 /* certificate is trusted */
37 #define CERT_SIGN 0x02 /* certificate is signed */
38 #define CERT_VALID 0x04 /* certificate is valid */
39 #define CERT_PRIV 0x08 /* certificate is private */
40 #define CERT_ERROR 0x80 /* certificate has errors */
43 * Extension field definitions
45 #define CRYPTO_MAXLEN 1024 /* max extension field length */
46 #define CRYPTO_VN 2 /* current protocol version number */
47 #define CRYPTO_CMD(x) (((CRYPTO_VN << 8) | (x)) << 16)
48 #define CRYPTO_NULL CRYPTO_CMD(0) /* no operation */
49 #define CRYPTO_ASSOC CRYPTO_CMD(1) /* association */
50 #define CRYPTO_CERT CRYPTO_CMD(2) /* certificate */
51 #define CRYPTO_COOK CRYPTO_CMD(3) /* cookie value */
52 #define CRYPTO_AUTO CRYPTO_CMD(4) /* autokey values */
53 #define CRYPTO_TAI CRYPTO_CMD(5) /* leapseconds table */
54 #define CRYPTO_SIGN CRYPTO_CMD(6) /* certificate sign */
55 #define CRYPTO_IFF CRYPTO_CMD(7) /* IFF identity scheme */
56 #define CRYPTO_GQ CRYPTO_CMD(8) /* GQ identity scheme */
57 #define CRYPTO_MV CRYPTO_CMD(9) /* MV identity scheme */
58 #define CRYPTO_RESP 0x80000000 /* response */
59 #define CRYPTO_ERROR 0x40000000 /* error */
62 * Autokey event codes
64 #define XEVNT_CMD(x) (CRPT_EVENT | (x))
65 #define XEVNT_OK XEVNT_CMD(0) /* success */
66 #define XEVNT_LEN XEVNT_CMD(1) /* bad field format or length */
67 #define XEVNT_TSP XEVNT_CMD(2) /* bad timestamp */
68 #define XEVNT_FSP XEVNT_CMD(3) /* bad filestamp */
69 #define XEVNT_PUB XEVNT_CMD(4) /* bad or missing public key */
70 #define XEVNT_MD XEVNT_CMD(5) /* unsupported digest type */
71 #define XEVNT_KEY XEVNT_CMD(6) /* unsupported identity type */
72 #define XEVNT_SGL XEVNT_CMD(7) /* bad signature length */
73 #define XEVNT_SIG XEVNT_CMD(8) /* signature not verified */
74 #define XEVNT_VFY XEVNT_CMD(9) /* certificate not verified */
75 #define XEVNT_PER XEVNT_CMD(10) /* host certificate expired */
76 #define XEVNT_CKY XEVNT_CMD(11) /* bad or missing cookie */
77 #define XEVNT_DAT XEVNT_CMD(12) /* bad or missing leapseconds table */
78 #define XEVNT_CRT XEVNT_CMD(13) /* bad or missing certificate */
79 #define XEVNT_ID XEVNT_CMD(14) /* bad or missing group key */
80 #define XEVNT_ERR XEVNT_CMD(15) /* protocol error */
81 #define XEVNT_SRV XEVNT_CMD(16) /* server certificate expired */
84 * Configuration codes
86 #define CRYPTO_CONF_NONE 0 /* nothing doing */
87 #define CRYPTO_CONF_PRIV 1 /* host keys file name */
88 #define CRYPTO_CONF_SIGN 2 /* signature keys file name */
89 #define CRYPTO_CONF_LEAP 3 /* leapseconds table file name */
90 #define CRYPTO_CONF_KEYS 4 /* keys directory path */
91 #define CRYPTO_CONF_CERT 5 /* certificate file name */
92 #define CRYPTO_CONF_RAND 6 /* random seed file name */
93 #define CRYPTO_CONF_TRST 7 /* specify trust */
94 #define CRYPTO_CONF_IFFPAR 8 /* IFF parameters file name */
95 #define CRYPTO_CONF_GQPAR 9 /* GQ parameters file name */
96 #define CRYPTO_CONF_MVPAR 10 /* GQ parameters file name */
97 #define CRYPTO_CONF_PW 11 /* private key password */
98 #define CRYPTO_CONF_IDENT 12 /* specify identity scheme */
101 * Miscellaneous crypto stuff
103 #define NTP_MAXSESSION 100 /* maximum session key list entries */
104 #define NTP_AUTOMAX 13 /* log2 default max session key life */
105 #define KEY_REVOKE 16 /* log2 default key revoke timeout */
106 #define NTP_MAXEXTEN 1024 /* maximum extension field size */
107 #define TAI_1972 10 /* initial TAI offset (s) */
110 * The autokey structure holds the values used to authenticate key IDs.
112 struct autokey { /* network byte order */
113 keyid_t key; /* key ID */
114 int32 seq; /* key number */
118 * The value structure holds variable length data such as public
119 * key, agreement parameters, public valule and leapsecond table.
120 * They are in network byte order.
122 struct value { /* network byte order */
123 tstamp_t tstamp; /* timestamp */
124 tstamp_t fstamp; /* filestamp */
125 u_int32 vallen; /* value length */
126 u_char *ptr; /* data pointer (various) */
127 u_int32 siglen; /* signature length */
128 u_char *sig; /* signature */
132 * The packet extension field structures are used to hold values
133 * and signatures in network byte order.
135 struct exten {
136 u_int32 opcode; /* opcode */
137 u_int32 associd; /* association ID */
138 u_int32 tstamp; /* timestamp */
139 u_int32 fstamp; /* filestamp */
140 u_int32 vallen; /* value length */
141 u_int32 pkt[1]; /* start of value field */
145 * The certificate info/value structure
147 struct cert_info {
148 struct cert_info *link; /* forward link */
149 u_int flags; /* flags that wave */
150 EVP_PKEY *pkey; /* generic key */
151 long version; /* X509 version */
152 int nid; /* signature/digest ID */
153 const EVP_MD *digest; /* message digest algorithm */
154 u_long serial; /* serial number */
155 tstamp_t first; /* not valid before */
156 tstamp_t last; /* not valid after */
157 char *subject; /* subject common name */
158 char *issuer; /* issuer common name */
159 u_char *grpkey; /* GQ group key */
160 u_int grplen; /* GQ group key length */
161 struct value cert; /* certificate/value */
165 * Cryptographic values
167 extern char *keysdir; /* crypto keys directory */
168 extern u_int crypto_flags; /* status word */
169 extern struct value hostval; /* host name/value */
170 extern struct cert_info *cinfo; /* host certificate information */
171 extern struct value tai_leap; /* leapseconds table */
172 #endif /* OPENSSL */