1 /* 2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 3 */ 4 5 /* Copyright (c) 2002 Graz University of Technology. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * 3. The end-user documentation included with the redistribution, if any, must 18 * include the following acknowledgment: 19 * 20 * "This product includes software developed by IAIK of Graz University of 21 * Technology." 22 * 23 * Alternately, this acknowledgment may appear in the software itself, if 24 * and wherever such third-party acknowledgments normally appear. 25 * 26 * 4. The names "Graz University of Technology" and "IAIK of Graz University of 27 * Technology" must not be used to endorse or promote products derived from 28 * this software without prior written permission. 29 * 30 * 5. Products derived from this software may not be called 31 * "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior 32 * written permission of Graz University of Technology. 33 * 34 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 35 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 36 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 37 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE 38 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 40 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 41 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 42 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 45 * POSSIBILITY OF SUCH DAMAGE. 46 */ 47 48 package sun.security.pkcs11.wrapper; 49 50 51 52 /** 53 * class CK_SSL3_KEY_MAT_PARAMS provides the parameters to the 54 * CKM_SSL3_KEY_AND_MAC_DERIVE mechanism.<p> 55 * <B>PKCS#11 structure:</B> 56 * <PRE> 57 * typedef struct CK_SSL3_KEY_MAT_PARAMS { 58 * CK_ULONG ulMacSizeInBits; 59 * CK_ULONG ulKeySizeInBits; 60 * CK_ULONG ulIVSizeInBits; 61 * CK_BBOOL bIsExport; 62 * CK_SSL3_RANDOM_DATA RandomInfo; 63 * CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; 64 * } CK_SSL3_KEY_MAT_PARAMS; 65 * </PRE> 66 * 67 * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> 68 * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> 69 */ 70 public class CK_SSL3_KEY_MAT_PARAMS{ 71 72 /** 73 * <B>PKCS#11:</B> 74 * <PRE> 75 * CK_ULONG ulMacSizeInBits; 76 * </PRE> 77 */ 78 public long ulMacSizeInBits; 79 80 /** 81 * <B>PKCS#11:</B> 82 * <PRE> 83 * CK_ULONG ulKeySizeInBits; 84 * </PRE> 85 */ 86 public long ulKeySizeInBits; 87 88 /** 89 * <B>PKCS#11:</B> 90 * <PRE> 91 * CK_ULONG ulIVSizeInBits; 92 * </PRE> 93 */ 94 public long ulIVSizeInBits; 95 96 /** 97 * <B>PKCS#11:</B> 98 * <PRE> 99 * CK_BBOOL bIsExport; 100 * </PRE> 101 */ 102 public boolean bIsExport; 103 104 /** 105 * <B>PKCS#11:</B> 106 * <PRE> 107 * CK_SSL3_RANDOM_DATA RandomInfo; 108 * </PRE> 109 */ 110 public CK_SSL3_RANDOM_DATA RandomInfo; 111 112 /** 113 * <B>PKCS#11:</B> 114 * <PRE> 115 * CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; 116 * </PRE> 117 */ 118 public CK_SSL3_KEY_MAT_OUT pReturnedKeyMaterial; 119 120 public CK_SSL3_KEY_MAT_PARAMS(int macSize, int keySize, int ivSize, boolean export, CK_SSL3_RANDOM_DATA random) { 121 ulMacSizeInBits = macSize; 122 ulKeySizeInBits = keySize; 123 ulIVSizeInBits = ivSize; 124 bIsExport = export; 125 RandomInfo = random; 126 pReturnedKeyMaterial = new CK_SSL3_KEY_MAT_OUT(); 127 if (ivSize != 0) { 128 int n = ivSize >> 3; 129 pReturnedKeyMaterial.pIVClient = new byte[n]; 130 pReturnedKeyMaterial.pIVServer = new byte[n]; 131 } 132 } 133 134 /** 135 * Returns the string representation of CK_SSL3_KEY_MAT_PARAMS. 136 * 137 * @return the string representation of CK_SSL3_KEY_MAT_PARAMS 138 */ 139 public String toString() { 140 StringBuilder buffer = new StringBuilder(); 141 142 buffer.append(Constants.INDENT); 143 buffer.append("ulMacSizeInBits: "); 144 buffer.append(ulMacSizeInBits); 145 buffer.append(Constants.NEWLINE); 146 147 buffer.append(Constants.INDENT); 148 buffer.append("ulKeySizeInBits: "); 149 buffer.append(ulKeySizeInBits); 150 buffer.append(Constants.NEWLINE); 151 152 buffer.append(Constants.INDENT); 153 buffer.append("ulIVSizeInBits: "); 154 buffer.append(ulIVSizeInBits); 155 buffer.append(Constants.NEWLINE); 156 157 buffer.append(Constants.INDENT); 158 buffer.append("bIsExport: "); 159 buffer.append(bIsExport); 160 buffer.append(Constants.NEWLINE); 161 162 buffer.append(Constants.INDENT); 163 buffer.append("RandomInfo: "); 164 buffer.append(RandomInfo); 165 buffer.append(Constants.NEWLINE); 166 167 buffer.append(Constants.INDENT); 168 buffer.append("pReturnedKeyMaterial: "); 169 buffer.append(pReturnedKeyMaterial); 170 //buffer.append(Constants.NEWLINE); 171 172 return buffer.toString(); 173 } 174 175 }