I have to generate HMAC(SHA256) signature with an AES-256 key on the Utimaco HSM simulator. I use the PKCS#11 library "Pkcs11Interop" (C#) for this. My source code function:
public static byte[] GetSignatureHmacSha256(IObjectHandle secretKeyHandle, byte[] message)
{
ICkMacGeneralParams macParams = Settings.Factories.MechanismParamsFactory.CreateCkMacGeneralParams(32);
IMechanism mechanism = session.Factories.MechanismFactory.Create(CKM.CKM_SHA256_HMAC_GENERAL, macParams);
byte[] signature = session.Sign(mechanism, secretKeyHandle, message);
return signature;
}
I get this error message. Can someone help me what am I doing wrong?
"Method C_SignInit returned CKR_MECHANISM_INVALID"
Utimaco Log: "Mechanism CKM_SHA256_HMAC_GENERAL doesn't fit key t."