jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/wrapper/Functions.java
author mchung
Wed, 14 Dec 2016 10:51:13 -0800
changeset 42693 6645de32a866
parent 31695 jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/Functions.java@4d10942c9a7b
permissions -rw-r--r--
8171201: Drop java.compact$N aggregator modules 8171202: Rename jdk.crypto.pkcs11 and jdk.pack200 to end with Java letters Reviewed-by: alanb, erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
31695
4d10942c9a7b 8074865: General crypto resilience changes
valeriep
parents: 25859
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * Redistribution and use in  source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * modification, are permitted  provided that the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * 1. Redistributions of  source code must retain the above copyright notice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *    this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * 2. Redistributions in  binary form must reproduce the above copyright notice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *    this list of conditions and the following disclaimer in the documentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *    and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 3. The end-user documentation included with the redistribution, if any, must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *    include the following acknowledgment:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *    "This product includes software developed by IAIK of Graz University of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 *     Technology."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *    Alternately, this acknowledgment may appear in the software itself, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 *    and wherever such third-party acknowledgments normally appear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * 4. The names "Graz University of Technology" and "IAIK of Graz University of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *    Technology" must not be used to endorse or promote products derived from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *    this software without prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * 5. Products derived from this software may not be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *    "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *    written permission of Graz University of Technology.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *  POSSIBILITY  OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
package sun.security.pkcs11.wrapper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * This class contains onyl static methods. It is the place for all functions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * that are used by several classes in this package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public class Functions {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // maps between ids and their names, forward and reverse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // ids are stored as Integers to save space
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // since only the lower 32 bits are ever used anyway
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // mechanisms (CKM_*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static final Map<Integer,String> mechNames =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        new HashMap<Integer,String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static final Map<String,Integer> mechIds =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        new HashMap<String,Integer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // key types (CKK_*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static final Map<Integer,String> keyNames =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        new HashMap<Integer,String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static final Map<String,Integer> keyIds =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        new HashMap<String,Integer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    // attributes (CKA_*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private static final Map<Integer,String> attributeNames =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        new HashMap<Integer,String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private static final Map<String,Integer> attributeIds =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        new HashMap<String,Integer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    // object classes (CKO_*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static final Map<Integer,String> objectClassNames =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        new HashMap<Integer,String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static final Map<String,Integer> objectClassIds =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        new HashMap<String,Integer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * For converting numbers to their hex presentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Converts a long value to a hexadecimal String of length 16. Includes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * leading zeros if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @param value The long value to be converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @return The hexadecimal string representation of the long value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static String toFullHexString(long value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        long currentValue = value;
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   112
        StringBuilder sb = new StringBuilder(16);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        for(int j = 0; j < 16; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            int currentDigit = (int) currentValue & 0xf;
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   115
            sb.append(HEX_DIGITS[currentDigit]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            currentValue >>>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   119
        return sb.reverse().toString();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Converts a int value to a hexadecimal String of length 8. Includes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * leading zeros if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param value The int value to be converted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @return The hexadecimal string representation of the int value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public static String toFullHexString(int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        int currentValue = value;
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   131
        StringBuilder sb = new StringBuilder(8);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        for(int i = 0; i < 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            int currentDigit = currentValue & 0xf;
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   134
            sb.append(HEX_DIGITS[currentDigit]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            currentValue >>>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   138
        return sb.reverse().toString();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * converts a long value to a hexadecimal String
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param value the long value to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @return the hexadecimal string representation of the long value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public static String toHexString(long value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return Long.toHexString(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Converts a byte array to a hexadecimal String. Each byte is presented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * its two digit hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * included in the result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param value the byte array to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @return the hexadecimal string representation of the byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public static String toHexString(byte[] value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   164
        StringBuilder sb = new StringBuilder(2 * value.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        int          single;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        for (int i = 0; i < value.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            single = value[i] & 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if (single < 0x10) {
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   171
                sb.append('0');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   174
            sb.append(Integer.toString(single, 16));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 12685
diff changeset
   177
        return sb.toString();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * converts a long value to a binary String
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @param value the long value to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @return the binary string representation of the long value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public static String toBinaryString(long value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return Long.toString(value, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * converts a byte array to a binary String
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @param value the byte array to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @return the binary string representation of the byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public static String toBinaryString(byte[] value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        BigInteger helpBigInteger = new BigInteger(1, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return helpBigInteger.toString(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    private static class Flags {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        private final long[] flagIds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        private final String[] flagNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        Flags(long[] flagIds, String[] flagNames) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            if (flagIds.length != flagNames.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                throw new AssertionError("Array lengths do not match");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            this.flagIds = flagIds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            this.flagNames = flagNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        String toString(long val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            StringBuilder sb = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            boolean first = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            for (int i = 0; i < flagIds.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                if ((val & flagIds[i]) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                    if (first == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                        sb.append(" | ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    sb.append(flagNames[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    first = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    private static final Flags slotInfoFlags = new Flags(new long[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        CKF_TOKEN_PRESENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        CKF_REMOVABLE_DEVICE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        CKF_HW_SLOT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }, new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        "CKF_TOKEN_PRESENT",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        "CKF_REMOVABLE_DEVICE",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        "CKF_HW_SLOT",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * converts the long value flags to a SlotInfoFlag string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @param flags the flags to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @return the SlotInfoFlag string representation of the flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public static String slotInfoFlagsToString(long flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return slotInfoFlags.toString(flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    private static final Flags tokenInfoFlags = new Flags(new long[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        CKF_RNG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        CKF_WRITE_PROTECTED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        CKF_LOGIN_REQUIRED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        CKF_USER_PIN_INITIALIZED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        CKF_RESTORE_KEY_NOT_NEEDED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        CKF_CLOCK_ON_TOKEN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        CKF_PROTECTED_AUTHENTICATION_PATH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        CKF_DUAL_CRYPTO_OPERATIONS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        CKF_TOKEN_INITIALIZED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        CKF_SECONDARY_AUTHENTICATION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        CKF_USER_PIN_COUNT_LOW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        CKF_USER_PIN_FINAL_TRY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        CKF_USER_PIN_LOCKED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        CKF_USER_PIN_TO_BE_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        CKF_SO_PIN_COUNT_LOW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        CKF_SO_PIN_FINAL_TRY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        CKF_SO_PIN_LOCKED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        CKF_SO_PIN_TO_BE_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }, new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        "CKF_RNG",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        "CKF_WRITE_PROTECTED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        "CKF_LOGIN_REQUIRED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        "CKF_USER_PIN_INITIALIZED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        "CKF_RESTORE_KEY_NOT_NEEDED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        "CKF_CLOCK_ON_TOKEN",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        "CKF_PROTECTED_AUTHENTICATION_PATH",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        "CKF_DUAL_CRYPTO_OPERATIONS",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        "CKF_TOKEN_INITIALIZED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        "CKF_SECONDARY_AUTHENTICATION",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        "CKF_USER_PIN_COUNT_LOW",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        "CKF_USER_PIN_FINAL_TRY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        "CKF_USER_PIN_LOCKED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        "CKF_USER_PIN_TO_BE_CHANGED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        "CKF_SO_PIN_COUNT_LOW",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        "CKF_SO_PIN_FINAL_TRY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        "CKF_SO_PIN_LOCKED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        "CKF_SO_PIN_TO_BE_CHANGED",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * converts long value flags to a TokenInfoFlag string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param flags the flags to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @return the TokenInfoFlag string representation of the flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public static String tokenInfoFlagsToString(long flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return tokenInfoFlags.toString(flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    private static final Flags sessionInfoFlags = new Flags(new long[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        CKF_RW_SESSION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        CKF_SERIAL_SESSION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }, new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        "CKF_RW_SESSION",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        "CKF_SERIAL_SESSION",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * converts the long value flags to a SessionInfoFlag string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param flags the flags to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @return the SessionInfoFlag string representation of the flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public static String sessionInfoFlagsToString(long flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return sessionInfoFlags.toString(flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * converts the long value state to a SessionState string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @param state the state to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @return the SessionState string representation of the state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public static String sessionStateToString(long state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        if (state == CKS_RO_PUBLIC_SESSION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            name = "CKS_RO_PUBLIC_SESSION";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        } else if (state == CKS_RO_USER_FUNCTIONS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            name = "CKS_RO_USER_FUNCTIONS";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        } else if (state == CKS_RW_PUBLIC_SESSION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            name = "CKS_RW_PUBLIC_SESSION";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        } else if (state == CKS_RW_USER_FUNCTIONS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            name = "CKS_RW_USER_FUNCTIONS";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        } else if (state == CKS_RW_SO_FUNCTIONS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            name = "CKS_RW_SO_FUNCTIONS";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            name = "ERROR: unknown session state 0x" + toFullHexString(state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    private static final Flags mechanismInfoFlags = new Flags(new long[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        CKF_HW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        CKF_ENCRYPT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        CKF_DECRYPT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        CKF_DIGEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        CKF_SIGN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        CKF_SIGN_RECOVER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        CKF_VERIFY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        CKF_VERIFY_RECOVER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        CKF_GENERATE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        CKF_GENERATE_KEY_PAIR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        CKF_WRAP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        CKF_UNWRAP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        CKF_DERIVE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        CKF_EC_F_P,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        CKF_EC_F_2M,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        CKF_EC_ECPARAMETERS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        CKF_EC_NAMEDCURVE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        CKF_EC_UNCOMPRESS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        CKF_EC_COMPRESS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        CKF_EXTENSION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }, new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        "CKF_HW",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        "CKF_ENCRYPT",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        "CKF_DECRYPT",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        "CKF_DIGEST",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        "CKF_SIGN",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        "CKF_SIGN_RECOVER",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        "CKF_VERIFY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        "CKF_VERIFY_RECOVER",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        "CKF_GENERATE",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        "CKF_GENERATE_KEY_PAIR",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        "CKF_WRAP",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        "CKF_UNWRAP",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        "CKF_DERIVE",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        "CKF_EC_F_P",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        "CKF_EC_F_2M",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        "CKF_EC_ECPARAMETERS",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        "CKF_EC_NAMEDCURVE",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        "CKF_EC_UNCOMPRESS",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        "CKF_EC_COMPRESS",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        "CKF_EXTENSION",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * converts the long value flags to a MechanismInfoFlag string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @param flags the flags to be converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @return the MechanismInfoFlag string representation of the flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public static String mechanismInfoFlagsToString(long flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return mechanismInfoFlags.toString(flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    private static String getName(Map<Integer,String> nameMap, long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        String name = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        if ((id >>> 32) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            name = nameMap.get(Integer.valueOf((int)id));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            name = "Unknown 0x" + toFullHexString(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public static long getId(Map<String,Integer> idMap, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        Integer mech = idMap.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        if (mech == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            throw new IllegalArgumentException("Unknown name " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        return mech.intValue() & 0xffffffffL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public static String getMechanismName(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        return getName(mechNames, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    public static long getMechanismId(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return getId(mechIds, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    public static String getKeyName(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        return getName(keyNames, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    public static long getKeyId(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        return getId(keyIds, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    public static String getAttributeName(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        return getName(attributeNames, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    public static long getAttributeId(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return getId(attributeIds, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    public static String getObjectClassName(long id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        return getName(objectClassNames, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    public static long getObjectClassId(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        return getId(objectClassIds, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * Check the given arrays for equalitiy. This method considers both arrays as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * equal, if both are <code>null</code> or both have the same length and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * contain exactly the same char values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @param array1 The first array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @param array2 The second array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * @return True, if both arrays are <code>null</code> or both have the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *         length and contain exactly the same char values. False, otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @preconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @postconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
31695
4d10942c9a7b 8074865: General crypto resilience changes
valeriep
parents: 25859
diff changeset
   459
    private static boolean equals(char[] array1, char[] array2) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        return Arrays.equals(array1, array2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * Check the given dates for equalitiy. This method considers both dates as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * equal, if both are <code>null</code> or both contain exactly the same char
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @param date1 The first date.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @param date2 The second date.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @return True, if both dates are <code>null</code> or both contain the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *         char values. False, otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @preconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * @postconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public static boolean equals(CK_DATE date1, CK_DATE date2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        boolean equal = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        if (date1 == date2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            equal = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        } else if ((date1 != null) && (date2 != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            equal = equals(date1.year, date2.year)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
              && equals(date1.month, date2.month)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
              && equals(date1.day, date2.day);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            equal = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        return equal ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * Calculate a hash code for the given byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @param array The byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @return A hash code for the given array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @preconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @postconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    public static int hashCode(byte[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        int hash = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        if (array != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            for (int i = 0; (i < 4) && (i < array.length); i++) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   504
                hash ^= (0xFF & array[i]) << ((i%4) << 3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return hash ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Calculate a hash code for the given char array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @param array The char array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @return A hash code for the given array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @preconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @postconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    public static int hashCode(char[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        int hash = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (array != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            for (int i = 0; (i < 4) && (i < array.length); i++) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   524
                hash ^= (0xFFFF & array[i]) << ((i%2) << 4);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        return hash ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * Calculate a hash code for the given date object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @param date The date object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @return A hash code for the given date.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @preconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * @postconditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    public static int hashCode(CK_DATE date) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        int hash = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        if (date != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            if (date.year.length == 4) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   544
                hash ^= (0xFFFF & date.year[0]) << 16;
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   545
                hash ^= 0xFFFF & date.year[1];
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   546
                hash ^= (0xFFFF & date.year[2]) << 16;
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   547
                hash ^= 0xFFFF & date.year[3];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            if (date.month.length == 2) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   550
                hash ^= (0xFFFF & date.month[0]) << 16;
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   551
                hash ^= 0xFFFF & date.month[1];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            if (date.day.length == 2) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   554
                hash ^= (0xFFFF & date.day[0]) << 16;
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   555
                hash ^= 0xFFFF & date.day[1];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        return hash ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    private static void addMapping(Map<Integer,String> nameMap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            Map<String,Integer> idMap, long id, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        if ((id >>> 32) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            throw new AssertionError("Id has high bits set: " + id + ", " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        Integer intId = Integer.valueOf((int)id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        if (nameMap.put(intId, name) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            throw new AssertionError("Duplicate id: " + id + ", " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        if (idMap.put(name, intId) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            throw new AssertionError("Duplicate name: " + id + ", " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    private static void addMech(long id, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        addMapping(mechNames, mechIds, id, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    private static void addKeyType(long id, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        addMapping(keyNames, keyIds, id, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    private static void addAttribute(long id, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        addMapping(attributeNames, attributeIds, id, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    private static void addObjectClass(long id, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        addMapping(objectClassNames, objectClassIds, id, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        addMech(CKM_RSA_PKCS_KEY_PAIR_GEN,      "CKM_RSA_PKCS_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        addMech(CKM_RSA_PKCS,                   "CKM_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        addMech(CKM_RSA_9796,                   "CKM_RSA_9796");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        addMech(CKM_RSA_X_509,                  "CKM_RSA_X_509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        addMech(CKM_MD2_RSA_PKCS,               "CKM_MD2_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        addMech(CKM_MD5_RSA_PKCS,               "CKM_MD5_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        addMech(CKM_SHA1_RSA_PKCS,              "CKM_SHA1_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        addMech(CKM_RIPEMD128_RSA_PKCS,         "CKM_RIPEMD128_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        addMech(CKM_RIPEMD160_RSA_PKCS,         "CKM_RIPEMD160_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        addMech(CKM_RSA_PKCS_OAEP,              "CKM_RSA_PKCS_OAEP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        addMech(CKM_RSA_X9_31_KEY_PAIR_GEN,     "CKM_RSA_X9_31_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        addMech(CKM_RSA_X9_31,                  "CKM_RSA_X9_31");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        addMech(CKM_SHA1_RSA_X9_31,             "CKM_SHA1_RSA_X9_31");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        addMech(CKM_RSA_PKCS_PSS,               "CKM_RSA_PKCS_PSS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        addMech(CKM_SHA1_RSA_PKCS_PSS,          "CKM_SHA1_RSA_PKCS_PSS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        addMech(CKM_DSA_KEY_PAIR_GEN,           "CKM_DSA_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        addMech(CKM_DSA,                        "CKM_DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        addMech(CKM_DSA_SHA1,                   "CKM_DSA_SHA1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        addMech(CKM_DH_PKCS_KEY_PAIR_GEN,       "CKM_DH_PKCS_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        addMech(CKM_DH_PKCS_DERIVE,             "CKM_DH_PKCS_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        addMech(CKM_X9_42_DH_KEY_PAIR_GEN,      "CKM_X9_42_DH_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        addMech(CKM_X9_42_DH_DERIVE,            "CKM_X9_42_DH_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        addMech(CKM_X9_42_DH_HYBRID_DERIVE,     "CKM_X9_42_DH_HYBRID_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        addMech(CKM_X9_42_MQV_DERIVE,           "CKM_X9_42_MQV_DERIVE");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   617
        addMech(CKM_SHA224_RSA_PKCS,            "CKM_SHA224_RSA_PKCS");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        addMech(CKM_SHA256_RSA_PKCS,            "CKM_SHA256_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        addMech(CKM_SHA384_RSA_PKCS,            "CKM_SHA384_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        addMech(CKM_SHA512_RSA_PKCS,            "CKM_SHA512_RSA_PKCS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        addMech(CKM_RC2_KEY_GEN,                "CKM_RC2_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        addMech(CKM_RC2_ECB,                    "CKM_RC2_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        addMech(CKM_RC2_CBC,                    "CKM_RC2_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        addMech(CKM_RC2_MAC,                    "CKM_RC2_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        addMech(CKM_RC2_MAC_GENERAL,            "CKM_RC2_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        addMech(CKM_RC2_CBC_PAD,                "CKM_RC2_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        addMech(CKM_RC4_KEY_GEN,                "CKM_RC4_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        addMech(CKM_RC4,                        "CKM_RC4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        addMech(CKM_DES_KEY_GEN,                "CKM_DES_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        addMech(CKM_DES_ECB,                    "CKM_DES_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        addMech(CKM_DES_CBC,                    "CKM_DES_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        addMech(CKM_DES_MAC,                    "CKM_DES_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        addMech(CKM_DES_MAC_GENERAL,            "CKM_DES_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        addMech(CKM_DES_CBC_PAD,                "CKM_DES_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        addMech(CKM_DES2_KEY_GEN,               "CKM_DES2_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        addMech(CKM_DES3_KEY_GEN,               "CKM_DES3_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        addMech(CKM_DES3_ECB,                   "CKM_DES3_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        addMech(CKM_DES3_CBC,                   "CKM_DES3_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        addMech(CKM_DES3_MAC,                   "CKM_DES3_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        addMech(CKM_DES3_MAC_GENERAL,           "CKM_DES3_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        addMech(CKM_DES3_CBC_PAD,               "CKM_DES3_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        addMech(CKM_CDMF_KEY_GEN,               "CKM_CDMF_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        addMech(CKM_CDMF_ECB,                   "CKM_CDMF_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        addMech(CKM_CDMF_CBC,                   "CKM_CDMF_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        addMech(CKM_CDMF_MAC,                   "CKM_CDMF_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        addMech(CKM_CDMF_MAC_GENERAL,           "CKM_CDMF_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        addMech(CKM_CDMF_CBC_PAD,               "CKM_CDMF_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        addMech(CKM_MD2,                        "CKM_MD2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        addMech(CKM_MD2_HMAC,                   "CKM_MD2_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        addMech(CKM_MD2_HMAC_GENERAL,           "CKM_MD2_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        addMech(CKM_MD5,                        "CKM_MD5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        addMech(CKM_MD5_HMAC,                   "CKM_MD5_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        addMech(CKM_MD5_HMAC_GENERAL,           "CKM_MD5_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        addMech(CKM_SHA_1,                      "CKM_SHA_1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        addMech(CKM_SHA_1_HMAC,                 "CKM_SHA_1_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        addMech(CKM_SHA_1_HMAC_GENERAL,         "CKM_SHA_1_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        addMech(CKM_RIPEMD128,                  "CKM_RIPEMD128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        addMech(CKM_RIPEMD128_HMAC,             "CKM_RIPEMD128_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        addMech(CKM_RIPEMD128_HMAC_GENERAL,     "CKM_RIPEMD128_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        addMech(CKM_RIPEMD160,                  "CKM_RIPEMD160");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        addMech(CKM_RIPEMD160_HMAC,             "CKM_RIPEMD160_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        addMech(CKM_RIPEMD160_HMAC_GENERAL,     "CKM_RIPEMD160_HMAC_GENERAL");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   663
        addMech(CKM_SHA224,                     "CKM_SHA224");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   664
        addMech(CKM_SHA224_HMAC,                "CKM_SHA224_HMAC");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   665
        addMech(CKM_SHA224_HMAC_GENERAL,        "CKM_SHA224_HMAC_GENERAL");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        addMech(CKM_SHA256,                     "CKM_SHA256");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        addMech(CKM_SHA256_HMAC,                "CKM_SHA256_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        addMech(CKM_SHA256_HMAC_GENERAL,        "CKM_SHA256_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        addMech(CKM_SHA384,                     "CKM_SHA384");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        addMech(CKM_SHA384_HMAC,                "CKM_SHA384_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        addMech(CKM_SHA384_HMAC_GENERAL,        "CKM_SHA384_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        addMech(CKM_SHA512,                     "CKM_SHA512");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        addMech(CKM_SHA512_HMAC,                "CKM_SHA512_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        addMech(CKM_SHA512_HMAC_GENERAL,        "CKM_SHA512_HMAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        addMech(CKM_CAST_KEY_GEN,               "CKM_CAST_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        addMech(CKM_CAST_ECB,                   "CKM_CAST_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        addMech(CKM_CAST_CBC,                   "CKM_CAST_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        addMech(CKM_CAST_MAC,                   "CKM_CAST_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        addMech(CKM_CAST_MAC_GENERAL,           "CKM_CAST_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        addMech(CKM_CAST_CBC_PAD,               "CKM_CAST_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        addMech(CKM_CAST3_KEY_GEN,              "CKM_CAST3_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        addMech(CKM_CAST3_ECB,                  "CKM_CAST3_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        addMech(CKM_CAST3_CBC,                  "CKM_CAST3_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        addMech(CKM_CAST3_MAC,                  "CKM_CAST3_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        addMech(CKM_CAST3_MAC_GENERAL,          "CKM_CAST3_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        addMech(CKM_CAST3_CBC_PAD,              "CKM_CAST3_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        addMech(CKM_CAST128_KEY_GEN,            "CKM_CAST128_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        addMech(CKM_CAST128_ECB,                "CKM_CAST128_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        addMech(CKM_CAST128_CBC,                "CKM_CAST128_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        addMech(CKM_CAST128_MAC,                "CKM_CAST128_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        addMech(CKM_CAST128_MAC_GENERAL,        "CKM_CAST128_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        addMech(CKM_CAST128_CBC_PAD,            "CKM_CAST128_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        addMech(CKM_RC5_KEY_GEN,                "CKM_RC5_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        addMech(CKM_RC5_ECB,                    "CKM_RC5_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        addMech(CKM_RC5_CBC,                    "CKM_RC5_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        addMech(CKM_RC5_MAC,                    "CKM_RC5_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        addMech(CKM_RC5_MAC_GENERAL,            "CKM_RC5_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        addMech(CKM_RC5_CBC_PAD,                "CKM_RC5_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        addMech(CKM_IDEA_KEY_GEN,               "CKM_IDEA_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        addMech(CKM_IDEA_ECB,                   "CKM_IDEA_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        addMech(CKM_IDEA_CBC,                   "CKM_IDEA_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        addMech(CKM_IDEA_MAC,                   "CKM_IDEA_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        addMech(CKM_IDEA_MAC_GENERAL,           "CKM_IDEA_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        addMech(CKM_IDEA_CBC_PAD,               "CKM_IDEA_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        addMech(CKM_GENERIC_SECRET_KEY_GEN,     "CKM_GENERIC_SECRET_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        addMech(CKM_CONCATENATE_BASE_AND_KEY,   "CKM_CONCATENATE_BASE_AND_KEY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        addMech(CKM_CONCATENATE_BASE_AND_DATA,  "CKM_CONCATENATE_BASE_AND_DATA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        addMech(CKM_CONCATENATE_DATA_AND_BASE,  "CKM_CONCATENATE_DATA_AND_BASE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        addMech(CKM_XOR_BASE_AND_DATA,          "CKM_XOR_BASE_AND_DATA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        addMech(CKM_EXTRACT_KEY_FROM_KEY,       "CKM_EXTRACT_KEY_FROM_KEY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        addMech(CKM_SSL3_PRE_MASTER_KEY_GEN,    "CKM_SSL3_PRE_MASTER_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        addMech(CKM_SSL3_MASTER_KEY_DERIVE,     "CKM_SSL3_MASTER_KEY_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        addMech(CKM_SSL3_KEY_AND_MAC_DERIVE,    "CKM_SSL3_KEY_AND_MAC_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        addMech(CKM_SSL3_MASTER_KEY_DERIVE_DH,  "CKM_SSL3_MASTER_KEY_DERIVE_DH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        addMech(CKM_TLS_PRE_MASTER_KEY_GEN,     "CKM_TLS_PRE_MASTER_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        addMech(CKM_TLS_MASTER_KEY_DERIVE,      "CKM_TLS_MASTER_KEY_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        addMech(CKM_TLS_KEY_AND_MAC_DERIVE,     "CKM_TLS_KEY_AND_MAC_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        addMech(CKM_TLS_MASTER_KEY_DERIVE_DH,   "CKM_TLS_MASTER_KEY_DERIVE_DH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        addMech(CKM_TLS_PRF,                    "CKM_TLS_PRF");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        addMech(CKM_SSL3_MD5_MAC,               "CKM_SSL3_MD5_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        addMech(CKM_SSL3_SHA1_MAC,              "CKM_SSL3_SHA1_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        addMech(CKM_MD5_KEY_DERIVATION,         "CKM_MD5_KEY_DERIVATION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        addMech(CKM_MD2_KEY_DERIVATION,         "CKM_MD2_KEY_DERIVATION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        addMech(CKM_SHA1_KEY_DERIVATION,        "CKM_SHA1_KEY_DERIVATION");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   725
        addMech(CKM_SHA224_KEY_DERIVATION,      "CKM_SHA224_KEY_DERIVATION");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        addMech(CKM_SHA256_KEY_DERIVATION,      "CKM_SHA256_KEY_DERIVATION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        addMech(CKM_SHA384_KEY_DERIVATION,      "CKM_SHA384_KEY_DERIVATION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        addMech(CKM_SHA512_KEY_DERIVATION,      "CKM_SHA512_KEY_DERIVATION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        addMech(CKM_PBE_MD2_DES_CBC,            "CKM_PBE_MD2_DES_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        addMech(CKM_PBE_MD5_DES_CBC,            "CKM_PBE_MD5_DES_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        addMech(CKM_PBE_MD5_CAST_CBC,           "CKM_PBE_MD5_CAST_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        addMech(CKM_PBE_MD5_CAST3_CBC,          "CKM_PBE_MD5_CAST3_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        addMech(CKM_PBE_MD5_CAST128_CBC,        "CKM_PBE_MD5_CAST128_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        addMech(CKM_PBE_SHA1_CAST128_CBC,       "CKM_PBE_SHA1_CAST128_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        addMech(CKM_PBE_SHA1_RC4_128,           "CKM_PBE_SHA1_RC4_128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        addMech(CKM_PBE_SHA1_RC4_40,            "CKM_PBE_SHA1_RC4_40");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        addMech(CKM_PBE_SHA1_DES3_EDE_CBC,      "CKM_PBE_SHA1_DES3_EDE_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        addMech(CKM_PBE_SHA1_DES2_EDE_CBC,      "CKM_PBE_SHA1_DES2_EDE_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        addMech(CKM_PBE_SHA1_RC2_128_CBC,       "CKM_PBE_SHA1_RC2_128_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        addMech(CKM_PBE_SHA1_RC2_40_CBC,        "CKM_PBE_SHA1_RC2_40_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        addMech(CKM_PKCS5_PBKD2,                "CKM_PKCS5_PBKD2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        addMech(CKM_PBA_SHA1_WITH_SHA1_HMAC,    "CKM_PBA_SHA1_WITH_SHA1_HMAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        addMech(CKM_KEY_WRAP_LYNKS,             "CKM_KEY_WRAP_LYNKS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        addMech(CKM_KEY_WRAP_SET_OAEP,          "CKM_KEY_WRAP_SET_OAEP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        addMech(CKM_SKIPJACK_KEY_GEN,           "CKM_SKIPJACK_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        addMech(CKM_SKIPJACK_ECB64,             "CKM_SKIPJACK_ECB64");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        addMech(CKM_SKIPJACK_CBC64,             "CKM_SKIPJACK_CBC64");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        addMech(CKM_SKIPJACK_OFB64,             "CKM_SKIPJACK_OFB64");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        addMech(CKM_SKIPJACK_CFB64,             "CKM_SKIPJACK_CFB64");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        addMech(CKM_SKIPJACK_CFB32,             "CKM_SKIPJACK_CFB32");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        addMech(CKM_SKIPJACK_CFB16,             "CKM_SKIPJACK_CFB16");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        addMech(CKM_SKIPJACK_CFB8,              "CKM_SKIPJACK_CFB8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        addMech(CKM_SKIPJACK_WRAP,              "CKM_SKIPJACK_WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        addMech(CKM_SKIPJACK_PRIVATE_WRAP,      "CKM_SKIPJACK_PRIVATE_WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        addMech(CKM_SKIPJACK_RELAYX,            "CKM_SKIPJACK_RELAYX");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        addMech(CKM_KEA_KEY_PAIR_GEN,           "CKM_KEA_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        addMech(CKM_KEA_KEY_DERIVE,             "CKM_KEA_KEY_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        addMech(CKM_FORTEZZA_TIMESTAMP,         "CKM_FORTEZZA_TIMESTAMP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        addMech(CKM_BATON_KEY_GEN,              "CKM_BATON_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        addMech(CKM_BATON_ECB128,               "CKM_BATON_ECB128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        addMech(CKM_BATON_ECB96,                "CKM_BATON_ECB96");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        addMech(CKM_BATON_CBC128,               "CKM_BATON_CBC128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        addMech(CKM_BATON_COUNTER,              "CKM_BATON_COUNTER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        addMech(CKM_BATON_SHUFFLE,              "CKM_BATON_SHUFFLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        addMech(CKM_BATON_WRAP,                 "CKM_BATON_WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        addMech(CKM_EC_KEY_PAIR_GEN,            "CKM_EC_KEY_PAIR_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        addMech(CKM_ECDSA,                      "CKM_ECDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        addMech(CKM_ECDSA_SHA1,                 "CKM_ECDSA_SHA1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        addMech(CKM_ECDH1_DERIVE,               "CKM_ECDH1_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        addMech(CKM_ECDH1_COFACTOR_DERIVE,      "CKM_ECDH1_COFACTOR_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        addMech(CKM_ECMQV_DERIVE,               "CKM_ECMQV_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        addMech(CKM_JUNIPER_KEY_GEN,            "CKM_JUNIPER_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        addMech(CKM_JUNIPER_ECB128,             "CKM_JUNIPER_ECB128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        addMech(CKM_JUNIPER_CBC128,             "CKM_JUNIPER_CBC128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        addMech(CKM_JUNIPER_COUNTER,            "CKM_JUNIPER_COUNTER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        addMech(CKM_JUNIPER_SHUFFLE,            "CKM_JUNIPER_SHUFFLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        addMech(CKM_JUNIPER_WRAP,               "CKM_JUNIPER_WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        addMech(CKM_FASTHASH,                   "CKM_FASTHASH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        addMech(CKM_AES_KEY_GEN,                "CKM_AES_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        addMech(CKM_AES_ECB,                    "CKM_AES_ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        addMech(CKM_AES_CBC,                    "CKM_AES_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        addMech(CKM_AES_MAC,                    "CKM_AES_MAC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        addMech(CKM_AES_MAC_GENERAL,            "CKM_AES_MAC_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        addMech(CKM_AES_CBC_PAD,                "CKM_AES_CBC_PAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        addMech(CKM_BLOWFISH_KEY_GEN,           "CKM_BLOWFISH_KEY_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        addMech(CKM_BLOWFISH_CBC,               "CKM_BLOWFISH_CBC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        addMech(CKM_DSA_PARAMETER_GEN,          "CKM_DSA_PARAMETER_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        addMech(CKM_DH_PKCS_PARAMETER_GEN,      "CKM_DH_PKCS_PARAMETER_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        addMech(CKM_X9_42_DH_PARAMETER_GEN,     "CKM_X9_42_DH_PARAMETER_GEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        addMech(CKM_VENDOR_DEFINED,             "CKM_VENDOR_DEFINED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        addMech(CKM_NSS_TLS_PRF_GENERAL,        "CKM_NSS_TLS_PRF_GENERAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        addMech(PCKM_SECURERANDOM,              "SecureRandom");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        addMech(PCKM_KEYSTORE,                  "KeyStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        addKeyType(CKK_RSA,                     "CKK_RSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        addKeyType(CKK_DSA,                     "CKK_DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        addKeyType(CKK_DH,                      "CKK_DH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        addKeyType(CKK_EC,                      "CKK_EC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        addKeyType(CKK_X9_42_DH,                "CKK_X9_42_DH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        addKeyType(CKK_KEA,                     "CKK_KEA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        addKeyType(CKK_GENERIC_SECRET,          "CKK_GENERIC_SECRET");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        addKeyType(CKK_RC2,                     "CKK_RC2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        addKeyType(CKK_RC4,                     "CKK_RC4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        addKeyType(CKK_DES,                     "CKK_DES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        addKeyType(CKK_DES2,                    "CKK_DES2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        addKeyType(CKK_DES3,                    "CKK_DES3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        addKeyType(CKK_CAST,                    "CKK_CAST");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        addKeyType(CKK_CAST3,                   "CKK_CAST3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        addKeyType(CKK_CAST128,                 "CKK_CAST128");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        addKeyType(CKK_RC5,                     "CKK_RC5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        addKeyType(CKK_IDEA,                    "CKK_IDEA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        addKeyType(CKK_SKIPJACK,                "CKK_SKIPJACK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        addKeyType(CKK_BATON,                   "CKK_BATON");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        addKeyType(CKK_JUNIPER,                 "CKK_JUNIPER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        addKeyType(CKK_CDMF,                    "CKK_CDMF");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        addKeyType(CKK_AES,                     "CKK_AES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        addKeyType(CKK_BLOWFISH,                "CKK_BLOWFISH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        addKeyType(CKK_VENDOR_DEFINED,          "CKK_VENDOR_DEFINED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        addKeyType(PCKK_ANY,                    "*");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        addAttribute(CKA_CLASS,                 "CKA_CLASS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        addAttribute(CKA_TOKEN,                 "CKA_TOKEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        addAttribute(CKA_PRIVATE,               "CKA_PRIVATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        addAttribute(CKA_LABEL,                 "CKA_LABEL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        addAttribute(CKA_APPLICATION,           "CKA_APPLICATION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        addAttribute(CKA_VALUE,                 "CKA_VALUE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        addAttribute(CKA_OBJECT_ID,             "CKA_OBJECT_ID");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        addAttribute(CKA_CERTIFICATE_TYPE,      "CKA_CERTIFICATE_TYPE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        addAttribute(CKA_ISSUER,                "CKA_ISSUER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        addAttribute(CKA_SERIAL_NUMBER,         "CKA_SERIAL_NUMBER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        addAttribute(CKA_AC_ISSUER,             "CKA_AC_ISSUER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        addAttribute(CKA_OWNER,                 "CKA_OWNER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        addAttribute(CKA_ATTR_TYPES,            "CKA_ATTR_TYPES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        addAttribute(CKA_TRUSTED,               "CKA_TRUSTED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        addAttribute(CKA_KEY_TYPE,              "CKA_KEY_TYPE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        addAttribute(CKA_SUBJECT,               "CKA_SUBJECT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        addAttribute(CKA_ID,                    "CKA_ID");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        addAttribute(CKA_SENSITIVE,             "CKA_SENSITIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        addAttribute(CKA_ENCRYPT,               "CKA_ENCRYPT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        addAttribute(CKA_DECRYPT,               "CKA_DECRYPT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        addAttribute(CKA_WRAP,                  "CKA_WRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        addAttribute(CKA_UNWRAP,                "CKA_UNWRAP");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        addAttribute(CKA_SIGN,                  "CKA_SIGN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        addAttribute(CKA_SIGN_RECOVER,          "CKA_SIGN_RECOVER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        addAttribute(CKA_VERIFY,                "CKA_VERIFY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        addAttribute(CKA_VERIFY_RECOVER,        "CKA_VERIFY_RECOVER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        addAttribute(CKA_DERIVE,                "CKA_DERIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        addAttribute(CKA_START_DATE,            "CKA_START_DATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        addAttribute(CKA_END_DATE,              "CKA_END_DATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        addAttribute(CKA_MODULUS,               "CKA_MODULUS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        addAttribute(CKA_MODULUS_BITS,          "CKA_MODULUS_BITS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        addAttribute(CKA_PUBLIC_EXPONENT,       "CKA_PUBLIC_EXPONENT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        addAttribute(CKA_PRIVATE_EXPONENT,      "CKA_PRIVATE_EXPONENT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        addAttribute(CKA_PRIME_1,               "CKA_PRIME_1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        addAttribute(CKA_PRIME_2,               "CKA_PRIME_2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        addAttribute(CKA_EXPONENT_1,            "CKA_EXPONENT_1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        addAttribute(CKA_EXPONENT_2,            "CKA_EXPONENT_2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        addAttribute(CKA_COEFFICIENT,           "CKA_COEFFICIENT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        addAttribute(CKA_PRIME,                 "CKA_PRIME");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        addAttribute(CKA_SUBPRIME,              "CKA_SUBPRIME");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        addAttribute(CKA_BASE,                  "CKA_BASE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        addAttribute(CKA_PRIME_BITS,            "CKA_PRIME_BITS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        addAttribute(CKA_SUB_PRIME_BITS,        "CKA_SUB_PRIME_BITS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        addAttribute(CKA_VALUE_BITS,            "CKA_VALUE_BITS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        addAttribute(CKA_VALUE_LEN,             "CKA_VALUE_LEN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        addAttribute(CKA_EXTRACTABLE,           "CKA_EXTRACTABLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        addAttribute(CKA_LOCAL,                 "CKA_LOCAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        addAttribute(CKA_NEVER_EXTRACTABLE,     "CKA_NEVER_EXTRACTABLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        addAttribute(CKA_ALWAYS_SENSITIVE,      "CKA_ALWAYS_SENSITIVE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        addAttribute(CKA_KEY_GEN_MECHANISM,     "CKA_KEY_GEN_MECHANISM");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        addAttribute(CKA_MODIFIABLE,            "CKA_MODIFIABLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        addAttribute(CKA_EC_PARAMS,             "CKA_EC_PARAMS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        addAttribute(CKA_EC_POINT,              "CKA_EC_POINT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        addAttribute(CKA_SECONDARY_AUTH,        "CKA_SECONDARY_AUTH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        addAttribute(CKA_AUTH_PIN_FLAGS,        "CKA_AUTH_PIN_FLAGS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        addAttribute(CKA_HW_FEATURE_TYPE,       "CKA_HW_FEATURE_TYPE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        addAttribute(CKA_RESET_ON_INIT,         "CKA_RESET_ON_INIT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        addAttribute(CKA_HAS_RESET,             "CKA_HAS_RESET");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        addAttribute(CKA_VENDOR_DEFINED,        "CKA_VENDOR_DEFINED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        addAttribute(CKA_NETSCAPE_DB,           "CKA_NETSCAPE_DB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        addAttribute(CKA_NETSCAPE_TRUST_SERVER_AUTH,      "CKA_NETSCAPE_TRUST_SERVER_AUTH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        addAttribute(CKA_NETSCAPE_TRUST_CLIENT_AUTH,      "CKA_NETSCAPE_TRUST_CLIENT_AUTH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        addAttribute(CKA_NETSCAPE_TRUST_CODE_SIGNING,     "CKA_NETSCAPE_TRUST_CODE_SIGNING");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        addAttribute(CKA_NETSCAPE_TRUST_EMAIL_PROTECTION, "CKA_NETSCAPE_TRUST_EMAIL_PROTECTION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        addAttribute(CKA_NETSCAPE_CERT_SHA1_HASH,         "CKA_NETSCAPE_CERT_SHA1_HASH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        addAttribute(CKA_NETSCAPE_CERT_MD5_HASH,          "CKA_NETSCAPE_CERT_MD5_HASH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        addObjectClass(CKO_DATA,                "CKO_DATA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        addObjectClass(CKO_CERTIFICATE,         "CKO_CERTIFICATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        addObjectClass(CKO_PUBLIC_KEY,          "CKO_PUBLIC_KEY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        addObjectClass(CKO_PRIVATE_KEY,         "CKO_PRIVATE_KEY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        addObjectClass(CKO_SECRET_KEY,          "CKO_SECRET_KEY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        addObjectClass(CKO_HW_FEATURE,          "CKO_HW_FEATURE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        addObjectClass(CKO_DOMAIN_PARAMETERS,   "CKO_DOMAIN_PARAMETERS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        addObjectClass(CKO_VENDOR_DEFINED,      "CKO_VENDOR_DEFINED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        addObjectClass(PCKO_ANY,                "*");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
}