1 /* 2 * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. 3 * 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 package sun.security.pkcs11.wrapper; 26 27 /** 28 * CK_TLS12_KEY_MAT_PARAMS from PKCS#11 v2.40. 29 * 30 * @author Martin Balao (mbalao@redhat.com) 31 * @since 10 32 */ 33 public class CK_TLS12_KEY_MAT_PARAMS { 34 35 /** 36 * <B>PKCS#11:</B> 37 * <PRE> 38 * CK_ULONG ulMacSizeInBits; 39 * </PRE> 40 */ 41 public long ulMacSizeInBits; 42 43 /** 44 * <B>PKCS#11:</B> 45 * <PRE> 46 * CK_ULONG ulKeySizeInBits; 47 * </PRE> 48 */ 49 public long ulKeySizeInBits; 50 51 /** 52 * <B>PKCS#11:</B> 53 * <PRE> 54 * CK_ULONG ulIVSizeInBits; 55 * </PRE> 56 */ 57 public long ulIVSizeInBits; 58 59 /** 60 * <B>PKCS#11:</B> 61 * <PRE> 62 * CK_BBOOL bIsExport; 63 * </PRE> 64 */ 65 public boolean bIsExport; 66 67 /** 68 * <B>PKCS#11:</B> 69 * <PRE> 70 * CK_SSL3_RANDOM_DATA RandomInfo; 71 * </PRE> 72 */ 73 public CK_SSL3_RANDOM_DATA RandomInfo; 74 75 /** 76 * <B>PKCS#11:</B> 77 * <PRE> 78 * CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; 79 * </PRE> 80 */ 81 public CK_SSL3_KEY_MAT_OUT pReturnedKeyMaterial; 82 83 /** 84 * <B>PKCS#11:</B> 85 * <PRE> 86 * CK_MECHANISM_TYPE prfHashMechanism; 87 * </PRE> 88 */ 89 public long prfHashMechanism; 90 91 public CK_TLS12_KEY_MAT_PARAMS( 92 int macSize, int keySize, int ivSize, boolean export, 93 CK_SSL3_RANDOM_DATA random, long prfHashMechanism) { 94 ulMacSizeInBits = macSize; 95 ulKeySizeInBits = keySize; 96 ulIVSizeInBits = ivSize; 97 bIsExport = export; 98 RandomInfo = random; 99 pReturnedKeyMaterial = new CK_SSL3_KEY_MAT_OUT(); 100 if (ivSize != 0) { 101 int n = ivSize >> 3; 102 pReturnedKeyMaterial.pIVClient = new byte[n]; 103 pReturnedKeyMaterial.pIVServer = new byte[n]; 104 } 105 this.prfHashMechanism = prfHashMechanism; 106 } 107 108 /** 109 * Returns the string representation of CK_TLS12_KEY_MAT_PARAMS. 110 * 111 * @return the string representation of CK_TLS12_KEY_MAT_PARAMS 112 */ 113 public String toString() { 114 StringBuilder buffer = new StringBuilder(); 115 116 buffer.append(Constants.INDENT); 117 buffer.append("ulMacSizeInBits: "); 118 buffer.append(ulMacSizeInBits); 119 buffer.append(Constants.NEWLINE); 120 121 buffer.append(Constants.INDENT); 122 buffer.append("ulKeySizeInBits: "); 123 buffer.append(ulKeySizeInBits); 124 buffer.append(Constants.NEWLINE); 125 126 buffer.append(Constants.INDENT); 127 buffer.append("ulIVSizeInBits: "); 128 buffer.append(ulIVSizeInBits); 129 buffer.append(Constants.NEWLINE); 130 131 buffer.append(Constants.INDENT); 132 buffer.append("bIsExport: "); 133 buffer.append(bIsExport); 134 buffer.append(Constants.NEWLINE); 135 136 buffer.append(Constants.INDENT); 137 buffer.append("RandomInfo: "); 138 buffer.append(RandomInfo); 139 buffer.append(Constants.NEWLINE); 140 141 buffer.append(Constants.INDENT); 142 buffer.append("pReturnedKeyMaterial: "); 143 buffer.append(pReturnedKeyMaterial); 144 buffer.append(Constants.NEWLINE); 145 146 buffer.append(Constants.INDENT); 147 buffer.append("prfHashMechanism: "); 148 buffer.append(prfHashMechanism); 149 150 return buffer.toString(); 151 } 152 153 }