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