In am using PKCS11Interop in C#, i got CKR_MECHANISM_INVALID error while trying to use method Sign. The key object i am using is of mechanism type CKM_EC_KEY_PAIR_GEN . but at signing time, i use mechanism CKM_ECDSA_SHA512 .
I tried to define key mechanism as CKM_ECDSA_SHA512 at key-pair generation time, but it seems that this key type needs some attributes that i don't know. The attributes i am using is similar to the correct version of this question, but it seems using hash algorithms need some thing more.
Please guide me how should i use SHA512 hash algorithm with ECDSA elliptic key.
Your unmanaged PKCS#11 library most likely does not support
CKM_ECDSA_SHA512.By returning
CKR_MECHANISM_INVALIDerror your unmanaged PKCS#11 library is telling you that "An invalid mechanism was specified to the cryptographic operation". You can useGetMechanismInfo()method to check whether the mechanism is supported:However
CKM_ECDSA_SHA512(hashing and signing) mechanism is used rather rarely. It's much more common and efficient to compute SHA512 hash in your application and then sign it withCKM_ECDSA(just signing) mechanism.