1 /* 2 * ntp_crypto.h - definitions for cryptographic operations 3 */ 4 #ifdef AUTOKEY 5 #include "global.h" 6 #include "md5.h" 7 #ifdef RSAREF 8 #include "rsaref.h" 9 #include "rsa.h" 10 11 #define EVP_SignInit(a, b) R_SignInit(a, b) 12 #define EVP_SignUpdate(a, b, c) R_SignUpdate(a, b, c); 13 #define EVP_SignFinal(a, b, c, d) R_SignFinal(a, b, c, d); 14 #define EVP_VerifyInit(a, b) R_VerifyInit(a, b) 15 #define EVP_VerifyUpdate(a, b, c) R_VerifyUpdate(a, b, c); 16 #define EVP_VerifyFinal(a, b, c, d) R_VerifyFinal(a, b, c, d); 17 18 #endif /* RSAREF */ 19 20 /* 21 * Cryptostatus word 22 */ 23 #define CRYPTO_FLAG_ENAB 0x01 /* crypto enable */ 24 #define CRYPTO_FLAG_RSA 0x02 /* public/private keys */ 25 #define CRYPTO_FLAG_CERT 0x04 /* certificate */ 26 #define CRYPTO_FLAG_DH 0x08 /* agreement parameters */ 27 #define CRYPTO_FLAG_TAI 0x10 /* leapseconds table */ 28 29 /* 30 * Extension field definitions 31 */ 32 #define CRYPTO_VN 1 /* current protocol version number */ 33 34 #define CRYPTO_NULL ((CRYPTO_VN << 8) | 0) /* no operation */ 35 #define CRYPTO_STAT ((CRYPTO_VN << 8) | 1) /* status */ 36 #define CRYPTO_ASSOC ((CRYPTO_VN << 8) | 2) /* association ID */ 37 #define CRYPTO_AUTO ((CRYPTO_VN << 8) | 3) /* autokey values */ 38 #define CRYPTO_PRIV ((CRYPTO_VN << 8) | 4) /* cookie value */ 39 #define CRYPTO_DHPAR ((CRYPTO_VN << 8) | 5) /* agreement params */ 40 #define CRYPTO_DH ((CRYPTO_VN << 8) | 6) /* public value */ 41 #define CRYPTO_NAME ((CRYPTO_VN << 8) | 7) /* host name/pub key */ 42 #define CRYPTO_CERT ((CRYPTO_VN << 8) | 8) /* PKI certificate */ 43 #define CRYPTO_TAI ((CRYPTO_VN << 8) | 9) /* leapseconds table */ 44 #define CRYPTO_RESP 0x8000 /* response */ 45 #define CRYPTO_ERROR 0x4000 /* error */ 46 47 #ifdef PUBKEY 48 /* 49 * Configuration codes 50 */ 51 #define CRYPTO_CONF_NONE 0 /* nothing doing */ 52 #define CRYPTO_CONF_FLAGS 1 /* initialize flags */ 53 #define CRYPTO_CONF_PRIV 2 /* load private key from file */ 54 #define CRYPTO_CONF_PUBL 3 /* load public key from file */ 55 #define CRYPTO_CONF_DH 4 /* load Diffie_Hellman pars from file */ 56 #define CRYPTO_CONF_LEAP 5 /* load leapsecond table */ 57 #define CRYPTO_CONF_KEYS 6 /* set keys directory path */ 58 #define CRYPTO_CONF_CERT 7 /* load PKI certificate from file */ 59 #endif /* PUBKEY */ 60 61 /* 62 * Function prototypes 63 */ 64 extern void crypto_recv P((struct peer *, struct recvbuf *)); 65 extern int crypto_xmit P((u_int32 *, int, u_int, keyid_t, 66 u_int)); 67 extern keyid_t session_key P((struct sockaddr_in *, struct 68 sockaddr_in *, keyid_t, keyid_t, 69 u_long)); 70 extern void make_keylist P((struct peer *, struct interface *)); 71 extern void key_expire P((struct peer *)); 72 extern void crypto_agree P((void)); 73 #ifdef PUBKEY 74 extern void crypto_config P((int, char *)); 75 extern void crypto_setup P((void)); 76 extern int crypto_public P((struct peer *, u_char *, u_int)); 77 #endif /* PUBKEY */ 78 79 /* 80 * Cryptographic values 81 */ 82 extern u_int crypto_flags; /* status word */ 83 #ifdef PUBKEY 84 extern R_DH_PARAMS dh_params; 85 extern struct value host; /* host name/public key */ 86 extern struct value certif; /* certificate */ 87 extern struct value dhparam; /* agreement parameters */ 88 extern struct value dhpub; /* public value */ 89 extern struct value tai_leap; /* leapseconds table */ 90 extern u_int crypto_flags; /* status word */ 91 extern u_int sys_tai; /* current UTC offset from TAI */ 92 #endif /* PUBKEY */ 93 #endif /* AUTOKEY */ 94