2362N/A * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. 0N/A/* Copyright (c) 2002 Graz University of Technology. All rights reserved. 0N/A * Redistribution and use in source and binary forms, with or without 0N/A * modification, are permitted provided that the following conditions are met: 0N/A * 1. Redistributions of source code must retain the above copyright notice, 0N/A * this list of conditions and the following disclaimer. 0N/A * 2. Redistributions in binary form must reproduce the above copyright notice, 0N/A * this list of conditions and the following disclaimer in the documentation 0N/A * and/or other materials provided with the distribution. 0N/A * 3. The end-user documentation included with the redistribution, if any, must 0N/A * include the following acknowledgment: 0N/A * "This product includes software developed by IAIK of Graz University of 0N/A * Alternately, this acknowledgment may appear in the software itself, if 0N/A * and wherever such third-party acknowledgments normally appear. 0N/A * 4. The names "Graz University of Technology" and "IAIK of Graz University of 0N/A * Technology" must not be used to endorse or promote products derived from 0N/A * this software without prior written permission. 0N/A * 5. Products derived from this software may not be called 0N/A * "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior 0N/A * written permission of Graz University of Technology. 0N/A * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 0N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0N/A * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE 0N/A * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 0N/A * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 0N/A * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 0N/A * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 0N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 0N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0N/A * POSSIBILITY OF SUCH DAMAGE. 0N/A * Class: sun_security_pkcs11_wrapper_PKCS11 0N/A * Method: C_GenerateKey 0N/A * Parametermapping: *PKCS11* 0N/A * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 0N/A * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 0N/A * @param jobjectArray jTemplate CK_ATTRIBUTE_PTR pTemplate 0N/A * @return jlong jKeyHandle CK_OBJECT_HANDLE_PTR phKey 936N/A /* cheack, if we must give a initialization vector back to Java */ 0N/A /* case CKM_PBE_MD5_CAST5_CBC: the same as CKM_PBE_MD5_CAST128_CBC */ 0N/A /* case CKM_PBE_SHA1_CAST5_CBC: the same as CKM_PBE_SHA1_CAST128_CBC */ 0N/A /* we must copy back the initialization vector to the jMechanism object */ 0N/A * Class: sun_security_pkcs11_wrapper_PKCS11 0N/A * Method: C_GenerateKeyPair 0N/A * Parametermapping: *PKCS11* 0N/A * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 0N/A * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 0N/A * @param jobjectArray jPublicKeyTemplate CK_ATTRIBUTE_PTR pPublicKeyTemplate 0N/A * CK_ULONG ulPublicKeyAttributeCount 0N/A * @param jobjectArray jPrivateKeyTemplate CK_ATTRIBUTE_PTR pPrivateKeyTemplate 0N/A * CK_ULONG ulPrivateKeyAttributeCount 0N/A * @return jlongArray jKeyHandles CK_OBJECT_HANDLE_PTR phPublicKey 0N/A * CK_OBJECT_HANDLE_PTR phPublicKey 0N/A * Class: sun_security_pkcs11_wrapper_PKCS11 0N/A * Parametermapping: *PKCS11* 0N/A * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 0N/A * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 0N/A * @param jlong jWrappingKeyHandle CK_OBJECT_HANDLE hWrappingKey 0N/A * @param jlong jKeyHandle CK_OBJECT_HANDLE hKey 0N/A * @return jbyteArray jWrappedKey CK_BYTE_PTR pWrappedKey 0N/A * CK_ULONG_PTR pulWrappedKeyLen 0N/A * Class: sun_security_pkcs11_wrapper_PKCS11 0N/A * Method: C_UnwrapKey 0N/A * Parametermapping: *PKCS11* 0N/A * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 0N/A * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 0N/A * @param jlong jUnwrappingKeyHandle CK_OBJECT_HANDLE hUnwrappingKey 0N/A * @param jbyteArray jWrappedKey CK_BYTE_PTR pWrappedKey 0N/A * CK_ULONG_PTR pulWrappedKeyLen 0N/A * @param jobjectArray jTemplate CK_ATTRIBUTE_PTR pTemplate 0N/A * @return jlong jKeyHandle CK_OBJECT_HANDLE_PTR phKey 936N/A /* cheack, if we must give a initialization vector back to Java */ 936N/A /* we must copy back the unwrapped key info to the jMechanism object */ 0N/A * Copy back the PRF output to Java. 0N/A /* we do not have maching types, this should not occur */ 0N/A /* get the native CK_TLS_PRF_PARAMS */ 0N/A /* get the Java CK_TLS_PRF_PARAMS object (pParameter) */ 0N/A /* copy back the client IV */ 0N/A // Note: we assume that the token returned exactly as many bytes as we 0N/A // requested. Anything else would not make sense. 0N/A /* copy the bytes to the Java buffer */ 0N/A /* copy back the Java buffer to the object */ 0N/A // free malloc'd data 0N/A * Class: sun_security_pkcs11_wrapper_PKCS11 0N/A * Method: C_DeriveKey 0N/A * Parametermapping: *PKCS11* 0N/A * @param jlong jSessionHandle CK_SESSION_HANDLE hSession 0N/A * @param jobject jMechanism CK_MECHANISM_PTR pMechanism 0N/A * @param jlong jBaseKeyHandle CK_OBJECT_HANDLE hBaseKey 0N/A * @param jobjectArray jTemplate CK_ATTRIBUTE_PTR pTemplate 0N/A * @return jlong jKeyHandle CK_OBJECT_HANDLE_PTR phKey 0N/A // these mechanism do not return a key handle via phKey 0N/A // set to NULL in case pedantic implementations check for it 0N/A /* we must copy back the client version */ 0N/A /* we must copy back the unwrapped key info to the jMechanism object */ 0N/A * Copy back the client version information from the native 0N/A * structure to the Java object. This is only used for the 0N/A * CKM_SSL3_MASTER_KEY_DERIVE mechanism when used for deriving a key. 0N/A /* we do not have maching types, this should not occur */ 0N/A /* get the native CK_SSL3_MASTER_KEY_DERIVE_PARAMS */ 0N/A /* get the native CK_VERSION */ 0N/A /* get the Java CK_SSL3_MASTER_KEY_DERIVE_PARAMS (pParameter) */ 0N/A /* get the Java CK_VERSION */ 0N/A /* now copy back the version from the native structure to the Java structure */ 0N/A /* copy back the major version */ 0N/A /* copy back the minor version */ 0N/A * Copy back the derived keys and initialization vectors from the native 0N/A * structure to the Java object. This is only used for the 0N/A * CKM_SSL3_KEY_AND_MAC_DERIVE mechanism when used for deriving a key. 0N/A /* we do not have maching types, this should not occur */ 0N/A /* get the native CK_SSL3_KEY_MAT_PARAMS */ 0N/A // free malloc'd data 0N/A /* get the native CK_SSL3_KEY_MAT_OUT */ 0N/A /* get the Java CK_SSL3_KEY_MAT_PARAMS (pParameter) */ 0N/A /* get the Java CK_SSL3_KEY_MAT_OUT */ 0N/A /* now copy back all the key handles and the initialization vectors */ 0N/A /* copy back client MAC secret handle */ 0N/A /* copy back server MAC secret handle */ 0N/A /* copy back client secret key handle */ 0N/A /* copy back server secret key handle */ 0N/A /* copy back the client IV */ 0N/A /* copy the bytes to the Java buffer */ 0N/A /* copy back the Java buffer to the object */ 0N/A /* copy back the server IV */ 0N/A /* copy the bytes to the Java buffer */ 0N/A /* copy back the Java buffer to the object */ 0N/A // free malloc'd data