From 1a0e03eb19998ab496a6ea845ff2c42d9a02df0b Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Tue, 25 Dec 2007 00:56:08 +0000 Subject: applied athena-update-branch patch --- lib/ZFmtAuth.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) (limited to 'lib/ZFmtAuth.c') diff --git a/lib/ZFmtAuth.c b/lib/ZFmtAuth.c index c2d8a00..97a70f2 100644 --- a/lib/ZFmtAuth.c +++ b/lib/ZFmtAuth.c @@ -16,7 +16,7 @@ static char rcsid_ZFormatAuthenticNotice_c[] = "$Id$"; #include -#ifdef HAVE_KRB4 +#if defined(HAVE_KRB4) || defined(HAVE_KRB5) Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session) ZNotice_t *notice; register char *buffer; @@ -62,3 +62,71 @@ Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session) return (ZERR_NONE); } #endif + +#ifdef HAVE_KRB5 +Code_t ZFormatAuthenticNoticeV5(notice, buffer, buffer_len, len, keyblock) + ZNotice_t *notice; + register char *buffer; + register int buffer_len; + int *len; + krb5_keyblock *keyblock; +{ + ZNotice_t newnotice; + char *ptr; + int retval, hdrlen, hdr_adj; + krb5_enctype enctype; + krb5_cksumtype cksumtype; + int valid; + char *svcinst, *x, *y; + int key_len; + char *cksum_start, *cstart, *cend; + int cksum_len; + + key_len = Z_keylen(keyblock); + retval = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype); + if (retval) + return (ZAUTH_FAILED); + + if (key_len == 8 && (enctype == ENCTYPE_DES_CBC_CRC || + enctype == ENCTYPE_DES_CBC_MD4 || + enctype == ENCTYPE_DES_CBC_MD5)) { + C_Block tmp; + memcpy(&tmp, Z_keydata(keyblock), key_len); + return ZFormatAuthenticNotice(notice, buffer, buffer_len, len, + tmp); + } + + newnotice = *notice; + newnotice.z_auth = 1; + newnotice.z_authent_len = 0; + newnotice.z_ascii_authent = ""; + + if ((retval = Z_NewFormatRawHeader(&newnotice, buffer, buffer_len, + &hdrlen, + &cksum_start, &cksum_len, &cstart, + &cend)) != ZERR_NONE) + return (retval); + + retval = Z_InsertZcodeChecksum(keyblock, &newnotice, buffer, + cksum_start, cksum_len, cstart, cend, + buffer_len, &hdr_adj); + if (retval) + return retval; + + hdrlen += hdr_adj; + + ptr = buffer+hdrlen; + + if (newnotice.z_message_len+hdrlen > buffer_len) + return (ZERR_PKTLEN); + + (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len); + + *len = hdrlen+newnotice.z_message_len; + + if (*len > Z_MAXPKTLEN) + return (ZERR_PKTLEN); + + return (ZERR_NONE); +} +#endif -- cgit v1.2.3