Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session C_FindObjectsInit get not PrivateKey Bug! #40

Closed
erdembas opened this issue Jul 1, 2016 · 10 comments
Closed

Session C_FindObjectsInit get not PrivateKey Bug! #40

erdembas opened this issue Jul 1, 2016 · 10 comments

Comments

@erdembas
Copy link

erdembas commented Jul 1, 2016

Hi,
session.find({ class: graphene.ObjectClass.PRIVATE_KEY }) [C_FindObjectsInit] method get not private key object.
Please help me.

@rmhrisk
Copy link
Contributor

rmhrisk commented Jul 1, 2016

Can you give sample code and details about your environment?

@erdembas
Copy link
Author

erdembas commented Jul 1, 2016

I am using Windows.10 x64 operation system.
NodeJs Version : 4.4.5

var lib = "C:/windows/system32/akisp11.dll";
var graphene = require("graphene-pk11");
var Module = graphene.Module;

var mod = Module.load(lib, "akis");

mod.initialize();

var session = mod.getSlots(0).open();
session.login("078066");

// Return 0! PRivate Key object.
console.log(session.find({ class: graphene.ObjectClass.PRIVATE_KEY }).length);

Graphene-pk11 Library
session.js find method

first while loop rv!== pkcs11.CKR_OK enter break; and exit while.

After objects.push(hObject). rv= this.lib.C_FindObjectsFİnal(this.handle); return 0 object!

Please help me.

@rmhrisk
Copy link
Contributor

rmhrisk commented Jul 1, 2016

@erdembas I will try to help.

It seems akisp11.dll is for uekae based devices/cards. Unfortunately I doubt we can get one here in the US or Russia for testing so we will have some trial and error helping you on this one.

Do you know this device has been initialized? Do you know if it has any keys on it? Based on the return you are seeing it seems the card has no contents.

If you do not one thing to try is to use opensc and it's pkcs11-tool to inspect the card, this way you can clearly check the contents of the card without taking a circular dependency on Graphene.

Another question becomes can you create keys on the card? One way to check this is to try with the Graphene CLI. With it you can check the performance of the card or simply generate a key:

test gen -it 1 -a all

The CLI is like pkcs11-tool, if they see something different there is likley a problem with Graphene.

Please let us know what you find out.

Ryan

@erdembas
Copy link
Author

erdembas commented Jul 1, 2016

SmartCard is initialized and exist any private key on card. I am using java sunpkcs11 provider access private key and create digital signature but using graphene-pk11 not access private key..

@rmhrisk
Copy link
Contributor

rmhrisk commented Jul 1, 2016

Can you confirm if the graphene-cli can access the key? Please run "test gen -it 1 -a all" and capture all console output up until and after that command and paste it here.

@microshine
Copy link
Contributor

It can be a problem with reading structure data from PKCS11 on Windows (TooTallNate/ref-struct#22)

@rmhrisk
Copy link
Contributor

rmhrisk commented Jul 1, 2016

Ah, yes I had forgotten about this.

@erdembas can you try on a non-windows machine?

@rmhrisk
Copy link
Contributor

rmhrisk commented Jul 1, 2016

Linking #39

@erdembas
Copy link
Author

SUCCESS.. THE PROBLEM IS FOR WINDOWS.

@rmhrisk I have just tried on Ubuntu 16.04 x32 os and got success. Return two private key result.
The problem is about windows os. Any idea to solve the problem for windows os.

Thanks

image

@rmhrisk
Copy link
Contributor

rmhrisk commented Jul 23, 2016

@erdembas thanks for doing the check, our issue was either with node-ffi or our use of it, to fix this we ended up re-writing to take out this dependency.

@microshine will do a publication of a new version in the next couple days that should resolve this, we would like to ask that once it is released that you test your token again on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants