Class: PKCS11::ProtectServer::Library
- Inherits:
-
Library
- Object
- Library
- PKCS11::ProtectServer::Library
- 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
-
#so_path ⇒ Object
readonly
Path and file name of the loaded cryptoki library.
Instance Method Summary collapse
-
#initialize(so_path = nil, args = {}) ⇒ Library
constructor
Load and initialize a pkcs11 dynamic library with Safenet Protect Server extensions.
- #vendor_all_attribute_names ⇒ Object
- #vendor_class_CK_ATTRIBUTE ⇒ Object
- #vendor_const_get(name) ⇒ Object
- #vendor_mechanism_parameter_struct(mech) ⇒ Object
- #vendor_raise_on_return_value(rv) ⇒ Object
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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/pkcs11_protect_server/extensions.rb', line 60 def initialize(so_path = nil, args = {}) if [:sw, :hsm].include?(so_path) if RUBY_PLATFORM =~ /mswin|mingw/ libctsw_so = "cryptoki.dll" libctsw_so_paths = [ File.join(ENV['ProgramFiles'], "SafeNet/ProtectToolkit C SDK/bin/#{so_path}"), ] else libctsw_so = "libct#{so_path}.so" libctsw_so_paths = [ "/opt/ETcpsdk/lib/linux-i386", "/opt/ETcpsdk/lib/linux-x86_64", "/opt/PTK/lib", ] end unless so_path=ENV['CRYPTOKI_SO'] paths = libctsw_so_paths.collect{|path| File.join(path, libctsw_so) } so_path = paths.find{|path| File.exist?(path) } end raise "#{libctsw_so} not found - please install ProtectServer PTK-C or set ENV['CRYPTOKI_SO']" unless so_path end @so_path = so_path super(so_path, args) end |
Instance Attribute Details
#so_path ⇒ Object (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
#vendor_all_attribute_names ⇒ Object
93 94 95 |
# File 'lib/pkcs11_protect_server/extensions.rb', line 93 def vendor_all_attribute_names return ProtectServer::ATTRIBUTES.values + super end |
#vendor_class_CK_ATTRIBUTE ⇒ Object
108 109 110 |
# File 'lib/pkcs11_protect_server/extensions.rb', line 108 def vendor_class_CK_ATTRIBUTE ProtectServer::CK_ATTRIBUTE end |
#vendor_const_get(name) ⇒ Object
88 89 90 91 |
# File 'lib/pkcs11_protect_server/extensions.rb', line 88 def vendor_const_get(name) return ProtectServer.const_get(name) if ProtectServer.const_defined?(name) super end |
#vendor_mechanism_parameter_struct(mech) ⇒ Object
97 98 99 |
# File 'lib/pkcs11_protect_server/extensions.rb', line 97 def vendor_mechanism_parameter_struct(mech) MechanismParameters[mech] || super end |
#vendor_raise_on_return_value(rv) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/pkcs11_protect_server/extensions.rb', line 101 def vendor_raise_on_return_value(rv) if ex=ProtectServer::RETURN_VALUES[rv] raise(ex, rv.to_s) end super end |