1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZCheckAuthentication function.
4 * Created by: Robert French
7 * $Author: warmenhoven $
9 * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
16 static char rcsid_ZCheckAuthentication_c
[] =
17 "$Zephyr: /mit/zephyr/src/lib/RCS/ZCheckAuthentication.c,v 1.14 89/03/24 14:17:38 jtkohl Exp Locker: raeburn $";
22 /* Check authentication of the notice.
23 If it looks authentic but fails the Kerberos check, return -1.
24 If it looks authentic and passes the Kerberos check, return 1.
25 If it doesn't look authentic, return 0
27 When not using Kerberos, return true if the notice claims to be authentic.
28 Only used by clients; the server uses its own routine.
30 Code_t
ZCheckAuthentication(notice
, from
)
32 struct sockaddr_in
*from
;
34 #ifdef ZEPHYR_USES_KERBEROS
36 ZChecksum_t our_checksum
;
39 /* If the value is already known, return it. */
40 if (notice
->z_checked_auth
!= ZAUTH_UNSET
)
41 return (notice
->z_checked_auth
);
46 if ((result
= krb_get_cred(SERVER_SERVICE
, SERVER_INSTANCE
,
47 __Zephyr_realm
, &cred
)) != 0)
53 our_checksum
= des_quad_cksum(notice
->z_packet
, NULL
,
54 notice
->z_default_format
+
55 strlen(notice
->z_default_format
)+1-
56 notice
->z_packet
, 0, cred
.session
);
58 /* if mismatched checksum, then the packet was corrupted */
59 return ((our_checksum
== notice
->z_checksum
) ? ZAUTH_YES
: ZAUTH_FAILED
);
62 return (notice
->z_auth
? ZAUTH_YES
: ZAUTH_NO
);