GenerateKey() публичный Метод

Generates a secret key or set of domain parameters, creating a new object
public GenerateKey ( Mechanism mechanism, List attributes ) : ObjectHandle
mechanism Mechanism Generation mechanism
attributes List Attributes of the new key or set of domain parameters
Результат ObjectHandle
Пример #1
0
 /// <summary>
 /// Generates symetric key.
 /// </summary>
 /// <param name='session'>Read-write session with user logged in</param>
 /// <returns>Object handle</returns>
 public static ObjectHandle GenerateKey(Session session)
 {
     // Prepare attribute template of new key
     List<ObjectAttribute> objectAttributes = new List<ObjectAttribute>();
     objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKO.CKO_SECRET_KEY));
     objectAttributes.Add(new ObjectAttribute(CKA.CKA_KEY_TYPE, CKK.CKK_DES3));
     objectAttributes.Add(new ObjectAttribute(CKA.CKA_ENCRYPT, true));
     objectAttributes.Add(new ObjectAttribute(CKA.CKA_DECRYPT, true));
     objectAttributes.Add(new ObjectAttribute(CKA.CKA_DERIVE, true));
     objectAttributes.Add(new ObjectAttribute(CKA.CKA_EXTRACTABLE, true));
     
     // Specify key generation mechanism
     Mechanism mechanism = new Mechanism(CKM.CKM_DES3_KEY_GEN);
     
     // Generate key
     return session.GenerateKey(mechanism, objectAttributes);
 }