Class: PKCS11::ProtectServer::Library

Inherits:
Library
  • Object
show all
Defined in:
lib/pkcs11_protect_server/extensions.rb

Overview

A ProtectServer::Library instance holds a handle to the opened cryptoki.dll or cryptoki.so file.

This class is derived from PKCS11::Library of pkcs11.gem.

Constant Summary collapse

MechanismParameters =
{
  CKM_DES_DERIVE_CBC => CK_DES_CBC_PARAMS,
  CKM_DES3_DERIVE_CBC => CK_DES3_CBC_PARAMS,
  CKM_ECIES => CK_ECIES_PARAMS,
  CKM_ENCODE_X_509 => CK_MECH_TYPE_AND_OBJECT,
  CKM_PKCS12_PBE_EXPORT => CK_PKCS12_PBE_EXPORT_PARAMS,
  CKM_PKCS12_PBE_IMPORT => CK_PKCS12_PBE_IMPORT_PARAMS,
  CKM_PP_LOAD_SECRET => CK_PP_LOAD_SECRET_PARAMS,
  CKM_REPLICATE_TOKEN_RSA_AES => CK_REPLICATE_TOKEN_PARAMS,
  CKM_SECRET_RECOVER_WITH_ATTRIBUTES => CK_SECRET_SHARE_PARAMS,
  CKM_SHA1_RSA_PKCS_TIMESTAMP => CK_TIMESTAMP_PARAMS,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(so_path = nil, args = {}) ⇒ Library

Load and initialize a pkcs11 dynamic library with Safenet Protect Server extensions.

Set so_path to :hsm, :sw or :logger in order to autodetect the cryptoki-HSM or software emulation library file.

See also PKCS11::Library#initialize of pkcs11.gem

Parameters:

  • so_path (String, Symbol, nil) (defaults to: nil)

    Shortcut-Symbol or path to the *.so or *.dll file to load.

  • args (Hash, CK_C_INITIALIZE_ARGS) (defaults to: {})

    A Hash or CK_C_INITIALIZE_ARGS instance with load params.



60
61
62
# File 'lib/pkcs11_protect_server/extensions.rb', line 60

def initialize(so_path = nil, args = {})
  super(so_path, args)
end

Instance Attribute Details

#so_pathObject (readonly)

Path and file name of the loaded cryptoki library.



49
50
51
# File 'lib/pkcs11_protect_server/extensions.rb', line 49

def so_path
  @so_path
end

Instance Method Details

#load_library(so_path) ⇒ Object



64
65
66
67
# File 'lib/pkcs11_protect_server/extensions.rb', line 64

def load_library(so_path)
  @so_path = resolve_so_path(so_path)
  super(@so_path)
end

#vendor_all_attribute_namesObject



101
102
103
# File 'lib/pkcs11_protect_server/extensions.rb', line 101

def vendor_all_attribute_names
  return ProtectServer::ATTRIBUTES.values + super
end

#vendor_class_CK_ATTRIBUTEObject



116
117
118
# File 'lib/pkcs11_protect_server/extensions.rb', line 116

def vendor_class_CK_ATTRIBUTE
  ProtectServer::CK_ATTRIBUTE
end

#vendor_const_get(name) ⇒ Object



96
97
98
99
# File 'lib/pkcs11_protect_server/extensions.rb', line 96

def vendor_const_get(name)
  return ProtectServer.const_get(name) if ProtectServer.const_defined?(name)
  super
end

#vendor_mechanism_parameter_struct(mech) ⇒ Object



105
106
107
# File 'lib/pkcs11_protect_server/extensions.rb', line 105

def vendor_mechanism_parameter_struct(mech)
  MechanismParameters[mech] || super
end

#vendor_raise_on_return_value(rv) ⇒ Object



109
110
111
112
113
114
# File 'lib/pkcs11_protect_server/extensions.rb', line 109

def vendor_raise_on_return_value(rv)
  if ex=ProtectServer::RETURN_VALUES[rv]
    raise(ex, rv.to_s)
  end
  super
end