View Javadoc
1   /*
2    * Copyright (c) 2003, 2012, 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         StringBuffer stringBuffer = new StringBuffer(16);
113         for(int j = 0; j < 16; j++) {
114             int currentDigit = (int) currentValue & 0xf;
115             stringBuffer.append(HEX_DIGITS[currentDigit]);
116             currentValue >>>= 4;
117         }
118 
119         return stringBuffer.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         StringBuffer stringBuffer = new StringBuffer(8);
132         for(int i = 0; i < 8; i++) {
133             int currentDigit = currentValue & 0xf;
134             stringBuffer.append(HEX_DIGITS[currentDigit]);
135             currentValue >>>= 4;
136         }
137 
138         return stringBuffer.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         StringBuffer buffer = new StringBuffer(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                 buffer.append('0');
172             }
173 
174             buffer.append(Integer.toString(single, 16));
175         }
176 
177         return buffer.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 byte 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 byte values. False, otherwise.
456      * @preconditions
457      * @postconditions
458      */
459     public static boolean equals(byte[] array1, byte[] array2) {
460         return Arrays.equals(array1, array2);
461     }
462 
463     /**
464      * Check the given arrays for equalitiy. This method considers both arrays as
465      * equal, if both are <code>null</code> or both have the same length and
466      * contain exactly the same char values.
467      *
468      * @param array1 The first array.
469      * @param array2 The second array.
470      * @return True, if both arrays are <code>null</code> or both have the same
471      *         length and contain exactly the same char values. False, otherwise.
472      * @preconditions
473      * @postconditions
474      */
475     public static boolean equals(char[] array1, char[] array2) {
476         return Arrays.equals(array1, array2);
477     }
478 
479     /**
480      * Check the given dates for equalitiy. This method considers both dates as
481      * equal, if both are <code>null</code> or both contain exactly the same char
482      * values.
483      *
484      * @param date1 The first date.
485      * @param date2 The second date.
486      * @return True, if both dates are <code>null</code> or both contain the same
487      *         char values. False, otherwise.
488      * @preconditions
489      * @postconditions
490      */
491     public static boolean equals(CK_DATE date1, CK_DATE date2) {
492         boolean equal = false;
493 
494         if (date1 == date2) {
495             equal = true;
496         } else if ((date1 != null) && (date2 != null)) {
497             equal = equals(date1.year, date2.year)
498               && equals(date1.month, date2.month)
499               && equals(date1.day, date2.day);
500         } else {
501             equal = false;
502         }
503 
504         return equal ;
505     }
506 
507     /**
508      * Calculate a hash code for the given byte array.
509      *
510      * @param array The byte array.
511      * @return A hash code for the given array.
512      * @preconditions
513      * @postconditions
514      */
515     public static int hashCode(byte[] array) {
516         int hash = 0;
517 
518         if (array != null) {
519             for (int i = 0; (i < 4) && (i < array.length); i++) {
520                 hash ^= (0xFF & array[i]) << ((i%4) << 3);
521             }
522         }
523 
524         return hash ;
525     }
526 
527     /**
528      * Calculate a hash code for the given char array.
529      *
530      * @param array The char array.
531      * @return A hash code for the given array.
532      * @preconditions
533      * @postconditions
534      */
535     public static int hashCode(char[] array) {
536         int hash = 0;
537 
538         if (array != null) {
539             for (int i = 0; (i < 4) && (i < array.length); i++) {
540                 hash ^= (0xFFFF & array[i]) << ((i%2) << 4);
541             }
542         }
543 
544         return hash ;
545     }
546 
547     /**
548      * Calculate a hash code for the given date object.
549      *
550      * @param date The date object.
551      * @return A hash code for the given date.
552      * @preconditions
553      * @postconditions
554      */
555     public static int hashCode(CK_DATE date) {
556         int hash = 0;
557 
558         if (date != null) {
559             if (date.year.length == 4) {
560                 hash ^= (0xFFFF & date.year[0]) << 16;
561                 hash ^= 0xFFFF & date.year[1];
562                 hash ^= (0xFFFF & date.year[2]) << 16;
563                 hash ^= 0xFFFF & date.year[3];
564             }
565             if (date.month.length == 2) {
566                 hash ^= (0xFFFF & date.month[0]) << 16;
567                 hash ^= 0xFFFF & date.month[1];
568             }
569             if (date.day.length == 2) {
570                 hash ^= (0xFFFF & date.day[0]) << 16;
571                 hash ^= 0xFFFF & date.day[1];
572             }
573         }
574 
575         return hash ;
576     }
577 
578     private static void addMapping(Map<Integer,String> nameMap,
579             Map<String,Integer> idMap, long id, String name) {
580         if ((id >>> 32) != 0) {
581             throw new AssertionError("Id has high bits set: " + id + ", " + name);
582         }
583         Integer intId = Integer.valueOf((int)id);
584         if (nameMap.put(intId, name) != null) {
585             throw new AssertionError("Duplicate id: " + id + ", " + name);
586         }
587         if (idMap.put(name, intId) != null) {
588             throw new AssertionError("Duplicate name: " + id + ", " + name);
589         }
590     }
591 
592     private static void addMech(long id, String name) {
593         addMapping(mechNames, mechIds, id, name);
594     }
595 
596     private static void addKeyType(long id, String name) {
597         addMapping(keyNames, keyIds, id, name);
598     }
599 
600     private static void addAttribute(long id, String name) {
601         addMapping(attributeNames, attributeIds, id, name);
602     }
603 
604     private static void addObjectClass(long id, String name) {
605         addMapping(objectClassNames, objectClassIds, id, name);
606     }
607 
608     static {
609         addMech(CKM_RSA_PKCS_KEY_PAIR_GEN,      "CKM_RSA_PKCS_KEY_PAIR_GEN");
610         addMech(CKM_RSA_PKCS,                   "CKM_RSA_PKCS");
611         addMech(CKM_RSA_9796,                   "CKM_RSA_9796");
612         addMech(CKM_RSA_X_509,                  "CKM_RSA_X_509");
613         addMech(CKM_MD2_RSA_PKCS,               "CKM_MD2_RSA_PKCS");
614         addMech(CKM_MD5_RSA_PKCS,               "CKM_MD5_RSA_PKCS");
615         addMech(CKM_SHA1_RSA_PKCS,              "CKM_SHA1_RSA_PKCS");
616         addMech(CKM_RIPEMD128_RSA_PKCS,         "CKM_RIPEMD128_RSA_PKCS");
617         addMech(CKM_RIPEMD160_RSA_PKCS,         "CKM_RIPEMD160_RSA_PKCS");
618         addMech(CKM_RSA_PKCS_OAEP,              "CKM_RSA_PKCS_OAEP");
619         addMech(CKM_RSA_X9_31_KEY_PAIR_GEN,     "CKM_RSA_X9_31_KEY_PAIR_GEN");
620         addMech(CKM_RSA_X9_31,                  "CKM_RSA_X9_31");
621         addMech(CKM_SHA1_RSA_X9_31,             "CKM_SHA1_RSA_X9_31");
622         addMech(CKM_RSA_PKCS_PSS,               "CKM_RSA_PKCS_PSS");
623         addMech(CKM_SHA1_RSA_PKCS_PSS,          "CKM_SHA1_RSA_PKCS_PSS");
624         addMech(CKM_DSA_KEY_PAIR_GEN,           "CKM_DSA_KEY_PAIR_GEN");
625         addMech(CKM_DSA,                        "CKM_DSA");
626         addMech(CKM_DSA_SHA1,                   "CKM_DSA_SHA1");
627         addMech(CKM_DH_PKCS_KEY_PAIR_GEN,       "CKM_DH_PKCS_KEY_PAIR_GEN");
628         addMech(CKM_DH_PKCS_DERIVE,             "CKM_DH_PKCS_DERIVE");
629         addMech(CKM_X9_42_DH_KEY_PAIR_GEN,      "CKM_X9_42_DH_KEY_PAIR_GEN");
630         addMech(CKM_X9_42_DH_DERIVE,            "CKM_X9_42_DH_DERIVE");
631         addMech(CKM_X9_42_DH_HYBRID_DERIVE,     "CKM_X9_42_DH_HYBRID_DERIVE");
632         addMech(CKM_X9_42_MQV_DERIVE,           "CKM_X9_42_MQV_DERIVE");
633         addMech(CKM_SHA224_RSA_PKCS,            "CKM_SHA224_RSA_PKCS");
634         addMech(CKM_SHA256_RSA_PKCS,            "CKM_SHA256_RSA_PKCS");
635         addMech(CKM_SHA384_RSA_PKCS,            "CKM_SHA384_RSA_PKCS");
636         addMech(CKM_SHA512_RSA_PKCS,            "CKM_SHA512_RSA_PKCS");
637         addMech(CKM_RC2_KEY_GEN,                "CKM_RC2_KEY_GEN");
638         addMech(CKM_RC2_ECB,                    "CKM_RC2_ECB");
639         addMech(CKM_RC2_CBC,                    "CKM_RC2_CBC");
640         addMech(CKM_RC2_MAC,                    "CKM_RC2_MAC");
641         addMech(CKM_RC2_MAC_GENERAL,            "CKM_RC2_MAC_GENERAL");
642         addMech(CKM_RC2_CBC_PAD,                "CKM_RC2_CBC_PAD");
643         addMech(CKM_RC4_KEY_GEN,                "CKM_RC4_KEY_GEN");
644         addMech(CKM_RC4,                        "CKM_RC4");
645         addMech(CKM_DES_KEY_GEN,                "CKM_DES_KEY_GEN");
646         addMech(CKM_DES_ECB,                    "CKM_DES_ECB");
647         addMech(CKM_DES_CBC,                    "CKM_DES_CBC");
648         addMech(CKM_DES_MAC,                    "CKM_DES_MAC");
649         addMech(CKM_DES_MAC_GENERAL,            "CKM_DES_MAC_GENERAL");
650         addMech(CKM_DES_CBC_PAD,                "CKM_DES_CBC_PAD");
651         addMech(CKM_DES2_KEY_GEN,               "CKM_DES2_KEY_GEN");
652         addMech(CKM_DES3_KEY_GEN,               "CKM_DES3_KEY_GEN");
653         addMech(CKM_DES3_ECB,                   "CKM_DES3_ECB");
654         addMech(CKM_DES3_CBC,                   "CKM_DES3_CBC");
655         addMech(CKM_DES3_MAC,                   "CKM_DES3_MAC");
656         addMech(CKM_DES3_MAC_GENERAL,           "CKM_DES3_MAC_GENERAL");
657         addMech(CKM_DES3_CBC_PAD,               "CKM_DES3_CBC_PAD");
658         addMech(CKM_CDMF_KEY_GEN,               "CKM_CDMF_KEY_GEN");
659         addMech(CKM_CDMF_ECB,                   "CKM_CDMF_ECB");
660         addMech(CKM_CDMF_CBC,                   "CKM_CDMF_CBC");
661         addMech(CKM_CDMF_MAC,                   "CKM_CDMF_MAC");
662         addMech(CKM_CDMF_MAC_GENERAL,           "CKM_CDMF_MAC_GENERAL");
663         addMech(CKM_CDMF_CBC_PAD,               "CKM_CDMF_CBC_PAD");
664         addMech(CKM_MD2,                        "CKM_MD2");
665         addMech(CKM_MD2_HMAC,                   "CKM_MD2_HMAC");
666         addMech(CKM_MD2_HMAC_GENERAL,           "CKM_MD2_HMAC_GENERAL");
667         addMech(CKM_MD5,                        "CKM_MD5");
668         addMech(CKM_MD5_HMAC,                   "CKM_MD5_HMAC");
669         addMech(CKM_MD5_HMAC_GENERAL,           "CKM_MD5_HMAC_GENERAL");
670         addMech(CKM_SHA_1,                      "CKM_SHA_1");
671         addMech(CKM_SHA_1_HMAC,                 "CKM_SHA_1_HMAC");
672         addMech(CKM_SHA_1_HMAC_GENERAL,         "CKM_SHA_1_HMAC_GENERAL");
673         addMech(CKM_RIPEMD128,                  "CKM_RIPEMD128");
674         addMech(CKM_RIPEMD128_HMAC,             "CKM_RIPEMD128_HMAC");
675         addMech(CKM_RIPEMD128_HMAC_GENERAL,     "CKM_RIPEMD128_HMAC_GENERAL");
676         addMech(CKM_RIPEMD160,                  "CKM_RIPEMD160");
677         addMech(CKM_RIPEMD160_HMAC,             "CKM_RIPEMD160_HMAC");
678         addMech(CKM_RIPEMD160_HMAC_GENERAL,     "CKM_RIPEMD160_HMAC_GENERAL");
679         addMech(CKM_SHA224,                     "CKM_SHA224");
680         addMech(CKM_SHA224_HMAC,                "CKM_SHA224_HMAC");
681         addMech(CKM_SHA224_HMAC_GENERAL,        "CKM_SHA224_HMAC_GENERAL");
682         addMech(CKM_SHA256,                     "CKM_SHA256");
683         addMech(CKM_SHA256_HMAC,                "CKM_SHA256_HMAC");
684         addMech(CKM_SHA256_HMAC_GENERAL,        "CKM_SHA256_HMAC_GENERAL");
685         addMech(CKM_SHA384,                     "CKM_SHA384");
686         addMech(CKM_SHA384_HMAC,                "CKM_SHA384_HMAC");
687         addMech(CKM_SHA384_HMAC_GENERAL,        "CKM_SHA384_HMAC_GENERAL");
688         addMech(CKM_SHA512,                     "CKM_SHA512");
689         addMech(CKM_SHA512_HMAC,                "CKM_SHA512_HMAC");
690         addMech(CKM_SHA512_HMAC_GENERAL,        "CKM_SHA512_HMAC_GENERAL");
691         addMech(CKM_CAST_KEY_GEN,               "CKM_CAST_KEY_GEN");
692         addMech(CKM_CAST_ECB,                   "CKM_CAST_ECB");
693         addMech(CKM_CAST_CBC,                   "CKM_CAST_CBC");
694         addMech(CKM_CAST_MAC,                   "CKM_CAST_MAC");
695         addMech(CKM_CAST_MAC_GENERAL,           "CKM_CAST_MAC_GENERAL");
696         addMech(CKM_CAST_CBC_PAD,               "CKM_CAST_CBC_PAD");
697         addMech(CKM_CAST3_KEY_GEN,              "CKM_CAST3_KEY_GEN");
698         addMech(CKM_CAST3_ECB,                  "CKM_CAST3_ECB");
699         addMech(CKM_CAST3_CBC,                  "CKM_CAST3_CBC");
700         addMech(CKM_CAST3_MAC,                  "CKM_CAST3_MAC");
701         addMech(CKM_CAST3_MAC_GENERAL,          "CKM_CAST3_MAC_GENERAL");
702         addMech(CKM_CAST3_CBC_PAD,              "CKM_CAST3_CBC_PAD");
703         addMech(CKM_CAST128_KEY_GEN,            "CKM_CAST128_KEY_GEN");
704         addMech(CKM_CAST128_ECB,                "CKM_CAST128_ECB");
705         addMech(CKM_CAST128_CBC,                "CKM_CAST128_CBC");
706         addMech(CKM_CAST128_MAC,                "CKM_CAST128_MAC");
707         addMech(CKM_CAST128_MAC_GENERAL,        "CKM_CAST128_MAC_GENERAL");
708         addMech(CKM_CAST128_CBC_PAD,            "CKM_CAST128_CBC_PAD");
709         addMech(CKM_RC5_KEY_GEN,                "CKM_RC5_KEY_GEN");
710         addMech(CKM_RC5_ECB,                    "CKM_RC5_ECB");
711         addMech(CKM_RC5_CBC,                    "CKM_RC5_CBC");
712         addMech(CKM_RC5_MAC,                    "CKM_RC5_MAC");
713         addMech(CKM_RC5_MAC_GENERAL,            "CKM_RC5_MAC_GENERAL");
714         addMech(CKM_RC5_CBC_PAD,                "CKM_RC5_CBC_PAD");
715         addMech(CKM_IDEA_KEY_GEN,               "CKM_IDEA_KEY_GEN");
716         addMech(CKM_IDEA_ECB,                   "CKM_IDEA_ECB");
717         addMech(CKM_IDEA_CBC,                   "CKM_IDEA_CBC");
718         addMech(CKM_IDEA_MAC,                   "CKM_IDEA_MAC");
719         addMech(CKM_IDEA_MAC_GENERAL,           "CKM_IDEA_MAC_GENERAL");
720         addMech(CKM_IDEA_CBC_PAD,               "CKM_IDEA_CBC_PAD");
721         addMech(CKM_GENERIC_SECRET_KEY_GEN,     "CKM_GENERIC_SECRET_KEY_GEN");
722         addMech(CKM_CONCATENATE_BASE_AND_KEY,   "CKM_CONCATENATE_BASE_AND_KEY");
723         addMech(CKM_CONCATENATE_BASE_AND_DATA,  "CKM_CONCATENATE_BASE_AND_DATA");
724         addMech(CKM_CONCATENATE_DATA_AND_BASE,  "CKM_CONCATENATE_DATA_AND_BASE");
725         addMech(CKM_XOR_BASE_AND_DATA,          "CKM_XOR_BASE_AND_DATA");
726         addMech(CKM_EXTRACT_KEY_FROM_KEY,       "CKM_EXTRACT_KEY_FROM_KEY");
727         addMech(CKM_SSL3_PRE_MASTER_KEY_GEN,    "CKM_SSL3_PRE_MASTER_KEY_GEN");
728         addMech(CKM_SSL3_MASTER_KEY_DERIVE,     "CKM_SSL3_MASTER_KEY_DERIVE");
729         addMech(CKM_SSL3_KEY_AND_MAC_DERIVE,    "CKM_SSL3_KEY_AND_MAC_DERIVE");
730         addMech(CKM_SSL3_MASTER_KEY_DERIVE_DH,  "CKM_SSL3_MASTER_KEY_DERIVE_DH");
731         addMech(CKM_TLS_PRE_MASTER_KEY_GEN,     "CKM_TLS_PRE_MASTER_KEY_GEN");
732         addMech(CKM_TLS_MASTER_KEY_DERIVE,      "CKM_TLS_MASTER_KEY_DERIVE");
733         addMech(CKM_TLS_KEY_AND_MAC_DERIVE,     "CKM_TLS_KEY_AND_MAC_DERIVE");
734         addMech(CKM_TLS_MASTER_KEY_DERIVE_DH,   "CKM_TLS_MASTER_KEY_DERIVE_DH");
735         addMech(CKM_TLS_PRF,                    "CKM_TLS_PRF");
736         addMech(CKM_SSL3_MD5_MAC,               "CKM_SSL3_MD5_MAC");
737         addMech(CKM_SSL3_SHA1_MAC,              "CKM_SSL3_SHA1_MAC");
738         addMech(CKM_MD5_KEY_DERIVATION,         "CKM_MD5_KEY_DERIVATION");
739         addMech(CKM_MD2_KEY_DERIVATION,         "CKM_MD2_KEY_DERIVATION");
740         addMech(CKM_SHA1_KEY_DERIVATION,        "CKM_SHA1_KEY_DERIVATION");
741         addMech(CKM_SHA224_KEY_DERIVATION,      "CKM_SHA224_KEY_DERIVATION");
742         addMech(CKM_SHA256_KEY_DERIVATION,      "CKM_SHA256_KEY_DERIVATION");
743         addMech(CKM_SHA384_KEY_DERIVATION,      "CKM_SHA384_KEY_DERIVATION");
744         addMech(CKM_SHA512_KEY_DERIVATION,      "CKM_SHA512_KEY_DERIVATION");
745         addMech(CKM_PBE_MD2_DES_CBC,            "CKM_PBE_MD2_DES_CBC");
746         addMech(CKM_PBE_MD5_DES_CBC,            "CKM_PBE_MD5_DES_CBC");
747         addMech(CKM_PBE_MD5_CAST_CBC,           "CKM_PBE_MD5_CAST_CBC");
748         addMech(CKM_PBE_MD5_CAST3_CBC,          "CKM_PBE_MD5_CAST3_CBC");
749         addMech(CKM_PBE_MD5_CAST128_CBC,        "CKM_PBE_MD5_CAST128_CBC");
750         addMech(CKM_PBE_SHA1_CAST128_CBC,       "CKM_PBE_SHA1_CAST128_CBC");
751         addMech(CKM_PBE_SHA1_RC4_128,           "CKM_PBE_SHA1_RC4_128");
752         addMech(CKM_PBE_SHA1_RC4_40,            "CKM_PBE_SHA1_RC4_40");
753         addMech(CKM_PBE_SHA1_DES3_EDE_CBC,      "CKM_PBE_SHA1_DES3_EDE_CBC");
754         addMech(CKM_PBE_SHA1_DES2_EDE_CBC,      "CKM_PBE_SHA1_DES2_EDE_CBC");
755         addMech(CKM_PBE_SHA1_RC2_128_CBC,       "CKM_PBE_SHA1_RC2_128_CBC");
756         addMech(CKM_PBE_SHA1_RC2_40_CBC,        "CKM_PBE_SHA1_RC2_40_CBC");
757         addMech(CKM_PKCS5_PBKD2,                "CKM_PKCS5_PBKD2");
758         addMech(CKM_PBA_SHA1_WITH_SHA1_HMAC,    "CKM_PBA_SHA1_WITH_SHA1_HMAC");
759         addMech(CKM_KEY_WRAP_LYNKS,             "CKM_KEY_WRAP_LYNKS");
760         addMech(CKM_KEY_WRAP_SET_OAEP,          "CKM_KEY_WRAP_SET_OAEP");
761         addMech(CKM_SKIPJACK_KEY_GEN,           "CKM_SKIPJACK_KEY_GEN");
762         addMech(CKM_SKIPJACK_ECB64,             "CKM_SKIPJACK_ECB64");
763         addMech(CKM_SKIPJACK_CBC64,             "CKM_SKIPJACK_CBC64");
764         addMech(CKM_SKIPJACK_OFB64,             "CKM_SKIPJACK_OFB64");
765         addMech(CKM_SKIPJACK_CFB64,             "CKM_SKIPJACK_CFB64");
766         addMech(CKM_SKIPJACK_CFB32,             "CKM_SKIPJACK_CFB32");
767         addMech(CKM_SKIPJACK_CFB16,             "CKM_SKIPJACK_CFB16");
768         addMech(CKM_SKIPJACK_CFB8,              "CKM_SKIPJACK_CFB8");
769         addMech(CKM_SKIPJACK_WRAP,              "CKM_SKIPJACK_WRAP");
770         addMech(CKM_SKIPJACK_PRIVATE_WRAP,      "CKM_SKIPJACK_PRIVATE_WRAP");
771         addMech(CKM_SKIPJACK_RELAYX,            "CKM_SKIPJACK_RELAYX");
772         addMech(CKM_KEA_KEY_PAIR_GEN,           "CKM_KEA_KEY_PAIR_GEN");
773         addMech(CKM_KEA_KEY_DERIVE,             "CKM_KEA_KEY_DERIVE");
774         addMech(CKM_FORTEZZA_TIMESTAMP,         "CKM_FORTEZZA_TIMESTAMP");
775         addMech(CKM_BATON_KEY_GEN,              "CKM_BATON_KEY_GEN");
776         addMech(CKM_BATON_ECB128,               "CKM_BATON_ECB128");
777         addMech(CKM_BATON_ECB96,                "CKM_BATON_ECB96");
778         addMech(CKM_BATON_CBC128,               "CKM_BATON_CBC128");
779         addMech(CKM_BATON_COUNTER,              "CKM_BATON_COUNTER");
780         addMech(CKM_BATON_SHUFFLE,              "CKM_BATON_SHUFFLE");
781         addMech(CKM_BATON_WRAP,                 "CKM_BATON_WRAP");
782         addMech(CKM_EC_KEY_PAIR_GEN,            "CKM_EC_KEY_PAIR_GEN");
783         addMech(CKM_ECDSA,                      "CKM_ECDSA");
784         addMech(CKM_ECDSA_SHA1,                 "CKM_ECDSA_SHA1");
785         addMech(CKM_ECDH1_DERIVE,               "CKM_ECDH1_DERIVE");
786         addMech(CKM_ECDH1_COFACTOR_DERIVE,      "CKM_ECDH1_COFACTOR_DERIVE");
787         addMech(CKM_ECMQV_DERIVE,               "CKM_ECMQV_DERIVE");
788         addMech(CKM_JUNIPER_KEY_GEN,            "CKM_JUNIPER_KEY_GEN");
789         addMech(CKM_JUNIPER_ECB128,             "CKM_JUNIPER_ECB128");
790         addMech(CKM_JUNIPER_CBC128,             "CKM_JUNIPER_CBC128");
791         addMech(CKM_JUNIPER_COUNTER,            "CKM_JUNIPER_COUNTER");
792         addMech(CKM_JUNIPER_SHUFFLE,            "CKM_JUNIPER_SHUFFLE");
793         addMech(CKM_JUNIPER_WRAP,               "CKM_JUNIPER_WRAP");
794         addMech(CKM_FASTHASH,                   "CKM_FASTHASH");
795         addMech(CKM_AES_KEY_GEN,                "CKM_AES_KEY_GEN");
796         addMech(CKM_AES_ECB,                    "CKM_AES_ECB");
797         addMech(CKM_AES_CBC,                    "CKM_AES_CBC");
798         addMech(CKM_AES_MAC,                    "CKM_AES_MAC");
799         addMech(CKM_AES_MAC_GENERAL,            "CKM_AES_MAC_GENERAL");
800         addMech(CKM_AES_CBC_PAD,                "CKM_AES_CBC_PAD");
801         addMech(CKM_BLOWFISH_KEY_GEN,           "CKM_BLOWFISH_KEY_GEN");
802         addMech(CKM_BLOWFISH_CBC,               "CKM_BLOWFISH_CBC");
803         addMech(CKM_DSA_PARAMETER_GEN,          "CKM_DSA_PARAMETER_GEN");
804         addMech(CKM_DH_PKCS_PARAMETER_GEN,      "CKM_DH_PKCS_PARAMETER_GEN");
805         addMech(CKM_X9_42_DH_PARAMETER_GEN,     "CKM_X9_42_DH_PARAMETER_GEN");
806         addMech(CKM_VENDOR_DEFINED,             "CKM_VENDOR_DEFINED");
807 
808         addMech(CKM_NSS_TLS_PRF_GENERAL,        "CKM_NSS_TLS_PRF_GENERAL");
809 
810         addMech(PCKM_SECURERANDOM,              "SecureRandom");
811         addMech(PCKM_KEYSTORE,                  "KeyStore");
812 
813         addKeyType(CKK_RSA,                     "CKK_RSA");
814         addKeyType(CKK_DSA,                     "CKK_DSA");
815         addKeyType(CKK_DH,                      "CKK_DH");
816         addKeyType(CKK_EC,                      "CKK_EC");
817         addKeyType(CKK_X9_42_DH,                "CKK_X9_42_DH");
818         addKeyType(CKK_KEA,                     "CKK_KEA");
819         addKeyType(CKK_GENERIC_SECRET,          "CKK_GENERIC_SECRET");
820         addKeyType(CKK_RC2,                     "CKK_RC2");
821         addKeyType(CKK_RC4,                     "CKK_RC4");
822         addKeyType(CKK_DES,                     "CKK_DES");
823         addKeyType(CKK_DES2,                    "CKK_DES2");
824         addKeyType(CKK_DES3,                    "CKK_DES3");
825         addKeyType(CKK_CAST,                    "CKK_CAST");
826         addKeyType(CKK_CAST3,                   "CKK_CAST3");
827         addKeyType(CKK_CAST128,                 "CKK_CAST128");
828         addKeyType(CKK_RC5,                     "CKK_RC5");
829         addKeyType(CKK_IDEA,                    "CKK_IDEA");
830         addKeyType(CKK_SKIPJACK,                "CKK_SKIPJACK");
831         addKeyType(CKK_BATON,                   "CKK_BATON");
832         addKeyType(CKK_JUNIPER,                 "CKK_JUNIPER");
833         addKeyType(CKK_CDMF,                    "CKK_CDMF");
834         addKeyType(CKK_AES,                     "CKK_AES");
835         addKeyType(CKK_BLOWFISH,                "CKK_BLOWFISH");
836         addKeyType(CKK_VENDOR_DEFINED,          "CKK_VENDOR_DEFINED");
837 
838         addKeyType(PCKK_ANY,                    "*");
839 
840         addAttribute(CKA_CLASS,                 "CKA_CLASS");
841         addAttribute(CKA_TOKEN,                 "CKA_TOKEN");
842         addAttribute(CKA_PRIVATE,               "CKA_PRIVATE");
843         addAttribute(CKA_LABEL,                 "CKA_LABEL");
844         addAttribute(CKA_APPLICATION,           "CKA_APPLICATION");
845         addAttribute(CKA_VALUE,                 "CKA_VALUE");
846         addAttribute(CKA_OBJECT_ID,             "CKA_OBJECT_ID");
847         addAttribute(CKA_CERTIFICATE_TYPE,      "CKA_CERTIFICATE_TYPE");
848         addAttribute(CKA_ISSUER,                "CKA_ISSUER");
849         addAttribute(CKA_SERIAL_NUMBER,         "CKA_SERIAL_NUMBER");
850         addAttribute(CKA_AC_ISSUER,             "CKA_AC_ISSUER");
851         addAttribute(CKA_OWNER,                 "CKA_OWNER");
852         addAttribute(CKA_ATTR_TYPES,            "CKA_ATTR_TYPES");
853         addAttribute(CKA_TRUSTED,               "CKA_TRUSTED");
854         addAttribute(CKA_KEY_TYPE,              "CKA_KEY_TYPE");
855         addAttribute(CKA_SUBJECT,               "CKA_SUBJECT");
856         addAttribute(CKA_ID,                    "CKA_ID");
857         addAttribute(CKA_SENSITIVE,             "CKA_SENSITIVE");
858         addAttribute(CKA_ENCRYPT,               "CKA_ENCRYPT");
859         addAttribute(CKA_DECRYPT,               "CKA_DECRYPT");
860         addAttribute(CKA_WRAP,                  "CKA_WRAP");
861         addAttribute(CKA_UNWRAP,                "CKA_UNWRAP");
862         addAttribute(CKA_SIGN,                  "CKA_SIGN");
863         addAttribute(CKA_SIGN_RECOVER,          "CKA_SIGN_RECOVER");
864         addAttribute(CKA_VERIFY,                "CKA_VERIFY");
865         addAttribute(CKA_VERIFY_RECOVER,        "CKA_VERIFY_RECOVER");
866         addAttribute(CKA_DERIVE,                "CKA_DERIVE");
867         addAttribute(CKA_START_DATE,            "CKA_START_DATE");
868         addAttribute(CKA_END_DATE,              "CKA_END_DATE");
869         addAttribute(CKA_MODULUS,               "CKA_MODULUS");
870         addAttribute(CKA_MODULUS_BITS,          "CKA_MODULUS_BITS");
871         addAttribute(CKA_PUBLIC_EXPONENT,       "CKA_PUBLIC_EXPONENT");
872         addAttribute(CKA_PRIVATE_EXPONENT,      "CKA_PRIVATE_EXPONENT");
873         addAttribute(CKA_PRIME_1,               "CKA_PRIME_1");
874         addAttribute(CKA_PRIME_2,               "CKA_PRIME_2");
875         addAttribute(CKA_EXPONENT_1,            "CKA_EXPONENT_1");
876         addAttribute(CKA_EXPONENT_2,            "CKA_EXPONENT_2");
877         addAttribute(CKA_COEFFICIENT,           "CKA_COEFFICIENT");
878         addAttribute(CKA_PRIME,                 "CKA_PRIME");
879         addAttribute(CKA_SUBPRIME,              "CKA_SUBPRIME");
880         addAttribute(CKA_BASE,                  "CKA_BASE");
881         addAttribute(CKA_PRIME_BITS,            "CKA_PRIME_BITS");
882         addAttribute(CKA_SUB_PRIME_BITS,        "CKA_SUB_PRIME_BITS");
883         addAttribute(CKA_VALUE_BITS,            "CKA_VALUE_BITS");
884         addAttribute(CKA_VALUE_LEN,             "CKA_VALUE_LEN");
885         addAttribute(CKA_EXTRACTABLE,           "CKA_EXTRACTABLE");
886         addAttribute(CKA_LOCAL,                 "CKA_LOCAL");
887         addAttribute(CKA_NEVER_EXTRACTABLE,     "CKA_NEVER_EXTRACTABLE");
888         addAttribute(CKA_ALWAYS_SENSITIVE,      "CKA_ALWAYS_SENSITIVE");
889         addAttribute(CKA_KEY_GEN_MECHANISM,     "CKA_KEY_GEN_MECHANISM");
890         addAttribute(CKA_MODIFIABLE,            "CKA_MODIFIABLE");
891         addAttribute(CKA_EC_PARAMS,             "CKA_EC_PARAMS");
892         addAttribute(CKA_EC_POINT,              "CKA_EC_POINT");
893         addAttribute(CKA_SECONDARY_AUTH,        "CKA_SECONDARY_AUTH");
894         addAttribute(CKA_AUTH_PIN_FLAGS,        "CKA_AUTH_PIN_FLAGS");
895         addAttribute(CKA_HW_FEATURE_TYPE,       "CKA_HW_FEATURE_TYPE");
896         addAttribute(CKA_RESET_ON_INIT,         "CKA_RESET_ON_INIT");
897         addAttribute(CKA_HAS_RESET,             "CKA_HAS_RESET");
898         addAttribute(CKA_VENDOR_DEFINED,        "CKA_VENDOR_DEFINED");
899         addAttribute(CKA_NETSCAPE_DB,           "CKA_NETSCAPE_DB");
900 
901         addAttribute(CKA_NETSCAPE_TRUST_SERVER_AUTH,      "CKA_NETSCAPE_TRUST_SERVER_AUTH");
902         addAttribute(CKA_NETSCAPE_TRUST_CLIENT_AUTH,      "CKA_NETSCAPE_TRUST_CLIENT_AUTH");
903         addAttribute(CKA_NETSCAPE_TRUST_CODE_SIGNING,     "CKA_NETSCAPE_TRUST_CODE_SIGNING");
904         addAttribute(CKA_NETSCAPE_TRUST_EMAIL_PROTECTION, "CKA_NETSCAPE_TRUST_EMAIL_PROTECTION");
905         addAttribute(CKA_NETSCAPE_CERT_SHA1_HASH,         "CKA_NETSCAPE_CERT_SHA1_HASH");
906         addAttribute(CKA_NETSCAPE_CERT_MD5_HASH,          "CKA_NETSCAPE_CERT_MD5_HASH");
907 
908         addObjectClass(CKO_DATA,                "CKO_DATA");
909         addObjectClass(CKO_CERTIFICATE,         "CKO_CERTIFICATE");
910         addObjectClass(CKO_PUBLIC_KEY,          "CKO_PUBLIC_KEY");
911         addObjectClass(CKO_PRIVATE_KEY,         "CKO_PRIVATE_KEY");
912         addObjectClass(CKO_SECRET_KEY,          "CKO_SECRET_KEY");
913         addObjectClass(CKO_HW_FEATURE,          "CKO_HW_FEATURE");
914         addObjectClass(CKO_DOMAIN_PARAMETERS,   "CKO_DOMAIN_PARAMETERS");
915         addObjectClass(CKO_VENDOR_DEFINED,      "CKO_VENDOR_DEFINED");
916 
917         addObjectClass(PCKO_ANY,                "*");
918 
919     }
920 
921 }