我正在尝试使用 pkcs11interop 实现 pkcs 11 标准
我有一些 des2 键(16 字节),我想使用符号方法
我的问题是 sign 方法只返回四个字节。但我想要 8 字节符号。
我应该怎么办?
PS 1:四字节结果是正确的。这是我预期结果的第一个字节。
PS 2:我知道签名方法与加密方法相同。所以我的一个解决方案是加密输入并获得前 8 个字节的结果(这就是我已经在做的)。但我对此感到难过,我认为最好使用 Sign 方法本身。
PS 3:有一个“ICkMacGeneralParams”接口可以用来选择MAC大小。但似乎根本没有影响!我将它设置为 UInt32.MaxValue 和 0,结果没有什么不同。
PS 4:我知道 Sign 方法通常与公钥和私钥一起使用。但我需要一键使用
var data = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
//macParams seems not to work at all! result remains same with any input of CreateCkMacGeneralParams method
var macParams = session.Factories.MechanismParamsFactory.CreateCkMacGeneralParams(8);
var signMechanism = session.Factories.MechanismFactory.Create(CKM.CKM_DES3_MAC, macParams);
//handle references to some 16 byte key with CKK_DES2
var signResult = session.Sign(signMechanism, handle, data);
//result is always 4 bytes