2 * Copyright 1993 by OpenVision Technologies, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appears in all copies and
7 * that both that copyright notice and this permission notice appear in
8 * supporting documentation, and that the name of OpenVision not be used
9 * in advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. OpenVision makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #include "gssapiP_krb5.h"
27 kg_checksum_channel_bindings(cb, cksum, bigend)
28 gss_channel_bindings_t cb;
36 if (!kg_context && (code=kg_get_context()))
39 /* generate a buffer full of zeros if no cb specified */
41 if (cb == GSS_C_NO_CHANNEL_BINDINGS) {
42 /* allocate the cksum contents buffer */
43 if ((cksum->contents = (krb5_octet *)
44 xmalloc(krb5_checksum_size(context, CKSUMTYPE_RSA_MD5))) == NULL)
47 cksum->checksum_type = CKSUMTYPE_RSA_MD5;
48 memset(cksum->contents, '\0',
49 (cksum->length = krb5_checksum_size(kg_context, CKSUMTYPE_RSA_MD5)));
53 /* create the buffer to checksum into */
55 len = (sizeof(long)*5+
56 cb->initiator_address.length+
57 cb->acceptor_address.length+
58 cb->application_data.length);
60 if ((buf = (char *) xmalloc(len)) == NULL)
63 /* allocate the cksum contents buffer */
64 if ((cksum->contents = (krb5_octet *)
65 xmalloc(krb5_checksum_size(context, CKSUMTYPE_RSA_MD5))) == NULL) {
70 /* helper macros. This code currently depends on a long being 32
71 bits, and htonl dtrt. */
75 TWRITE_INT(ptr, cb->initiator_addrtype, bigend);
76 TWRITE_BUF(ptr, cb->initiator_address, bigend);
77 TWRITE_INT(ptr, cb->acceptor_addrtype, bigend);
78 TWRITE_BUF(ptr, cb->acceptor_address, bigend);
79 TWRITE_BUF(ptr, cb->application_data, bigend);
81 /* checksum the data */
83 if (code = krb5_calculate_checksum(kg_context, CKSUMTYPE_RSA_MD5,
84 buf, len, NULL, 0, cksum)) {
85 xfree(cksum->contents);