我使用下面的代码访问令牌的认证文件,模块得到的信息有关的令牌,.NET Net.pkcs11.dll抛出异常system.formatexception在objToken.TokenInfo
Module module = Module.GetInstance(@"C:\WINDOWS\system32\eTPKCS11.dll");
module.Initialize();
Slot[] slots = module.GetSlotList(true);
if (slots.Length== 0)
{
MessageBox.Show("No slot available");
return null;
}
Token token = null;
for (int i = 0; i < slots.Length; i++)
{
if (slots[i].SlotInfo.IsTokenPresent)
token = slots[i].Token; // slots[i].token assigns token to Token object
}
token.TokenInfo;// throws exception at this line
Session session = token.OpenSession(true);
PIN pin = new PIN();
pin.ShowDialog();
// Executes the login passing the user PIN
session.Login(UserType.USER,pin.Pin.ToCharArray());
// Find RSA Private keys
session.FindObjectsInit(new P11Attribute[]{new ObjectClassAttribute(CKO.PRIVATE_KEY),new KeyTypeAttribute(CKK.RSA)}); // hence when calling FindObjectInit method it throws ATTRIBUTE_VALUE_INVALID , stackTrace at Net.Sf.Pkcs11.Wrapper.Pkcs11Module.checkCKR(CKR retVal)
在网。 Sf.Pkcs11.Wrapper.Pkcs11Module.FindObjectsInit(UInt32的hSession,CK_ATTRIBUTE [] pTemplate) 在Net.Sf.Pkcs11.Session.FindObjectsInit(P11Attribute [] ATTRS) 在ECDecryptor.CSPDec.Decrypt(字节[]消息时,字节[ ] pad,Byte [] modulus)in c:\ Users \ vaishali.pathare \ Desktop \ Token \ decryptor_NewChanges \ decryptor_tool_source_2048 \ CSP Registrar Decryptor Utility 2048 \ Decryptor \ CSPDec.cs:line 100 P11Object [] keyObject s = session.FindObjects(10);