Skip to content

Latest commit

 

History

History
89 lines (57 loc) · 2.59 KB

README.rdoc

File metadata and controls

89 lines (57 loc) · 2.59 KB

PKCS #11/Ruby Interface for Safenet Protect Server HSM

This ruby gem is an add-on to ruby-pkcs11 . It allowes to use Protect Server specific extensions, which are beyond the PKCS#11 standard. That means CKA_EXPORT, CKM_DES3_DERIVE_CBC, structs like CK_DES3_CBC_PARAMS, special functions and so on. The module works on the Unix like operating systems and win32.

Requirements

  • Safenet PTKC-SDK to compile the module

  • pkcs11 gem installed (use: gem install pkcs11 )

Installation

gem install pkcs11-safenet -- --with-safenet-sdk-dir=/path/to/ETcpsdk

This installs the Safenet-PKCS#11 extension along with pkcs11-gem either by compiling (Unix) or by using the precompiled gem for Win32.

git clone git://github.com/larskanis/pkcs11-safenet.git
cd pkcs11-safenet
rake gem SAFENET_SDK_DIR=/path/to/ETcpsdk
gem install -l pkg/pkcs11-safenet -- --with-safenet-sdk-dir=/path/to/ETcpsdk

Downloads and installs the gem from git source.

Usage

Open the software emulation library and login to a session:

require "rubygems"
require "pkcs11_safenet"

pkcs11 = PKCS11::Safenet::Library.new(:sw)
p pkcs11.info
session = pkcs11.active_slots.last.open
session.login(:USER, "1234")
# ... crypto operations
session.logout
session.close

{PKCS11::Safenet::Library#initialize} tries to find the library file in the standard installation directory on Windows or Linux.

Cross compiling for mswin32

Using rake-compiler a cross compiled pkcs11-safenet-gem can be build on a linux host for the win32 platform. There are no runtime dependencies to any but the standard Windows DLLs.

Install mingw32. On a debian based system this should work:

apt-get install mingw32

On MacOS X, if you have MacPorts installed:

port install i386-mingw32-gcc

Install the rake-compiler:

gem install rake-compiler

Download and cross compile ruby for win32:

rake-compiler cross-ruby VERSION=1.8.6-p287

Download and cross compile pkcs11-safenet for win32:

rake cross native gem SAFENET_SDK_DIR=/path/to/ETcpsdk

If everything works, there should be pkcs11-safenet-VERSION-x86-mswin32.gem in the pkg directory.

ToDo

  • implement Safenet specific function calls

  • implement possibility to use callbacks

  • add all structs and constants

Authors

  • Lars Kanis <kanis@comcard.de>

Copying

See MIT-LICENSE included in the package.