Class: PKCS11::Luna::Library

Inherits:
Library
  • Object
show all
Defined in:
lib/pkcs11_luna/extensions.rb,
ext/pk11l.c,
ext/pk11l.c

Overview

Derived class for Luna Library

Constant Summary collapse

MechanismParameters =
{
  CKM_AES_GCM => CK_AES_GCM_PARAMS,
  CKM_ECIES => CK_ECIES_PARAMS,
  CKM_XOR_BASE_AND_DATA_W_KDF => CK_XOR_BASE_DATA_KDF_PARAMS,
  CKM_PRF_KDF => CK_PRF_KDF_PARAMS,
  CKM_NIST_PRF_KDF => CK_PRF_KDF_PARAMS,
  CKM_SEED_CTR => CK_AES_CTR_PARAMS,
  CKM_AES_CTR => CK_AES_CTR_PARAMS,
  CKM_DES3_CTR => CK_DES_CTR_PARAMS,
  CKM_AES_GMAC => CK_AES_GCM_PARAMS,
  CKM_AES_CBC_PAD_EXTRACT => CK_AES_CBC_PAD_EXTRACT_PARAMS,
  CKM_AES_CBC_PAD_INSERT => CK_AES_CBC_PAD_INSERT_PARAMS,
  CKM_AES_CBC_PAD_EXTRACT_FLATTENED => CK_AES_CBC_PAD_EXTRACT_PARAMS,
  CKM_AES_CBC_PAD_INSERT_FLATTENED => CK_AES_CBC_PAD_INSERT_PARAMS,
  CKM_PKCS5_PBKD2 => Luna::CK_PKCS5_PBKD2_PARAMS
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Library

Returns a new instance of Library.



276
277
278
# File 'ext/pk11l.c', line 276

def initialize(so_path = :config, args = {})
  unwrapped_initialize(so_path, args)
end

Instance Attribute Details

#so_pathObject (readonly)

Path and file name of the loaded cryptoki library.



50
51
52
# File 'lib/pkcs11_luna/extensions.rb', line 50

def so_path
  @so_path
end

Instance Method Details

#load_library(so_path) ⇒ Object



66
67
68
69
# File 'lib/pkcs11_luna/extensions.rb', line 66

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

#unwrapped_initializeObject

Load and initialize a pkcs11 dynamic library with Safenet Luna extensions.

Set so_path to :config, in order to autodetect the .dll or .so or set it to the full path of the .dll or .so file.

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

Parameters:

  • so_path (String, Symbol)

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

  • args (Hash, CK_C_INITIALIZE_ARGS)

    A Hash or CK_C_INITIALIZE_ARGS instance with load params.



61
# File 'lib/pkcs11_luna/extensions.rb', line 61

alias unwrapped_initialize initialize

#vendor_all_attribute_namesObject



107
108
109
# File 'lib/pkcs11_luna/extensions.rb', line 107

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

#vendor_class_CK_ATTRIBUTEObject



125
126
127
# File 'lib/pkcs11_luna/extensions.rb', line 125

def vendor_class_CK_ATTRIBUTE
  Luna::CK_ATTRIBUTE
end

#vendor_const_get(name) ⇒ Object



102
103
104
105
# File 'lib/pkcs11_luna/extensions.rb', line 102

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

#vendor_mechanism_parameter_struct(mech) ⇒ Object



111
112
113
# File 'lib/pkcs11_luna/extensions.rb', line 111

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

#vendor_raise_on_return_value(rv) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/pkcs11_luna/extensions.rb', line 115

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