2362N/A * Copyright (c) 2003, 2011, 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: 2362N/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 * This class contains onyl static methods. It is the place for all functions 0N/A * that are used by several classes in this package. 0N/A * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> 0N/A * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> 0N/A // maps between ids and their names, forward and reverse 0N/A // ids are stored as Integers to save space 0N/A // since only the lower 32 bits are ever used anyway // object classes (CKO_*) * For converting numbers to their hex presentation. * Converts a long value to a hexadecimal String of length 16. Includes * leading zeros if necessary. * @param value The long value to be converted. * @return The hexadecimal string representation of the long value. for(
int j =
0; j <
16; j++) {
* Converts a int value to a hexadecimal String of length 8. Includes * leading zeros if necessary. * @param value The int value to be converted. * @return The hexadecimal string representation of the int value. for(
int i =
0; i <
8; i++) {
* converts a long value to a hexadecimal String * @param value the long value to be converted * @return the hexadecimal string representation of the long value * Converts a byte array to a hexadecimal String. Each byte is presented by * its two digit hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is * included in the result. * @param value the byte array to be converted * @return the hexadecimal string representation of the byte array * converts a long value to a binary String * @param value the long value to be converted * @return the binary string representation of the long value * converts a byte array to a binary String * @param value the byte array to be converted * @return the binary string representation of the byte array private static class Flags {
* converts the long value flags to a SlotInfoFlag string * @param flags the flags to be converted * @return the SlotInfoFlag string representation of the flags "CKF_USER_PIN_INITIALIZED",
"CKF_RESTORE_KEY_NOT_NEEDED",
"CKF_PROTECTED_AUTHENTICATION_PATH",
"CKF_DUAL_CRYPTO_OPERATIONS",
"CKF_SECONDARY_AUTHENTICATION",
"CKF_USER_PIN_COUNT_LOW",
"CKF_USER_PIN_FINAL_TRY",
"CKF_USER_PIN_TO_BE_CHANGED",
"CKF_SO_PIN_TO_BE_CHANGED",
* converts long value flags to a TokenInfoFlag string * @param flags the flags to be converted * @return the TokenInfoFlag string representation of the flags * converts the long value flags to a SessionInfoFlag string * @param flags the flags to be converted * @return the SessionInfoFlag string representation of the flags * converts the long value state to a SessionState string * @param state the state to be converted * @return the SessionState string representation of the state name =
"CKS_RO_PUBLIC_SESSION";
name =
"CKS_RO_USER_FUNCTIONS";
name =
"CKS_RW_PUBLIC_SESSION";
name =
"CKS_RW_USER_FUNCTIONS";
name =
"CKS_RW_SO_FUNCTIONS";
* converts the long value flags to a MechanismInfoFlag string * @param flags the flags to be converted * @return the MechanismInfoFlag string representation of the flags * Check the given arrays for equalitiy. This method considers both arrays as * equal, if both are <code>null</code> or both have the same length and * contain exactly the same byte values. * @param array1 The first array. * @param array2 The second array. * @return True, if both arrays are <code>null</code> or both have the same * length and contain exactly the same byte values. False, otherwise. * Check the given arrays for equalitiy. This method considers both arrays as * equal, if both are <code>null</code> or both have the same length and * contain exactly the same char values. * @param array1 The first array. * @param array2 The second array. * @return True, if both arrays are <code>null</code> or both have the same * length and contain exactly the same char values. False, otherwise. * Check the given dates for equalitiy. This method considers both dates as * equal, if both are <code>null</code> or both contain exactly the same char * @param date1 The first date. * @param date2 The second date. * @return True, if both dates are <code>null</code> or both contain the same * char values. False, otherwise. * Calculate a hash code for the given byte array. * @param array The byte array. * @return A hash code for the given array. hash ^= ((
int) (
0xFF &
array[i])) << ((i%
4) <<
3);
* Calculate a hash code for the given char array. * @param array The char array. * @return A hash code for the given array. hash ^= ((
int) (
0xFFFF &
array[i])) << ((i%
2) <<
4);
* Calculate a hash code for the given date object. * @param date The date object. * @return A hash code for the given date.