/* This file is part of the Project Athena Zephyr Notification System. * It contains source for the ZMakeAuthentication function. * Created by: Robert French * Copyright (c) 1987 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file #ifndef ERROR_TABLE_BASE_krb #define ERROR_TABLE_BASE_krb (39525376L) #ifdef ZEPHYR_USES_KERBEROS static long last_authent_time = 0L; static KTEXT_ST last_authent; Code_t ZResetAuthentication () { #ifdef ZEPHYR_USES_KERBEROS Code_t ZMakeAuthentication(notice, buffer, buffer_len, len) register ZNotice_t *notice; #ifdef ZEPHYR_USES_KERBEROS extern unsigned long des_quad_cksum(); if (last_authent_time == 0 || (now - last_authent_time > 120)) { result = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE, __Zephyr_realm, 0); if (result != MK_AP_OK) { return (result+ERROR_TABLE_BASE_krb); notice->z_authent_len = authent.length; notice->z_ascii_authent = (char *)malloc((unsigned)authent.length*3); /* zero length authent is an error, so malloc(0) is not a problem */ if (!notice->z_ascii_authent) if ((result = ZMakeAscii(notice->z_ascii_authent, authent.length)) != ZERR_NONE) { free(notice->z_ascii_authent); result = Z_FormatRawHeader(notice, buffer, buffer_len, len, &cstart, free(notice->z_ascii_authent); notice->z_authent_len = 0; /* Compute a checksum over the header and message. */ if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, __Zephyr_realm, &cred)) != 0) checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, (C_Block *)cred.session); checksum ^= des_quad_cksum(cend, NULL, buffer + *len - cend, 0, (C_Block *)cred.session); checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len, 0, (C_Block *)cred.session); notice->z_checksum = checksum; ZMakeAscii32(cstart, buffer + buffer_len - cstart, checksum); notice->z_authent_len = 0; notice->z_ascii_authent = ""; return (Z_FormatRawHeader(notice, buffer, buffer_len, len, NULL, NULL));