2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * SMB MAC Signing support. 2N/A * Calculates the MAC key using the specified user session 2N/A * key (NTLM or NTLMv2). 2N/A * Returns SMBAUTH_SUCCESS if key generation was successful, 2N/A * SMBAUTH_FAILURE if not. 2N/A * Calculates MAC signature for the given buffer and returns 2N/A * it in the mac_sign parameter. 2N/A * The MAC signature is calculated as follows: 2N/A * data = concat(MAC_Key, MAC_Key_Len, SMB_Msg, SMB_Msg_Len); 2N/A * MAC = head(hash, 8); 2N/A * The tricky part is that a sequence number should be used 2N/A * in calculation instead of the signature field in the 2N/A * Returns SMBAUTH_SUCCESS if cryptology framework use was successful, 2N/A * SMBAUTH_FAILURE if not. 2N/A * put seq_num into the first 4 bytes and 2N/A * zero out the next 4 bytes 2N/A /* Initialize the digest operation in the session */ 2N/A /* init with the MAC key */ 2N/A /* copy in SMB packet info till signature field */ 2N/A /* copy in the seq_buf instead of the signature */ 2N/A /* copy in the rest of the packet, skipping the signature */ 2N/A * Calculates MAC signature for the given buffer 2N/A * and compares it to the signature in the given context. 2N/A * Return 1 if the signature are match, otherwise, return (0); 2N/A /* calculate mac signature */ 2N/A /* compare the signatures */ 2N/A * Calculates MAC signature for the given buffer, 2N/A * and write it to the buffer's signature field. 2N/A * Returns SMBAUTH_SUCCESS if cryptology framework use was successful, 2N/A * SMBAUTH_FAILURE if not. 2N/A /* calculate mac signature */ 2N/A /* put mac signature in the header's signature field */