Description

Twofold (deimos/derelict) binding to PKCS #11 Cryptoki interface

Package Information

Version2.40.0-alpha.3 (2017-Mar-19)
Homepagehttps://github.com/carblue/pkcs11
Repositoryhttps://github.com/carblue/pkcs11
LicenseLGPL-2.1
CopyrightCopyright © 2017, Carsten Blüggel
AuthorsCarsten Blüggel
Registered byCarsten Blüggel
Dependenciesnone

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

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 PKCS11DYNAMICBINDINGONE 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 CKFUNCTIONLISTPTR. There is also version identifier PKCS11DYNAMICBINDINGMULTIPLE for cases, where multiple/different PKCS#11 libraries will be used by an application. Version identifier P11KIT may be used with PKCS11DYNAMICBINDINGONE, 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)

Available versions

2.40.0-alpha.3 2.40.0-alpha.2 2.40.0-alpha.1 ~master