1 /*
2  * Copyright (c) 1997, 1998 Kungliga Tekniska H�gskolan
3  * (Royal Institute of Technology, Stockholm, Sweden).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Kungliga Tekniska
20  *      H�gskolan and its contributors.
21  *
22  * 4. Neither the name of the Institute nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  */
38 
39 /* $Id: krb-protos.h,v 1.2 2001/12/04 02:06:08 rjs3 Exp $ */
40 
41 #ifndef __krb_protos_h__
42 #define __krb_protos_h__
43 
44 #if defined (__STDC__) || defined (_MSC_VER)
45 #include <stdarg.h>
46 #ifndef __P
47 #define __P(x) x
48 #endif
49 #else
50 #ifndef __P
51 #define __P(x) ()
52 #endif
53 #endif
54 
55 #ifdef __STDC__
56 struct in_addr;
57 struct sockaddr_in;
58 struct timeval;
59 #endif
60 
61 #ifndef KRB_LIB_FUNCTION
62 #if defined(__BORLANDC__)
63 #define KRB_LIB_FUNCTION /* not-ready-definition-yet */
64 #elif defined(_MSC_VER)
65 #define KRB_LIB_FUNCTION /* not-ready-definition-yet2 */
66 #else
67 #define KRB_LIB_FUNCTION
68 #endif
69 #endif
70 
71 void KRB_LIB_FUNCTION
72 afs_string_to_key __P((
73 	char *str,
74 	char *cell,
75 	des_cblock *key));
76 
77 int KRB_LIB_FUNCTION
78 create_ciph __P((
79 	KTEXT c,
80 	unsigned char *session,
81 	char *service,
82 	char *instance,
83 	char *realm,
84 	u_int32_t life,
85 	int kvno,
86 	KTEXT tkt,
87 	u_int32_t kdc_time,
88 	des_cblock *key));
89 
90 int KRB_LIB_FUNCTION
91 cr_err_reply __P((
92 	KTEXT pkt,
93 	char *pname,
94 	char *pinst,
95 	char *prealm,
96 	u_int32_t time_ws,
97 	u_int32_t e,
98 	char *e_string));
99 
100 int KRB_LIB_FUNCTION
101 decomp_ticket __P((
102 	KTEXT tkt,
103 	unsigned char *flags,
104 	char *pname,
105 	char *pinstance,
106 	char *prealm,
107 	u_int32_t *paddress,
108 	unsigned char *session,
109 	int *life,
110 	u_int32_t *time_sec,
111 	char *sname,
112 	char *sinstance,
113 	des_cblock *key,
114 	des_key_schedule schedule));
115 
116 int KRB_LIB_FUNCTION
117 dest_tkt __P((void));
118 
119 int KRB_LIB_FUNCTION
120 get_ad_tkt __P((
121 	char *service,
122 	char *sinstance,
123 	char *realm,
124 	int lifetime));
125 
126 int KRB_LIB_FUNCTION
127 getst __P((
128 	int fd,
129 	char *s,
130 	int n));
131 
132 int KRB_LIB_FUNCTION
133 in_tkt __P((
134 	char *pname,
135 	char *pinst));
136 
137 int KRB_LIB_FUNCTION
138 k_get_all_addrs __P((struct in_addr **l));
139 
140 int KRB_LIB_FUNCTION
141 k_gethostname __P((
142 	char *name,
143 	int namelen));
144 
145 int KRB_LIB_FUNCTION
146 k_getportbyname __P((
147 	const char *service,
148 	const char *proto,
149 	int default_port));
150 
151 int KRB_LIB_FUNCTION
152 k_getsockinst __P((
153 	int fd,
154 	char *inst,
155 	size_t inst_size));
156 
157 int KRB_LIB_FUNCTION
158 k_isinst __P((char *s));
159 
160 int KRB_LIB_FUNCTION
161 k_isname __P((char *s));
162 
163 int KRB_LIB_FUNCTION
164 k_isrealm __P((char *s));
165 
166 struct tm * KRB_LIB_FUNCTION
167 k_localtime __P((u_int32_t *tp));
168 
169 int KRB_LIB_FUNCTION
170 kname_parse __P((
171 	char *np,
172 	char *ip,
173 	char *rp,
174 	char *fullname));
175 
176 int KRB_LIB_FUNCTION
177 krb_atime_to_life __P((char *atime));
178 
179 int KRB_LIB_FUNCTION
180 krb_check_auth __P((
181 	KTEXT packet,
182 	u_int32_t checksum,
183 	MSG_DAT *msg_data,
184 	des_cblock *session,
185 	struct des_ks_struct *schedule,
186 	struct sockaddr_in *laddr,
187 	struct sockaddr_in *faddr));
188 
189 int KRB_LIB_FUNCTION
190 krb_check_tm __P((struct tm tm));
191 
192 KTEXT KRB_LIB_FUNCTION
193 krb_create_death_packet __P((char *a_name));
194 
195 int KRB_LIB_FUNCTION
196 krb_create_ticket __P((
197 	KTEXT tkt,
198 	unsigned char flags,
199 	char *pname,
200 	char *pinstance,
201 	char *prealm,
202 	int32_t paddress,
203 	void *session,
204 	int16_t life,
205 	int32_t time_sec,
206 	char *sname,
207 	char *sinstance,
208 	des_cblock *key));
209 
210 int KRB_LIB_FUNCTION
211 krb_decode_as_rep __P((
212 	char *user,
213 	char *instance,
214 	char *realm,
215 	char *service,
216 	char *sinstance,
217 	key_proc_t key_proc,
218 	decrypt_proc_t decrypt_proc,
219 	void *arg,
220 	KTEXT as_rep,
221 	CREDENTIALS *cred));
222 
223 int KRB_LIB_FUNCTION
224 krb_enable_debug __P((void));
225 
226 int KRB_LIB_FUNCTION
227 krb_equiv __P((
228 	u_int32_t a,
229 	u_int32_t b));
230 
231 int KRB_LIB_FUNCTION
232 krb_get_address __P((
233 	void *from,
234 	u_int32_t *to));
235 
236 int KRB_LIB_FUNCTION
237 krb_get_admhst __P((
238 	char *host,
239 	char *realm,
240 	int nth));
241 
242 int KRB_LIB_FUNCTION
243 krb_get_config_bool __P((const char *variable));
244 
245 const char * KRB_LIB_FUNCTION
246 krb_get_config_string __P((const char *variable));
247 
248 int KRB_LIB_FUNCTION
249 krb_get_cred __P((
250         char *service,
251         char *instance,
252         char *realm,
253         CREDENTIALS *c));
254 
255 int KRB_LIB_FUNCTION
256 krb_get_default_principal __P((
257 	char *name,
258 	char *instance,
259 	char *realm));
260 
261 char * KRB_LIB_FUNCTION
262 krb_get_default_realm __P((void));
263 
264 const char * KRB_LIB_FUNCTION
265 krb_get_err_text __P((int code));
266 
267 struct krb_host* KRB_LIB_FUNCTION
268 krb_get_host __P((
269 	int nth,
270 	char *realm,
271 	int admin));
272 
273 int KRB_LIB_FUNCTION
274 krb_get_in_tkt __P((
275 	char *user,
276 	char *instance,
277 	char *realm,
278 	char *service,
279 	char *sinstance,
280 	int life,
281 	key_proc_t key_proc,
282 	decrypt_proc_t decrypt_proc,
283 	void *arg));
284 
285 int KRB_LIB_FUNCTION
286 krb_get_int __P((
287 	void *f,
288 	u_int32_t *to,
289 	int size,
290 	int lsb));
291 
292 int KRB_LIB_FUNCTION
293 krb_get_kdc_time_diff __P((void));
294 
295 int KRB_LIB_FUNCTION
296 krb_get_krbconf __P((
297 	int num,
298 	char *buf,
299 	size_t len));
300 
301 int KRB_LIB_FUNCTION
302 krb_get_krbextra __P((
303 	int num,
304 	char *buf,
305 	size_t len));
306 
307 int KRB_LIB_FUNCTION
308 krb_get_krbhst __P((
309 	char *host,
310 	char *realm,
311 	int nth));
312 
313 int KRB_LIB_FUNCTION
314 krb_get_krbrealms __P((
315 	int num,
316 	char *buf,
317 	size_t len));
318 
319 int KRB_LIB_FUNCTION
320 krb_get_lrealm __P((
321 	char *r,
322 	int n));
323 
324 int KRB_LIB_FUNCTION
325 krb_get_nir __P((
326 	void *from,
327 	char *name,
328 	char *instance,
329 	char *realm));
330 
331 char * KRB_LIB_FUNCTION
332 krb_get_phost __P((const char *alias));
333 
334 int KRB_LIB_FUNCTION
335 krb_get_pw_in_tkt __P((
336 	char *user,
337 	char *instance,
338 	char *realm,
339 	char *service,
340 	char *sinstance,
341 	int life,
342 	char *password));
343 
344 int KRB_LIB_FUNCTION
345 krb_get_pw_in_tkt2 __P((
346 	char *user,
347 	char *instance,
348 	char *realm,
349 	char *service,
350 	char *sinstance,
351 	int life,
352 	char *password,
353 	des_cblock *key));
354 
355 int KRB_LIB_FUNCTION
356 krb_get_string __P((
357 	void *from,
358 	char *to,
359 	size_t to_size));
360 
361 int KRB_LIB_FUNCTION
362 krb_get_svc_in_tkt __P((
363 	char *user,
364 	char *instance,
365 	char *realm,
366 	char *service,
367 	char *sinstance,
368 	int life,
369 	char *srvtab));
370 
371 int KRB_LIB_FUNCTION
372 krb_get_tf_fullname __P((
373 	char *ticket_file,
374 	char *name,
375 	char *instance,
376 	char *realm));
377 
378 int KRB_LIB_FUNCTION
379 krb_get_tf_realm __P((
380 	char *ticket_file,
381 	char *realm));
382 
383 void KRB_LIB_FUNCTION
384 krb_kdctimeofday __P((struct timeval *tv));
385 
386 int KRB_LIB_FUNCTION
387 krb_kntoln __P((
388 	AUTH_DAT *ad,
389 	char *lname));
390 
391 int KRB_LIB_FUNCTION
392 krb_kuserok __P((
393 	char *name,
394 	char *instance,
395 	char *realm,
396 	char *luser));
397 
398 char * KRB_LIB_FUNCTION
399 krb_life_to_atime __P((int life));
400 
401 u_int32_t KRB_LIB_FUNCTION
402 krb_life_to_time __P((
403 	u_int32_t start,
404 	int life_));
405 
406 int KRB_LIB_FUNCTION
407 krb_lsb_antinet_ulong_cmp __P((
408 	u_int32_t x,
409 	u_int32_t y));
410 
411 int KRB_LIB_FUNCTION
412 krb_lsb_antinet_ushort_cmp __P((
413 	u_int16_t x,
414 	u_int16_t y));
415 
416 int KRB_LIB_FUNCTION
417 krb_mk_as_req __P((
418 	char *user,
419 	char *instance,
420 	char *realm,
421 	char *service,
422 	char *sinstance,
423 	int life,
424 	KTEXT cip));
425 
426 int KRB_LIB_FUNCTION
427 krb_mk_auth __P((
428 	int32_t options,
429 	KTEXT ticket,
430 	char *service,
431 	char *instance,
432 	char *realm,
433 	u_int32_t checksum,
434 	char *version,
435 	KTEXT buf));
436 
437 int32_t KRB_LIB_FUNCTION
438 krb_mk_err __P((
439 	u_char *p,
440 	int32_t e,
441 	char *e_string));
442 
443 int32_t KRB_LIB_FUNCTION
444 krb_mk_priv __P((
445 	void *in,
446 	void *out,
447 	u_int32_t length,
448 	struct des_ks_struct *schedule,
449 	des_cblock *key,
450 	struct sockaddr_in *sender,
451 	struct sockaddr_in *receiver));
452 
453 int KRB_LIB_FUNCTION
454 krb_mk_req __P((
455 	KTEXT authent,
456 	char *service,
457 	char *instance,
458 	char *realm,
459 	int32_t checksum));
460 
461 int32_t KRB_LIB_FUNCTION
462 krb_mk_safe __P((
463 	void *in,
464 	void *out,
465 	u_int32_t length,
466 	des_cblock *key,
467 	struct sockaddr_in *sender,
468 	struct sockaddr_in *receiver));
469 
470 int KRB_LIB_FUNCTION
471 krb_net_read __P((
472 	int fd,
473 	void *v,
474 	size_t len));
475 
476 int KRB_LIB_FUNCTION
477 krb_net_write __P((
478 	int fd,
479 	const void *v,
480 	size_t len));
481 
482 int KRB_LIB_FUNCTION
483 krb_parse_name __P((
484 	const char *fullname,
485 	krb_principal *principal));
486 
487 int KRB_LIB_FUNCTION
488 krb_put_address __P((
489 	u_int32_t addr,
490 	void *to,
491 	size_t rem));
492 
493 int KRB_LIB_FUNCTION
494 krb_put_int __P((
495 	u_int32_t from,
496 	void *to,
497 	size_t rem,
498 	int size));
499 
500 int KRB_LIB_FUNCTION
501 krb_put_nir __P((
502 	char *name,
503 	char *instance,
504 	char *realm,
505 	void *to,
506 	size_t rem));
507 
508 int KRB_LIB_FUNCTION
509 krb_put_string __P((
510 	char *from,
511 	void *to,
512 	size_t rem));
513 
514 int KRB_LIB_FUNCTION
515 krb_rd_err __P((
516 	u_char *in,
517 	u_int32_t in_length,
518 	int32_t *code,
519 	MSG_DAT *m_data));
520 
521 int32_t KRB_LIB_FUNCTION
522 krb_rd_priv __P((
523 	void *in,
524 	u_int32_t in_length,
525 	struct des_ks_struct *schedule,
526 	des_cblock *key,
527 	struct sockaddr_in *sender,
528 	struct sockaddr_in *receiver,
529 	MSG_DAT *m_data));
530 
531 int KRB_LIB_FUNCTION
532 krb_rd_req __P((
533 	KTEXT authent,
534 	char *service,
535 	char *instance,
536 	int32_t from_addr,
537 	AUTH_DAT *ad,
538 	char *fn));
539 
540 int32_t KRB_LIB_FUNCTION
541 krb_rd_safe __P((
542 	void *in,
543 	u_int32_t in_length,
544 	des_cblock *key,
545 	struct sockaddr_in *sender,
546 	struct sockaddr_in *receiver,
547 	MSG_DAT *m_data));
548 
549 int KRB_LIB_FUNCTION
550 krb_realm_parse __P((
551 	char *realm,
552 	int length));
553 
554 char * KRB_LIB_FUNCTION
555 krb_realmofhost __P((const char *host));
556 
557 int KRB_LIB_FUNCTION
558 krb_recvauth __P((
559 	int32_t options,
560 	int fd,
561 	KTEXT ticket,
562 	char *service,
563 	char *instance,
564 	struct sockaddr_in *faddr,
565 	struct sockaddr_in *laddr,
566 	AUTH_DAT *kdata,
567 	char *filename,
568 	struct des_ks_struct *schedule,
569 	char *version));
570 
571 int KRB_LIB_FUNCTION
572 krb_sendauth __P((
573 	int32_t options,
574 	int fd,
575 	KTEXT ticket,
576 	char *service,
577 	char *instance,
578 	char *realm,
579 	u_int32_t checksum,
580 	MSG_DAT *msg_data,
581 	CREDENTIALS *cred,
582 	struct des_ks_struct *schedule,
583 	struct sockaddr_in *laddr,
584 	struct sockaddr_in *faddr,
585 	char *version));
586 
587 void KRB_LIB_FUNCTION
588 krb_set_kdc_time_diff __P((int diff));
589 
590 int KRB_LIB_FUNCTION
591 krb_set_key __P((
592 	void *key,
593 	int cvt));
594 
595 int KRB_LIB_FUNCTION
596 krb_set_lifetime __P((int newval));
597 
598 void KRB_LIB_FUNCTION
599 krb_set_tkt_string __P((const char *val));
600 
601 const char * KRB_LIB_FUNCTION
602 krb_stime __P((time_t *t));
603 
604 int KRB_LIB_FUNCTION
605 krb_time_to_life __P((
606 	u_int32_t start,
607 	u_int32_t end));
608 
609 char * KRB_LIB_FUNCTION
610 krb_unparse_name __P((krb_principal *pr));
611 
612 char * KRB_LIB_FUNCTION
613 krb_unparse_name_long __P((
614 	char *name,
615 	char *instance,
616 	char *realm));
617 
618 char * KRB_LIB_FUNCTION
619 krb_unparse_name_long_r __P((
620 	char *name,
621 	char *instance,
622 	char *realm,
623 	char *fullname));
624 
625 char * KRB_LIB_FUNCTION
626 krb_unparse_name_r __P((
627 	krb_principal *pr,
628 	char *fullname));
629 
630 int KRB_LIB_FUNCTION
631 krb_use_admin_server __P((int flag));
632 
633 int KRB_LIB_FUNCTION
634 krb_verify_user __P((
635 	char *name,
636 	char *instance,
637 	char *realm,
638 	char *password,
639 	int secure,
640 	char *linstance));
641 
642 int KRB_LIB_FUNCTION
643 krb_verify_user_srvtab __P((
644 	char *name,
645 	char *instance,
646 	char *realm,
647 	char *password,
648 	int secure,
649 	char *linstance,
650 	char *srvtab));
651 
652 int KRB_LIB_FUNCTION
653 kuserok __P((
654 	AUTH_DAT *auth,
655 	char *luser));
656 
657 u_int32_t KRB_LIB_FUNCTION
658 lsb_time __P((
659 	time_t t,
660 	struct sockaddr_in *src,
661 	struct sockaddr_in *dst));
662 
663 const char * KRB_LIB_FUNCTION
664 month_sname __P((int n));
665 
666 int KRB_LIB_FUNCTION
667 passwd_to_5key __P((
668 	char *user,
669 	char *instance,
670 	char *realm,
671 	void *passwd,
672 	des_cblock *key));
673 
674 int KRB_LIB_FUNCTION
675 passwd_to_afskey __P((
676 	char *user,
677 	char *instance,
678 	char *realm,
679 	void *passwd,
680 	des_cblock *key));
681 
682 int KRB_LIB_FUNCTION
683 passwd_to_key __P((
684 	char *user,
685 	char *instance,
686 	char *realm,
687 	void *passwd,
688 	des_cblock *key));
689 
690 int KRB_LIB_FUNCTION
691 read_service_key __P((
692 	char *service,
693 	char *instance,
694 	char *realm,
695 	int kvno,
696 	char *file,
697 	char *key));
698 
699 int KRB_LIB_FUNCTION
700 save_credentials __P((
701 	char *service,
702 	char *instance,
703 	char *realm,
704 	unsigned char *session,
705 	int lifetime,
706 	int kvno,
707 	KTEXT ticket,
708 	int32_t issue_date));
709 
710 int KRB_LIB_FUNCTION
711 send_to_kdc __P((
712 	KTEXT pkt,
713 	KTEXT rpkt,
714 	char *realm));
715 
716 int KRB_LIB_FUNCTION
717 srvtab_to_key __P((
718 	char *user,
719 	char *instance,
720 	char *realm,
721 	void *srvtab,
722 	des_cblock *key));
723 
724 void KRB_LIB_FUNCTION
725 tf_close __P((void));
726 
727 int KRB_LIB_FUNCTION
728 tf_create __P((char *tf_name));
729 
730 int KRB_LIB_FUNCTION
731 tf_get_cred __P((CREDENTIALS *c));
732 
733 int KRB_LIB_FUNCTION
734 tf_get_pinst __P((char *inst));
735 
736 int KRB_LIB_FUNCTION
737 tf_get_pname __P((char *p));
738 
739 int KRB_LIB_FUNCTION
740 tf_init __P((
741 	char *tf_name,
742 	int rw));
743 
744 int KRB_LIB_FUNCTION
745 tf_put_pinst __P((char *inst));
746 
747 int KRB_LIB_FUNCTION
748 tf_put_pname __P((char *p));
749 
750 int KRB_LIB_FUNCTION
751 tf_save_cred __P((
752 	char *service,
753 	char *instance,
754 	char *realm,
755 	unsigned char *session,
756 	int lifetime,
757 	int kvno,
758 	KTEXT ticket,
759 	u_int32_t issue_date));
760 
761 int KRB_LIB_FUNCTION
762 tf_setup __P((
763 	CREDENTIALS *cred,
764 	char *pname,
765 	char *pinst));
766 
767 char * KRB_LIB_FUNCTION
768 tkt_string __P((void));
769 
770 #endif /* __krb_protos_h__ */
771