1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZFormatAuthenticNotice function.
4 * Created by: Robert French
8 * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
14 static const char rcsid_ZFormatAuthenticNotice_c[] = "$Id$";
21 ZFormatAuthenticNotice(ZNotice_t *notice,
33 newnotice.z_authent_len = 0;
34 newnotice.z_ascii_authent = "";
36 if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
37 &hdrlen, &ptr, NULL)) != ZERR_NONE)
40 newnotice.z_checksum =
41 (ZChecksum_t)des_quad_cksum((unsigned char *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
43 if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
44 &hdrlen, NULL, NULL)) != ZERR_NONE)
49 if (newnotice.z_message_len+hdrlen > buffer_len)
52 (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
54 *len = hdrlen+newnotice.z_message_len;
56 if (*len > Z_MAXPKTLEN)
65 ZFormatAuthenticNoticeV5(ZNotice_t *notice,
66 register char *buffer,
67 register int buffer_len,
69 krb5_keyblock *keyblock)
73 int retval, hdrlen, hdr_adj;
75 krb5_cksumtype cksumtype;
77 char *cksum_start, *cstart, *cend;
80 key_len = Z_keylen(keyblock);
81 retval = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
83 return (ZAUTH_FAILED);
86 if (key_len == 8 && (enctype == ENCTYPE_DES_CBC_CRC ||
87 enctype == ENCTYPE_DES_CBC_MD4 ||
88 enctype == ENCTYPE_DES_CBC_MD5)) {
90 memcpy(&tmp, Z_keydata(keyblock), key_len);
91 return ZFormatAuthenticNotice(notice, buffer, buffer_len, len,
98 newnotice.z_authent_len = 0;
99 newnotice.z_ascii_authent = "";
101 if ((retval = Z_NewFormatRawHeader(&newnotice, buffer, buffer_len,
103 &cksum_start, &cksum_len, &cstart,
104 &cend)) != ZERR_NONE)
107 /* we know this is only called by the server */
108 retval = Z_InsertZcodeChecksum(keyblock, &newnotice, buffer,
109 cksum_start, cksum_len, cstart, cend,
110 buffer_len, &hdr_adj, 1);
118 if (newnotice.z_message_len+hdrlen > buffer_len)
119 return (ZERR_PKTLEN);
121 (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
123 *len = hdrlen+newnotice.z_message_len;
125 if (*len > Z_MAXPKTLEN)
126 return (ZERR_PKTLEN);