How to make attribute template for PBKDF2 key generation in pkcs11interop.
Below is my trial code :
byte[] randomSalt = session.GenerateRandom(20);
objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKZ.CKZ_SALT_SPECIFIED));
objectAttributes.Add(new ObjectAttribute(CKA.CKA_VALUE, randomSalt));
objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, 1000));
objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, 0x00000004));
objectAttributes.Add(new ObjectAttribute(CKA.CKA_VALUE, new byte[] { }));
objectAttributes.Add(new ObjectAttribute(CKA.CKA_VALUE, Encoding.UTF8.GetBytes("password")));
Mechanism mechanism = new Mechanism(CKM.CKM_PKCS5_PBKD2);
objectHandle objectHandle = session.GenerateKey(mechanism, objectAttributes);
With this I am getting CKR_MECHANISM_INVALID exception