Skip to content

carblue/pkcs11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build state

Build Status Coverage Status

pkcs11

Twofold binding to PKCS #11 Cryptoki interface (Version 2.40 Plus Errata 01) {1,2 PKCS#11}

configuration 'deimos': Static binding, the "import-only" C header's declarations.
configuration 'derelict': Dynamic binding (DerelictUtil), the header's declarations + derelict runtime loading (any pkcs#11 implementing shared library(s)) interface.

With configuration 'derelict', the version identifier PKCS11_DYNAMIC_BINDING_ONE is set as default by dub.json, meaning, that connecting to exactly one only PKCS#11 implementing library is as easy as shown in the code snippet below. In the one-library-case, You won't have to deal with the CK_FUNCTION_LIST_PTR. There is also version identifier PKCS11_DYNAMIC_BINDING_MULTIPLE for cases, where multiple/different PKCS#11 libraries will be used by an application. Version identifier P11KIT may be used with PKCS11_DYNAMIC_BINDING_ONE, i.a. to select the PKCS#11 implementing library via the p11-kit configuration.

For more information on dynamic binding and Your options with derelict-util, look at {4 Derelict}.
Here's some sample code:

// Written in the D programming language
// configuration 'derelict'
import std.stdio;
import pkcs11;

int main() {
	PKCS11.load(); // uses default library: opensc-pkcs11.so/.dll {5 OpenSC}, or do specify explicitely

	CK_RV rv;
	if ((rv=C_Initialize(null)) != CKR_OK) {
		writeln("Failed to initialze Cryptoki");
		return 1;
	}
	scope(exit)
		C_Finalize(NULL_PTR);

	...
}

1 PKCS#11
2 PKCS#11 headers
3 PKCS#11 programming intro
4 Derelict
5 OpenSC, opensc.conf/debug/debug_file, inspect (high-level) Cryptoki communication
(6 Inspect (low-level) PC/SC communication)

Not yet covered: v3.0
7 PKCS#11
8 PKCS#11 headers

About

Twofold binding to PKCS #11 Cryptoki interface

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published