1 /* 2 C K U A T 2 . H -- Kerberos headers for C-Kermit 3 4 Copyright (C) 1985, 2009, 5 Trustees of Columbia University in the City of New York. 6 All rights reserved. See the C-Kermit COPYING.TXT file or the 7 copyright text in the ckcmai.c module for disclaimer and permissions. 8 9 Author: 10 Kerberos IV and V intergration. 11 Jeffrey E Altman (jaltman@secure-endpoints.com) 12 Secure Endpoints Inc., New York City 13 */ 14 /* 15 * Based on a concatenation of all necessary include files distributed with 16 * the Kerberos 5 NT Alpha 2 Telnet package from MIT. 17 */ 18 19 #ifndef KRB5_TELNET_H 20 #define KRB5_TELNET_H 21 /*- 22 * Copyright (c) 1991, 1993 23 * The Regents of the University of California. All rights reserved. 24 * 25 * Redistribution and use in source and binary forms, with or without 26 * modification, are permitted provided that the following conditions 27 * are met: 28 * 1. Redistributions of source code must retain the above copyright 29 * notice, this list of conditions and the following disclaimer. 30 * 2. Redistributions in binary form must reproduce the above copyright 31 * notice, this list of conditions and the following disclaimer in the 32 * documentation and/or other materials provided with the distribution. 33 * 3. All advertising materials mentioning features or use of this software 34 * must display the following acknowledgement: 35 * This product includes software developed by the University of 36 * California, Berkeley and its contributors. 37 * 4. Neither the name of the University nor the names of its contributors 38 * may be used to endorse or promote products derived from this software 39 * without specific prior written permission. 40 * 41 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 * SUCH DAMAGE. 52 * 53 * @(#)encrypt.h 8.1 (Berkeley) 6/4/93 54 */ 55 56 /* 57 * Copyright (C) 1990 by the Massachusetts Institute of Technology 58 * 59 * Export of this software from the United States of America may 60 * require a specific license from the United States Government. 61 * It is the responsibility of any person or organization contemplating 62 * export to obtain such a license before exporting. 63 * 64 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 65 * distribute this software and its documentation for any purpose and 66 * without fee is hereby granted, provided that the above copyright 67 * notice appear in all copies and that both that copyright notice and 68 * this permission notice appear in supporting documentation, and that 69 * the name of M.I.T. not be used in advertising or publicity pertaining 70 * to distribution of the software without specific, written prior 71 * permission. M.I.T. makes no representations about the suitability of 72 * this software for any purpose. It is provided "as is" without express 73 * or implied warranty. 74 */ 75 76 #ifdef CK_ENCRYPTION 77 78 #ifndef __ENCRYPTION__ 79 #define __ENCRYPTION__ 80 81 #define DIR_DECRYPT 1 82 #define DIR_ENCRYPT 2 83 84 #ifndef CK_DES_C 85 #ifndef NOBLOCKDEF 86 typedef unsigned char Block[8]; 87 #endif /* NOBLOCKDEF */ 88 typedef unsigned char *BlockT; 89 #ifndef KRB4 /* already defined in kerberosiv/des.h */ 90 typedef struct des_ks_struct { Block _; } Schedule[16]; 91 #else /* KRB4 */ 92 #ifndef OS2 93 #ifndef NOBLOCKDEF /* already defined in kerberosiv/des.h */ 94 typedef struct des_ks_struct { Block _; } Schedule[16]; 95 #endif /* NOBLOCKDEF */ 96 #endif /* OS2 */ 97 #endif /* KRB4 */ 98 99 #define VALIDKEY(key) (key[0]|key[1]|key[2]|key[3]|key[4]|key[5]|key[6]|key[7]) 100 101 #define SAMEKEY(k1, k2) (!memcmp((void *)k1, (void *)k2, sizeof(Block))) 102 #endif /* CK_DES_C */ 103 104 typedef struct _session_key { 105 short type; 106 int length; 107 unsigned char *data; 108 } Session_Key; 109 110 #ifdef __STDC__ 111 typedef struct { 112 char *name; 113 int type; 114 void (*output)(unsigned char *, int); 115 int (*input)(int); 116 void (*init)(int); 117 int (*start)(int, int); 118 int (*is)(unsigned char *, int); 119 int (*reply)(unsigned char *, int); 120 int (*session)(Session_Key *, int); 121 int (*keyid)(int, unsigned char *, int *); 122 void (*printsub)(unsigned char *, int, unsigned char *, int); 123 } Encryptions; 124 #if !defined(P) 125 #define P(x) x 126 #endif 127 #else 128 typedef struct { 129 char *name; 130 int type; 131 void (*output)(); 132 int (*input)(); 133 void (*init)(); 134 int (*start)(); 135 int (*is)(); 136 int (*reply)(); 137 int (*session)(); 138 int (*keyid)(); 139 void (*printsub)(); 140 } Encryptions; 141 #if !defined(P) 142 #define P(x) () 143 #endif 144 #endif 145 146 int encrypt_parse(unsigned char *, int); 147 148 #ifdef DEBUG 149 int printsub(char, unsigned char *, size_t); 150 #endif 151 152 #define SK_GENERIC 0 /* Just a string of bits */ 153 #define SK_DES 1 /* Matched Kerberos v5 ENCTYPE_DES */ 154 155 void encrypt_init P((kstream,int)); 156 Encryptions *findencryption P((int)); 157 void encrypt_send_support P((void)); 158 void encrypt_auto P((int)); 159 void decrypt_auto P((int)); 160 int encrypt_is P((unsigned char *, int)); 161 int encrypt_reply P((unsigned char *, int)); 162 void encrypt_start_input P((int)); 163 int encrypt_session_key P((Session_Key *, int)); 164 int encrypt_dont_support P((int)); 165 void encrypt_end_input P((void)); 166 void encrypt_start_output P((int)); 167 void encrypt_end_output P((void)); 168 void encrypt_send_request_start P((void)); 169 void encrypt_send_request_end P((void)); 170 void encrypt_send_end P((void)); 171 void encrypt_wait P((void)); 172 int encrypt_is_encrypting P((void)); 173 void encrypt_send_support P((void)); 174 int encrypt_send_keyid P((int, unsigned char *, int, int)); 175 176 int encrypt_cmd P((int, char **)); 177 void encrypt_display P((void)); 178 179 #ifdef CK_KERBEROS 180 void krbdes_encrypt P((unsigned char *, int)); 181 int krbdes_decrypt P((int)); 182 int krbdes_is P((unsigned char *, int)); 183 int krbdes_reply P((unsigned char *, int)); 184 void krbdes_init P((int)); 185 int krbdes_start P((int, int)); 186 void krbdes_session P((Session_Key *, int)); 187 void krbdes_printsub P((unsigned char *, int, unsigned char *, int)); 188 #endif /* CK_KERBEROS */ 189 190 void cfb64_encrypt P((unsigned char *, int)); 191 int cfb64_decrypt P((int)); 192 void cfb64_init P((int)); 193 int cfb64_start P((int, int)); 194 int cfb64_is P((unsigned char *, int)); 195 int cfb64_reply P((unsigned char *, int)); 196 int cfb64_session P((Session_Key *, int)); 197 int cfb64_keyid P((int, unsigned char *, int *)); 198 void cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 199 200 void ofb64_encrypt P((unsigned char *, int)); 201 int ofb64_decrypt P((int)); 202 void ofb64_init P((int)); 203 int ofb64_start P((int, int)); 204 int ofb64_is P((unsigned char *, int)); 205 int ofb64_reply P((unsigned char *, int)); 206 int ofb64_session P((Session_Key *, int)); 207 int ofb64_keyid P((int, unsigned char *, int *)); 208 void ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 209 210 void des3_cfb64_encrypt P((unsigned char *, int)); 211 int des3_cfb64_decrypt P((int)); 212 void des3_cfb64_init P((int)); 213 int des3_cfb64_start P((int, int)); 214 int des3_cfb64_is P((unsigned char *, int)); 215 int des3_cfb64_reply P((unsigned char *, int)); 216 int des3_cfb64_session P((Session_Key *, int)); 217 int des3_cfb64_keyid P((int, unsigned char *, int *)); 218 void des3_cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 219 220 void des3_ofb64_encrypt P((unsigned char *, int)); 221 int des3_ofb64_decrypt P((int)); 222 void des3_ofb64_init P((int)); 223 int des3_ofb64_start P((int, int)); 224 int des3_ofb64_is P((unsigned char *, int)); 225 int des3_ofb64_reply P((unsigned char *, int)); 226 int des3_ofb64_session P((Session_Key *, int)); 227 int des3_ofb64_keyid P((int, unsigned char *, int *)); 228 void des3_ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 229 230 #ifdef CAST_ENCRYPTION 231 void cast_cfb64_encrypt P((unsigned char *, int)); 232 int cast_cfb64_decrypt P((int)); 233 void cast_cfb64_init P((int)); 234 int cast_cfb64_start P((int, int)); 235 int cast_cfb64_is P((unsigned char *, int)); 236 int cast_cfb64_reply P((unsigned char *, int)); 237 int cast_cfb64_session P((Session_Key *, int)); 238 int cast_cfb64_keyid P((int, unsigned char *, int *)); 239 void cast_cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 240 241 void cast_ofb64_encrypt P((unsigned char *, int)); 242 int cast_ofb64_decrypt P((int)); 243 void cast_ofb64_init P((int)); 244 int cast_ofb64_start P((int, int)); 245 int cast_ofb64_is P((unsigned char *, int)); 246 int cast_ofb64_reply P((unsigned char *, int)); 247 int cast_ofb64_session P((Session_Key *, int)); 248 int cast_ofb64_keyid P((int, unsigned char *, int *)); 249 void cast_ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 250 251 void castexp_cfb64_encrypt P((unsigned char *, int)); 252 int castexp_cfb64_decrypt P((int)); 253 void castexp_cfb64_init P((int)); 254 int castexp_cfb64_start P((int, int)); 255 int castexp_cfb64_is P((unsigned char *, int)); 256 int castexp_cfb64_reply P((unsigned char *, int)); 257 int castexp_cfb64_session P((Session_Key *, int)); 258 int castexp_cfb64_keyid P((int, unsigned char *, int *)); 259 void castexp_cfb64_printsub P((unsigned char *, int, unsigned char *, int)); 260 261 void castexp_ofb64_encrypt P((unsigned char *, int)); 262 int castexp_ofb64_decrypt P((int)); 263 void castexp_ofb64_init P((int)); 264 int castexp_ofb64_start P((int, int)); 265 int castexp_ofb64_is P((unsigned char *, int)); 266 int castexp_ofb64_reply P((unsigned char *, int)); 267 int castexp_ofb64_session P((Session_Key *, int)); 268 int castexp_ofb64_keyid P((int, unsigned char *, int *)); 269 void castexp_ofb64_printsub P((unsigned char *, int, unsigned char *, int)); 270 #endif /* CAST_ENCRYPTION */ 271 272 /* int des_string_to_key P((char *, Block)); */ 273 274 #ifdef DEBUG 275 extern int encrypt_debug_mode; 276 #endif 277 278 int decrypt_ks_hack(unsigned char *, int); 279 280 #endif /* __ENCRYPTION__ */ 281 #endif /* ENCRYPTION */ 282 283 #ifdef CRYPT_DLL 284 struct _crypt_dll_init { 285 int version; 286 287 /* Version 1 variables */ 288 int (*p_ttol)(char *,int); 289 int (*p_dodebug)(int,char *,char *,CK_OFF_T); 290 int (*p_dohexdump)(char *,char *,int); 291 void (*p_tn_debug)(char *); 292 int (*p_vscrnprintf)(char *, ...); 293 294 /* Version 2 variables */ 295 void * p_k5_context; 296 297 /* Version 3 variables */ 298 void (*p_install_funcs)(char *,void *); 299 300 /* Version 5 variables */ 301 unsigned long (*p_reqtelmutex)(unsigned long); 302 unsigned long (*p_reltelmutex)(void); 303 }; 304 #endif /* CRYPT_DLL */ 305 306 /* per Kerberos v5 protocol spec */ 307 #ifndef ENCTYPE_NULL 308 #define ENCTYPE_NULL 0x0000 309 #endif 310 #ifndef ENCTYPE_DES_CBC_CRC 311 #define ENCTYPE_DES_CBC_CRC 0x0001 /* DES cbc mode with CRC-32 */ 312 #endif 313 #ifndef ENCTYPE_DES_CBC_MD4 314 #define ENCTYPE_DES_CBC_MD4 0x0002 /* DES cbc mode with RSA-MD4 */ 315 #endif 316 #ifndef ENCTYPE_DES_CBC_MD5 317 #define ENCTYPE_DES_CBC_MD5 0x0003 /* DES cbc mode with RSA-MD5 */ 318 #endif 319 #ifndef ENCTYPE_DES_CBC_RAW 320 #define ENCTYPE_DES_CBC_RAW 0x0004 /* DES cbc mode raw */ 321 #endif 322 /* XXX deprecated? */ 323 #ifndef ENCTYPE_DES3_CBC_SHA 324 #define ENCTYPE_DES3_CBC_SHA 0x0005 /* DES-3 cbc mode with NIST-SHA */ 325 #endif 326 #ifndef ENCTYPE_DES3_CBC_RAW 327 #define ENCTYPE_DES3_CBC_RAW 0x0006 /* DES-3 cbc mode raw */ 328 #endif 329 #ifndef ENCTYPE_DES_HMAC_SHA1 330 #define ENCTYPE_DES_HMAC_SHA1 0x0008 331 #endif 332 #ifndef ENCTYPE_DES3_CBC_SHA1 333 #define ENCTYPE_DES3_CBC_SHA1 0x0010 334 #endif 335 #ifndef ENCTYPE_AES128_CTS_HMAC_SHA1_96 336 #define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011 337 #endif 338 #ifndef ENCTYPE_AES256_CTS_HMAC_SHA1_96 339 #define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012 340 #endif 341 #ifndef ENCTYPE_ARCFOUR_HMAC 342 #define ENCTYPE_ARCFOUR_HMAC 0x0017 343 #endif 344 #ifndef ENCTYPE_ARCFOUR_HMAC_EXP 345 #define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018 346 #endif 347 #ifndef ENCTYPE_LOCAL_RC4_MD4 348 #define ENCTYPE_LOCAL_RC4_MD4 0xFFFFFF80 349 #endif 350 #ifndef ENCTYPE_UNKNOWN 351 #define ENCTYPE_UNKNOWN 0x01ff 352 #endif 353 /* local crud */ 354 /* marc's DES-3 with 32-bit length */ 355 #ifndef ENCTYPE_LOCAL_DES3_HMAC_SHA1 356 #define ENCTYPE_LOCAL_DES3_HMAC_SHA1 0x7007 357 #endif 358 #endif /* KRB5_TELNET_H */ 359