da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
3db3f65c6274eb042354801a308c8e9bc4994553amw * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void smb_initlmkey(unsigned char *keyin, unsigned char *keyout);
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * Randomize the contents of the specified buffer.
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * Implement a "fall back", because current callers
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * don't expect an error from this. In practice,
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * we never use this fall back.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_auth_md4
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Compute an MD4 digest.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_auth_md4(unsigned char *result, unsigned char *input, int length)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *key,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *digest)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rv = SUNW_C_GetMechSession(mechanism.mechanism, &hSession);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Initialize the digest operation in the session */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rv = C_SignUpdate(hSession, (CK_BYTE_PTR)data, data_len);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rv = C_SignFinal(hSession, (CK_BYTE_PTR)digest, &diglen);
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * Calculate proper number of iterations.
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * Known call cases include:
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * ResultLen=16, KeyLen=14, DataLen=8
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * ResultLen=24, KeyLen=21, DataLen=8
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * ResultLen=16, KeyLen=14, DataLen=16
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross if (K == 0 || D == 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use SUNW convenience function to initialize the cryptoki
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * library, and open a session with a slot that supports
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the mechanism we plan on using.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rv = SUNW_C_GetMechSession(mechanism.mechanism, &hSession);
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross for (d = k = 0; k < K; k++, d++) {
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross /* Cycle the input again, as necessary. */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Initialize the encryption operation in the session */
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross /* Read in the data and encrypt this portion */
3db3f65c6274eb042354801a308c8e9bc4994553amw * See "Netlogon Credential Computation" section of MS-NRPC document.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amwsmb_initlmkey(unsigned char *keyin, unsigned char *keyout)
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i = 0; i < 8; i++)
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * Use SUNW convenience function to initialize the cryptoki
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * library, and open a session with a slot that supports
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross * the mechanism we plan on using.
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross rv = SUNW_C_GetMechSession(mechanism.mechanism, &hSession);
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross rv = SUNW_C_KeyToObject(hSession, mechanism.mechanism,
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross /* Initialize the encryption operation in the session */