Key Not Needed

1/8/2013 3:26:08 PM
Gravatar
Total Posts 17

Key Not Needed

Hi,

 

when trying to decrypt a string with the following code:

 

nRes = session.DecryptInit(Mechanism.RSA_PKCS, privateKey)

Dim decrypted() As Byte = session.Decrypt(text)

 

I get  error message CKR_KEY_NOT_NEEDED but I dont understand why....

 

The string that we try to decode has been encoded earlier by the public key in the same key pair.

Please help

 

Best regards

1/12/2013 2:35:47 PM
Gravatar
Total Posts 300
Ugo Chirico http://www.ugochirico.com

Re: Key Not Needed

Hi,

your error is very strange. PKCS#11 specification says:

CKR_KEY_NOT_NEEDED: An extraneous key was supplied to C_SetOperationState. For example, an attempt was made to restore a session that
had been performing a message digesting operation, and an encryption key was supplied.

Even if this error is related to the function SetOperationState it seems that the key you passed to DecryptInit is not good for decryption. Probably that key doesn't have the flag CKA_DECRYPT to true.