Re: Programmatically acess smartcard with NSS

Túlio Gomes <[email protected]>
Newsgroups gmane.comp.mozilla.crypto
Message-ID <[email protected]>
Em quinta-feira, 17 de março de 2016 14:16:30 UTC-3, Túlio Gomes  escreveu:
> Hello, i need to access a smartcard for signing documents with the private key stored inside it.
> The idea is to create a c++ component that will be used with a pnacl module inside chrome's browser.
> 
> So i decided to use NSS, but i'm confused about what steps i need to do for load the smartcard, access the private key, sign and verify the document.
> 
> I read almost all the existing documentation and didn find any sample to do that.
> 
> Here's my code:
> 
> int main(int argc, char** argv) {
> 	SECMODModule *module;
> 	SECStatus rv;
> 	static char moduleName[] = "library=libwdpkcs_icp.so name=Token-libwdpkcs_icp";
> 		
> 	module = SECMOD_LoadUserModule(moduleName, NULL, PR_TRUE);
> 
> 	if(!module) {
> 		fprintf(stderr, "fail to load module");
> 		exit(1);
> 	}
> 
> 	PK11SlotInfo* slot = PK11_GetInternalSlot(); //didnt work. Returns nothing (0x0);
> 
> 	/*
> 	*  Ok, i load the module. What's next? I need to create a DB or i can access the token directly? If so, how can i do this?
> 	*  Probably the next step is to get the slot info. But how?
> 	*/
> 
> 	SECMOD_DestroyModule(module);
> }
> 
> Can anyone give me some help? 
> Thanks in advance.
> ps: sorry for my english



Em quinta-feira, 17 de março de 2016 14:16:30 UTC-3, Túlio Gomes  escreveu:
> Hello, i need to access a smartcard for signing documents with the private key stored inside it.
> The idea is to create a c++ component that will be used with a pnacl module inside chrome's browser.
> 
> So i decided to use NSS, but i'm confused about what steps i need to do for load the smartcard, access the private key, sign and verify the document.
> 
> I read almost all the existing documentation and didn find any sample to do that.
> 
> Here's my code:
> 
> int main(int argc, char** argv) {
> 	SECMODModule *module;
> 	SECStatus rv;
> 	static char moduleName[] = "library=libwdpkcs_icp.so name=Token-libwdpkcs_icp";
> 		
> 	module = SECMOD_LoadUserModule(moduleName, NULL, PR_TRUE);
> 
> 	if(!module) {
> 		fprintf(stderr, "fail to load module");
> 		exit(1);
> 	}
> 
> 	PK11SlotInfo* slot = PK11_GetInternalSlot(); //didnt work. Returns nothing (0x0);
> 
> 	/*
> 	*  Ok, i load the module. What's next? I need to create a DB or i can access the token directly? If so, how can i do this?
> 	*  Probably the next step is to get the slot info. But how?
> 	*/
> 
> 	SECMOD_DestroyModule(module);
> }
> 
> Can anyone give me some help? 
> Thanks in advance.
> ps: sorry for my english



Em quinta-feira, 17 de março de 2016 14:16:30 UTC-3, Túlio Gomes  escreveu:
> Hello, i need to access a smartcard for signing documents with the private key stored inside it.
> The idea is to create a c++ component that will be used with a pnacl module inside chrome's browser.
> 
> So i decided to use NSS, but i'm confused about what steps i need to do for load the smartcard, access the private key, sign and verify the document.
> 
> I read almost all the existing documentation and didn find any sample to do that.
> 
> Here's my code:
> 
> int main(int argc, char** argv) {
> 	SECMODModule *module;
> 	SECStatus rv;
> 	static char moduleName[] = "library=libwdpkcs_icp.so name=Token-libwdpkcs_icp";
> 		
> 	module = SECMOD_LoadUserModule(moduleName, NULL, PR_TRUE);
> 
> 	if(!module) {
> 		fprintf(stderr, "fail to load module");
> 		exit(1);
> 	}
> 
> 	PK11SlotInfo* slot = PK11_GetInternalSlot(); //didnt work. Returns nothing (0x0);
> 
> 	/*
> 	*  Ok, i load the module. What's next? I need to create a DB or i can access the token directly? If so, how can i do this?
> 	*  Probably the next step is to get the slot info. But how?
> 	*/
> 
> 	SECMOD_DestroyModule(module);
> }
> 
> Can anyone give me some help? 
> Thanks in advance.
> ps: sorry for my english

I just had some progress but now i'm stuck in how i can prompt the user for password. Can anyone help?
-- 
dev-tech-crypto mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-crypto
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.