Sha256 RSA signature

4/4/2017 7:53:26 PM
Gravatar
Total Posts 1

Sha256 RSA signature

Hello,

We've been working with NCryptoki for quite a while, but we've been using SHA1 signatures until now.

A recent project requires us to switch to RSA + SHA256 for signature and verification purposes.

Currently we are using the code showed in the documentation:

    nRes = session.SignInit(Mechanism.SHA1_RSA_PKCS, privateKey);

From what I can see, I'd have to switch to:

    nRes = session.SignInit(Mechanism.CKM_SHA256_RSA_PKCS, privateKey);

Is this correct? Also, it gives me a compile error ("Cannot convert from int to Cryptware.NCryptoki.Mechanism)

How would I go around to actually signing data with SHA256 + RSA?

 

Thank you for your time,

 

Fernando

 


 

4/4/2017 8:11:44 PM
Gravatar
Total Posts 30

Re: Sha256 RSA signature

You can set your mechanism by using this code.

Mechanism mechanism = new Mechanism(Mechanism.CKM_SHA256_RSA_PKCS, null);

and then sign with this code:

nRes = session.SignInit(mechanism, privateKey);