40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * CDDL HEADER START
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * The contents of this file are subject to the terms of the
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Common Development and Distribution License (the "License").
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * You may not use this file except in compliance with the License.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * See the License for the specific language governing permissions
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * and limitations under the License.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * When distributing Covered Code, include this CDDL HEADER in each
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * If applicable, add the following below this CDDL HEADER, with the
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * fields enclosed by brackets "[]" replaced with your own identifying
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * information: Portions Copyright [yyyy] [name of copyright owner]
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * CDDL HEADER END
2c2c41837e330b002c4220a39638150db504fe0evi * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Use is subject to license terms.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#pragma ident "%Z%%M% %I% %E% SMI"
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vivoid sip_md5_hash(char *, int, char *, int, char *, int, char *, int,
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi char *, int, char *, int, uchar_t *);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Wrapper around /dev/urandom
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi return (-1);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi return (-1);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi return (0);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Get MD5 hash of call_id, from_tag, to_tag using key
40cb5e5daa7b80bb70fcf8dadfb20f9281566331visip_md5_hash(char *str1, int lstr1, char *str2, int lstr2, char *str3,
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sasl_MD5Update(&ctx, (uchar_t *)&sip_hash_salt, sizeof (uint64_t));
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#else /* solaris */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi MD5Update(&ctx, (uchar_t *)&sip_hash_salt, sizeof (uint64_t));
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * generate a guid (globally unique id)
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Get a 32-bit random #
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi if (sip_get_random((char *)&random, sizeof (random)) != 0)
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Get 32-bits from gethrtime()
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi (void) snprintf(guid, SIP_RANDOM_LEN + 1, "%u%u", random, time);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * just throw in some alphabets too
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi for (i = 0; i < guidlen; i++) {
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi guid[i] = r[i];
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Generate branchid for a transaction
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi if ((branchid = (char *)malloc(SIP_BRANCHID_LEN + 1)) == NULL)
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi (void) snprintf(branchid, SIP_BRANCHID_LEN + 1, "z9hG4bK%s",
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi callid = sip_search_for_header(_sip_msg, SIP_CALL_ID, NULL);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi if (to == NULL || from == NULL || callid == NULL || cseq == -1)
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sip_msg->sip_msg_req_res->U.sip_request.sip_request_uri.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sasl_MD5Update(&ctx, (uchar_t *)via->sip_hdr_start, hdrlen);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sasl_MD5Update(&ctx, (uchar_t *)to->sip_hdr_start, hdrlen);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sasl_MD5Update(&ctx, (uchar_t *)from->sip_hdr_start, hdrlen);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sasl_MD5Update(&ctx, (uchar_t *)callid->sip_hdr_start, hdrlen);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi _sasl_MD5Update(&ctx, (uchar_t *)_sip_msg->sip_msg_req_res->
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#else /* solaris */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi MD5Update(&ctx, (uchar_t *)callid->sip_hdr_start, hdrlen);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi for (i = 0; i < sizeof (md5_hash); i++) {