开发者

Get a byte array from gtop11dotnet.dll in c#

I have a gtop11dotnet.dll. It is .NET PKCS#11 Library for Windows v2.2.0.9 from Gemalto website. DLL is containing C_GetCardProperty method which can be used to retrieve Smart card's serial number or GUID. According to PKCS#11 User's Guide and .NET Integration Guide it is "byte[] GetCardProperty(byte property, byte flags)". It receives two bytes as parameters and retrieves e.g. serial number or GUID in form of bytes array. My question is how to get serial number and store it into managed bytes array?

Here is my try:

[DllImport("gtop11dotnet.dl开发者_如何学Pythonl")]
public static extern byte[] C_GetCardProperty(byte property, byte flags);
public static void Main()
{
    byte[] bytes = new byte[12];
    bytes = C_GetCardProperty(0x06, 0x00) //Error at this line -> Cannot marshal 'return value': Invalid managed/unmanaged type combination.
}

Thanks for any help.


What is ".NET PKCS#11"? PKCS#11 v2.20 nor v2.30 draft do not contain "C_GetCardProperty" method. You are probably facing with some proprietary Gemalto/.NET thing that has nothing to do with PCKS#11 as known by the rest of the world and Gemalto does a "good" thing by prefixing arbitrary functions with "C_" and calling the result cryptoki. PKCS#11 is a C interface and has nothing to do with managed/unmanaged code or .NET.


Try this.

public static extern uint C_GetCardProperty(uint slotID, byte property, byte flags, byte[] blob, ref byte length);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜