pkcs11 0.2.6 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 20e09104f3d3d4612707a80a370726b048de1c78
4
- data.tar.gz: 423e7a843678a770b76d486478a18925ff428ee0
2
+ SHA256:
3
+ metadata.gz: 0fb60ecaa0300930499d7783396ff4f471174f6bca63a97082208baaa9d3521b
4
+ data.tar.gz: c3019089cd8d0a8c2aed6d11f8a3f3b55d688c199ea62fb85b385e195e98494c
5
5
  SHA512:
6
- metadata.gz: d4dae807594372b47a5b006619936630c63e07c55f9fc0f7d82db5a4d4a2b1c5f4e23e3eab4c219f5a10ee65a485f1e428c796f4009c35507c37a84b33798667
7
- data.tar.gz: 297c34351e2014ea8f9416a84f7c3b9a9b1843bc579ef6e40b89f6fe23318de20c5d58ce5c0f9498af3a3dde08a540bef24f25d84960968d67574e65b357acde
6
+ metadata.gz: d3f00f7d6fa0b386477b06de8e1fe30257f0fb4e625c7661ca90bad46fee20449d3f2b17ce71c132f11c3f2d11ed2aa8e27cbfb8c6000cb33d23c4a10d6a2aee
7
+ data.tar.gz: af86c163e05b8d7e850563fa724901bad4a6ed395a712b2c7f6a0a5dfc1c65352bd729d0f722d00b52db33f19bd8e4884d3ac26cbf5eda8f3c6db0c2bdfb6d73
Binary file
Binary file
@@ -0,0 +1,44 @@
1
+ install:
2
+ - SET PATH=C:/Ruby%ruby_version%/bin;%PATH%
3
+ - SET RAKEOPT=-rdevkit
4
+ - ps: |
5
+ if ($env:ruby_version -like "*head*") {
6
+ $(new-object net.webclient).DownloadFile("https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-$env:ruby_version.exe", "$pwd/ruby-setup.exe")
7
+ cmd /c ruby-setup.exe /verysilent /dir=C:/Ruby$env:ruby_version
8
+ }
9
+ - ruby --version
10
+ - gem --version
11
+ - bundle install
12
+
13
+ # When running ruby-x86, we make use of the softokn3.dll that is part of the
14
+ # pre-installed firefox. The test helper will find it automatically.
15
+ # When running ruby-x64, we equally need a 64 bit softokn3.dll to test against.
16
+ # However it is not part of any installed software on Appveyor,
17
+ # so we download and install a 64 bit firefox version and use it's softokn3.dll.
18
+ - ps: |
19
+ if ($env:ruby_version -like "*x64*") {
20
+ $(new-object net.webclient).DownloadFile('http://ftp.mozilla.org/pub/firefox/releases/68.3.0esr/win64/en-US/Firefox%20Setup%2068.3.0esr.exe', 'C:/firefox-setup.exe')
21
+ $env:SOFTOKN_PATH = 'C:/Program Files/Mozilla Firefox/softokn3.dll'
22
+ $env:PATH = 'C:/Program Files/Mozilla Firefox;' + $env:PATH
23
+ } else {
24
+ $(new-object net.webclient).DownloadFile('http://ftp.mozilla.org/pub/firefox/releases/68.3.0esr/win32/en-US/Firefox%20Setup%2068.3.0esr.exe', 'C:/firefox-setup.exe')
25
+ $env:SOFTOKN_PATH = 'C:/Program Files (x86)/Mozilla Firefox/softokn3.dll'
26
+ $env:PATH = 'C:/Program Files (x86)/Mozilla Firefox;' + $env:PATH
27
+ }
28
+ cmd /c "C:/firefox-setup.exe" -ms
29
+
30
+ build: off
31
+
32
+ test_script:
33
+ - bundle exec rake compile test gem
34
+
35
+ environment:
36
+ matrix:
37
+ - ruby_version: head-x64
38
+ RUBY_DLL_PATH: "C:/Program Files/Mozilla Firefox"
39
+ - ruby_version: "25"
40
+ RUBY_DLL_PATH: "C:/Program Files (x86)/Mozilla Firefox"
41
+ - ruby_version: "24-x64"
42
+ RUBY_DLL_PATH: "C:/Program Files/Mozilla Firefox"
43
+ - ruby_version: "22"
44
+ - ruby_version: "23-x64"
@@ -0,0 +1,25 @@
1
+ ext/pk11_const_def.inc
2
+ ext/pk11_struct.doc
3
+ ext/pk11_struct_def.inc
4
+ ext/pk11_struct_impl.inc
5
+ ext/pk11_thread_funcs.c
6
+ ext/pk11_thread_funcs.h
7
+ pkcs11_luna/ext/generate_constants.rb
8
+ pkcs11_luna/ext/generate_structs.rb
9
+ pkcs11_luna/ext/pk11_const_macros.h
10
+ pkcs11_luna/ext/pk11_struct_macros.h
11
+ pkcs11_luna/ext/pk11_version.h
12
+ pkcs11_luna/ext/std_structs.rb
13
+ pkcs11_luna/pkg/
14
+ pkcs11_protect_server/ext/generate_constants.rb
15
+ pkcs11_protect_server/ext/generate_structs.rb
16
+ pkcs11_protect_server/ext/pk11_const_macros.h
17
+ pkcs11_protect_server/ext/pk11_struct_macros.h
18
+ pkcs11_protect_server/ext/pk11_version.h
19
+ pkcs11_protect_server/ext/std_structs.rb
20
+ pkcs11_protect_server/pkg/
21
+ *.so
22
+ Gemfile.lock
23
+ tmp
24
+ Manifest.txt
25
+ pkg/
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - "1.9.3"
5
- - "2.2.0"
6
- - rbx
4
+ - "2.2"
5
+ - "2.5.7"
6
+ - "ruby-head"
7
+ - truffleruby
7
8
  matrix:
8
9
  allow_failures:
9
- - rvm: rbx
10
+ - rvm: truffleruby
10
11
  script: bundle exec rake compile test gem
data/Gemfile CHANGED
@@ -5,12 +5,12 @@
5
5
  source "https://rubygems.org/"
6
6
 
7
7
 
8
- gem "yard", ">=0.6", :group => [:development, :test]
8
+ gem "yard", "~>0.6", :group => [:development, :test]
9
9
  gem "rake-compiler", "~>1.0", :group => [:development, :test]
10
- gem "rake-compiler-dock", "~>0.6.0", :group => [:development, :test]
10
+ gem "rake-compiler-dock", "~>0.6.2", :group => [:development, :test]
11
11
  gem "minitest", "~>5.7", :group => [:development, :test]
12
12
  gem "hoe-bundler", "~>1.0", :group => [:development, :test]
13
- gem "rdoc", "~>4.0", :group => [:development, :test]
14
- gem "hoe", "~>3.16", :group => [:development, :test]
13
+ gem "rdoc", ">=4.0", "<7", :group => [:development, :test]
14
+ gem "hoe", "~>3.22", :group => [:development, :test]
15
15
 
16
16
  # vim: syntax=ruby
@@ -1,3 +1,35 @@
1
+ === 0.3.3 / 2020-11-07
2
+
3
+ * Fix possible segfault on GC pressure at startup
4
+ * Move CI from http://travis-ci.org to https://travis-ci.com
5
+
6
+ === 0.3.2 / 2020-01-12
7
+
8
+ * pkcs11_protect_server, pkcs11_luna: Move parsing of vendor header files to gem installation.
9
+ This fixes possible compile errors, if the version of vendor header files differ between gem build and gem install.
10
+ * pkcs11_luna: Workaround invalid UTF-8 encoding in cryptoki_v2.h of some Luna Client versions.
11
+
12
+ === 0.3.1 / 2020-01-07
13
+
14
+ * Fix compilation issue with newer Luna client library. #11
15
+
16
+ === 0.3.0 / 2019-12-05
17
+
18
+ * Change hash style in documentation and tests.
19
+ It was kind of {:LABEL => value} and is now {LABEL: value}
20
+ * Implement proper String encoding support.
21
+ Now strings retrieved as attribute values and from struct members
22
+ are tagged with binary, ASCII or UTF8 encoding.
23
+ * Remove compatibility to rubies < 2.2.
24
+ * Add support for TruffleRuby
25
+
26
+ === 0.2.7 / 2018-01-05
27
+
28
+ * Add vendor extension for Safenet Luna called pkcs11_luna.
29
+ * Fix warnings to Fixnum/Bignum in Ruby-2.4+.
30
+ * Add binary Windows gems for Ruby-2.5.
31
+ * Add a note about RUBY_DLL_PATH on Windows.
32
+
1
33
  === 0.2.6 / 2017-06-07
2
34
 
3
35
  * Update pkcs11 header files to PKCS11-v2.4.
@@ -1,10 +1,10 @@
1
- {<img src="https://travis-ci.org/larskanis/pkcs11.png?branch=master" alt="Build Status" />}[https://travis-ci.org/larskanis/pkcs11]
2
- {<img src="https://ci.appveyor.com/api/projects/status/8m7ugl1ogijw1c8c?svg=true" alt="Build Status" />}[https://ci.appveyor.com/project/larskanis/pkcs11]
3
-
4
1
  = PKCS #11/Ruby Interface
5
2
 
6
- * Homepage: http://github.com/larskanis/pkcs11
7
- * API documentation: http://rubydoc.info/gems/pkcs11/frames
3
+ home :: http://github.com/larskanis/pkcs11
4
+ API documentation :: http://rubydoc.info/gems/pkcs11/frames
5
+
6
+ {<img src="https://travis-ci.com/larskanis/pkcs11.svg?branch=master" alt="Build Status" />}[https://travis-ci.com/larskanis/pkcs11]
7
+ {<img src="https://ci.appveyor.com/api/projects/status/8m7ugl1ogijw1c8c?svg=true" alt="Build Status" />}[https://ci.appveyor.com/project/larskanis/pkcs11]
8
8
 
9
9
  This module allows Ruby programs to interface with "RSA Security Inc.
10
10
  PKCS #11 Cryptographic Token Interface (Cryptoki)".
@@ -43,8 +43,8 @@ While this seems to be true for C, it shouldn't for Ruby.
43
43
  pkcs11.active_slots.first.open do |session|
44
44
  session.login(:USER, "1234")
45
45
  secret_key = session.generate_key(:DES2_KEY_GEN,
46
- :ENCRYPT=>true, :DECRYPT=>true, :SENSITIVE=>true, :TOKEN=>true, :LABEL=>'my key')
47
- cryptogram = session.encrypt( {:DES3_CBC_PAD=>"\0"*8}, secret_key, "some plaintext")
46
+ ENCRYPT: true, DECRYPT: true, SENSITIVE: true, TOKEN: true, LABEL: 'my key')
47
+ cryptogram = session.encrypt( {DES3_CBC_PAD: "\0"*8}, secret_key, "some plaintext")
48
48
  session.logout
49
49
  end
50
50
 
@@ -64,13 +64,12 @@ Browsable HTML can be found at http://www.cryptsoft.com/pkcs11doc.
64
64
  === Vendor extensions
65
65
  Some vendors extend their libraries beyond the standard, in it's own way.
66
66
  This can be used by vendor specific packages:
67
- * Safenet ProtectServer: {file:pkcs11_protect_server/README_PROTECT_SERVER.rdoc}
68
- * Safenet Luna: {file:pkcs11_luna/README_LUNA.rdoc}
67
+ * Safenet ProtectServer: {http://www.rubydoc.info/gems/pkcs11_protect_server/}
68
+ * Safenet Luna: {http://www.rubydoc.info/gems/pkcs11_luna/}
69
69
 
70
70
  === Threading
71
71
 
72
- The pkcs11 binding fully supports native, background Ruby threads.
73
- This of course only applies to Rubinius and Ruby 1.9 or higher since earlier versions of Ruby do not support native threads.
72
+ The pkcs11 binding fully supports background Ruby threads while calls to PKCS#11 functions.
74
73
 
75
74
  According to the standard, calling the Cryptoki library from multiple threads simultaneously, requires to open it with flag PKCS11::CKF_OS_LOCKING_OK.
76
75
  Application-supplied synchronization primitives (CreateMutex, DestroyMutex, LockMutex, UnlockMutex) are not supported.
@@ -78,7 +77,7 @@ Application-supplied synchronization primitives (CreateMutex, DestroyMutex, Lock
78
77
 
79
78
  == Compiling for Windows
80
79
 
81
- The pkcs11 source gem can be built on Windows (with help of the RubyInstaller's DevKit[http://rubyinstaller.org/add-ons/devkit/] ) .
80
+ The pkcs11 source gem can be built on Windows (with help of the RubyInstaller's DevKit[http://rubyinstaller.org/add-ons/devkit] ) .
82
81
  Use
83
82
 
84
83
  $ gem install pkcs11 --platform=ruby
@@ -96,9 +95,7 @@ If everything works, there should be some files kind of pkcs11-VERSION-ARCH-ming
96
95
 
97
96
  == ToDo
98
97
 
99
- * encoding support for Ruby 1.9+
100
98
  * support for proprietary extensions of other vendors
101
- * full support for PKCS#11 v2.40
102
99
 
103
100
  == Development Status
104
101
 
data/Rakefile CHANGED
@@ -24,17 +24,22 @@ Hoe.plugin :bundler
24
24
  # Build a Manifest file to satisfy hoe.
25
25
  IO.write("Manifest.txt", `git ls-files`)
26
26
 
27
+ # Ensure pkg is rebuilt
28
+ task :remove_pkg do
29
+ rm_rf 'pkg'
30
+ end
31
+ task :gem => [:remove_pkg]
32
+
27
33
  hoe = Hoe.spec 'pkcs11' do
28
34
  developer('Ryosuke Kutsuna', 'ryosuke@deer-n-horse.jp')
29
35
  developer('GOTOU Yuuzou', 'gotoyuzo@notwork.org')
30
36
  developer('Lars Kanis', 'kanis@comcard.de')
31
- extra_dev_deps << ['yard', '>= 0.6']
37
+ extra_dev_deps << ['yard', '~> 0.6']
32
38
  extra_dev_deps << ['rake-compiler', '~> 1.0']
33
- extra_dev_deps << ['rake-compiler-dock', '~> 0.6.0']
39
+ extra_dev_deps << ['rake-compiler-dock', '~> 0.6.2']
34
40
  extra_dev_deps << ['minitest', '~> 5.7']
35
41
  extra_dev_deps << ['hoe-bundler', '~> 1.0']
36
42
 
37
- self.urls = ['http://github.com/larskanis/pkcs11']
38
43
  self.summary = 'PKCS#11 binding for Ruby'
39
44
  self.description = 'This module allows Ruby programs to interface with "RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki)".'
40
45
 
@@ -43,7 +48,7 @@ hoe = Hoe.spec 'pkcs11' do
43
48
  spec_extras[:extensions] = 'ext/extconf.rb'
44
49
  spec_extras[:files] = `git ls-files`.split("\n").reject{|f| f=~/^pkcs11_/ }
45
50
  spec_extras[:files] += GENERATED_FILES
46
- spec_extras[:has_rdoc] = 'yard'
51
+ spec_extras[:required_ruby_version] = '>= 2.2.0'
47
52
  self.rdoc_locations << "http://www.rubydoc.info/gems/pkcs11"
48
53
  end
49
54
 
@@ -100,13 +105,13 @@ task :docs_of_vendor_extensions do
100
105
  end
101
106
 
102
107
  desc "Generate static HTML documentation with YARD"
103
- task :yardoc=>['ext/pk11_struct.doc', :docs_of_vendor_extensions] do
108
+ task yardoc: ['ext/pk11_struct.doc', :docs_of_vendor_extensions] do
104
109
  luna_docs = "pkcs11_luna/lib/**/*.rb pkcs11_luna/ext/*.c pkcs11_luna/ext/*.doc"
105
110
  sh "yardoc --title \"PKCS#11/Ruby Interface\" --no-private lib/**/*.rb ext/*.c ext/*.doc pkcs11_protect_server/lib/**/*.rb pkcs11_protect_server/ext/*.c pkcs11_protect_server/ext/*.doc #{luna_docs} - pkcs11_protect_server/README_PROTECT_SERVER.rdoc pkcs11_luna/README_LUNA.rdoc"
106
111
  end
107
112
 
108
113
  desc "Publish YARD to wherever you want."
109
- task :publish_yard => [:yardoc] do
114
+ task publish_yard: [:yardoc] do
110
115
  rdoc_locations = hoe.rdoc_locations
111
116
  warn "no rdoc_location values" if rdoc_locations.empty?
112
117
  rdoc_locations.each do |dest|
@@ -2,6 +2,4 @@ require "mkmf"
2
2
 
3
3
  basedir = File.dirname(__FILE__)
4
4
  $CPPFLAGS += " -I \"#{basedir}/include\""
5
- have_func("rb_str_set_len")
6
- have_func("rb_thread_call_without_gvl")
7
5
  create_makefile("pkcs11_ext");
@@ -12,7 +12,7 @@ class ConstantParser
12
12
  def self.run(argv)
13
13
  s = self.new
14
14
  options = Struct.new(:verbose, :const, :files).new
15
- OptionParser.new(argv) do |opts|
15
+ OptionParser.new do |opts|
16
16
  opts.banner = "Usage: #{$0} [options] <header-file.h>*"
17
17
 
18
18
  opts.on("-v", "--[no-]verbose", "Run verbosely", &options.method(:verbose=))
@@ -21,7 +21,7 @@ class ConstantParser
21
21
  puts opts
22
22
  exit
23
23
  end
24
- end.parse!
24
+ end.parse!(argv)
25
25
  options.files = argv
26
26
  s.options = options
27
27
  s.start!
@@ -15,7 +15,7 @@ class StructParser
15
15
  def self.run(argv)
16
16
  s = self.new
17
17
  options = Struct.new(:verbose, :def, :impl, :doc, :files).new
18
- OptionParser.new(argv) do |opts|
18
+ OptionParser.new do |opts|
19
19
  opts.banner = "Usage: #{$0} [options] <header-file.h>*"
20
20
 
21
21
  opts.on("-v", "--[no-]verbose", "Run verbosely", &options.method(:verbose=))
@@ -26,7 +26,7 @@ class StructParser
26
26
  puts opts
27
27
  exit
28
28
  end
29
- end.parse!
29
+ end.parse!(argv)
30
30
  options.files = argv
31
31
  s.options = options
32
32
  s.start!
@@ -111,20 +111,26 @@ class StructParser
111
111
  end
112
112
  # find string attributes belonging together
113
113
  struct.attrs.select{|attr| ['CK_BYTE_PTR', 'CK_VOID_PTR', 'CK_UTF8CHAR_PTR', 'CK_CHAR_PTR'].include?(attr.type) }.each do |attr|
114
+ enco = case attr.type
115
+ when 'CK_UTF8CHAR_PTR' then 'utf8'
116
+ when 'CK_CHAR_PTR' then 'usascii'
117
+ when 'CK_BYTE_PTR', 'CK_VOID_PTR' then 'ascii8bit'
118
+ else raise "unexpected type #{attr.type.inspect}"
119
+ end
114
120
  if len_attr=struct.attr_by_sign("CK_ULONG #{attr.name.gsub(/^p([A-Z])/){ "ul"+$1 }}Len")
115
- fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(#{struct.name}, #{attr.name}, #{len_attr.name});"
121
+ fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(#{struct.name}, #{attr.name}, #{len_attr.name}, #{enco});"
116
122
  fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
117
- fd_doc.puts"# @return [String, nil] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
123
+ fd_doc.puts"# @return [#{enco.upcase}-String, nil] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
118
124
  len_attr.mark = true
119
125
  elsif attr.name=='pData' && (len_attr = struct.attr_by_sign("CK_ULONG length") || struct.attr_by_sign("CK_ULONG ulLen"))
120
- fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(#{struct.name}, #{attr.name}, #{len_attr.name});"
126
+ fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_LEN_ACCESSOR(#{struct.name}, #{attr.name}, #{len_attr.name}, #{enco});"
121
127
  fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
122
- fd_doc.puts"# @return [String, nil] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
128
+ fd_doc.puts"# @return [#{enco.upcase}-String, nil] accessor for #{attr.name} and #{len_attr.name}\nattr_accessor :#{attr.name}"
123
129
  len_attr.mark = true
124
130
  else
125
- fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(#{struct.name}, #{attr.name});"
131
+ fd_impl.puts "PKCS11_IMPLEMENT_STRING_PTR_ACCESSOR(#{struct.name}, #{attr.name}, #{enco});"
126
132
  fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
127
- fd_doc.puts"# @return [String, nil] accessor for #{attr.name}\nattr_accessor :#{attr.name}"
133
+ fd_doc.puts"# @return [#{enco.upcase}-String, nil] accessor for #{attr.name}\nattr_accessor :#{attr.name}"
128
134
  end
129
135
  attr.mark = true
130
136
  end
@@ -133,11 +139,16 @@ class StructParser
133
139
  struct.attrs.reject{|a| a.mark }.each do |attr|
134
140
  if attr.qual
135
141
  # Attributes with qualifier
142
+ enco = case attr.type
143
+ when 'CK_BYTE' then 'ascii8bit'
144
+ when 'CK_UTF8CHAR' then 'utf8'
145
+ when 'CK_CHAR' then 'usascii'
146
+ end
136
147
  case attr.type
137
148
  when 'CK_BYTE', 'CK_UTF8CHAR', 'CK_CHAR'
138
- fd_impl.puts "PKCS11_IMPLEMENT_STRING_ACCESSOR(#{struct.name}, #{attr.name});"
149
+ fd_impl.puts "PKCS11_IMPLEMENT_STRING_ACCESSOR(#{struct.name}, #{attr.name}, #{enco});"
139
150
  fd_def.puts "PKCS11_DEFINE_MEMBER(#{struct.name}, #{attr.name});"
140
- fd_doc.puts"# @return [String] accessor for #{attr.name} (max #{attr.qual} bytes)\nattr_accessor :#{attr.name}"
151
+ fd_doc.puts"# @return [#{enco.upcase}-String] accessor for #{attr.name} (max #{attr.qual} bytes)\nattr_accessor :#{attr.name}"
141
152
  else
142
153
  fd_impl.puts "/* unimplemented attr #{attr.type} #{attr.name} #{attr.qual} */"
143
154
  fd_def.puts "/* unimplemented attr #{attr.type} #{attr.name} #{attr.qual} */"
@@ -26,11 +26,9 @@ fd_decl.puts <<-EOT
26
26
  #ifndef #{options.decl.gsub(/[^\w]/, "_").upcase}
27
27
  #define #{options.decl.gsub(/[^\w]/, "_").upcase}
28
28
  #include "pk11.h"
29
- #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
30
29
  EOT
31
30
  fd_impl.puts <<-EOT
32
31
  #include #{File.basename(options.decl).inspect}
33
- #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
34
32
  EOT
35
33
  ARGV.each do |file_h|
36
34
  c_src = IO.read(file_h)
@@ -61,12 +59,8 @@ ARGV.each do |file_h|
61
59
  EOT
62
60
  end
63
61
  end
64
- fd_impl.puts <<-EOT
65
- #endif
66
- EOT
67
62
  fd_decl.puts <<-EOT
68
63
  #endif
69
- #endif
70
64
  EOT
71
65
  end
72
66
  end
data/ext/pk11.c CHANGED
@@ -39,11 +39,6 @@ static VALUE aCK_MECHANISM_members;
39
39
 
40
40
  VALUE pkcs11_return_value_to_class(CK_RV, VALUE);
41
41
 
42
- #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
43
- extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
44
- rb_unblock_function_t *ubf, void *data2);
45
- #endif
46
-
47
42
  static void
48
43
  pkcs11_raise(VALUE self, CK_RV rv)
49
44
  {
@@ -67,21 +62,14 @@ typedef struct {
67
62
  if (!sval) rb_raise(ePKCS11Error, #name " is not supported."); \
68
63
  }
69
64
 
70
- #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
71
- #define CallFunction(name, func, rv, ...) \
72
- { \
73
- struct tbr_##name##_params params = { \
74
- func, {__VA_ARGS__}, CKR_FUNCTION_FAILED \
75
- }; \
76
- rb_thread_call_without_gvl(tbf_##name, &params, RUBY_UBF_PROCESS, NULL); \
77
- rv = params.retval; \
78
- }
79
-
80
- #else
81
- #define CallFunction(name, func, rv, ...) \
82
- rv = func(__VA_ARGS__)
83
-
84
- #endif
65
+ #define CallFunction(name, func, rv, ...) \
66
+ { \
67
+ struct tbr_##name##_params params = { \
68
+ func, {__VA_ARGS__}, CKR_FUNCTION_FAILED \
69
+ }; \
70
+ rb_thread_call_without_gvl(tbf_##name, &params, RUBY_UBF_PROCESS, NULL); \
71
+ rv = params.retval; \
72
+ }
85
73
 
86
74
  static void
87
75
  pkcs11_ctx_unload_library(pkcs11_ctx *ctx)
@@ -1476,6 +1464,13 @@ ck_attr_value(VALUE self)
1476
1464
  if (attr->ulValueLen == sizeof(CK_ULONG))
1477
1465
  return ULONG2NUM(*(CK_ULONG_PTR)(attr->pValue));
1478
1466
  break;
1467
+ case CKA_LABEL:
1468
+ case CKA_APPLICATION:
1469
+ case CKA_URL:
1470
+ case CKA_CHAR_SETS:
1471
+ case CKA_ENCODING_METHODS:
1472
+ case CKA_MIME_TYPES:
1473
+ return rb_enc_str_new(attr->pValue, attr->ulValueLen, rb_utf8_encoding());
1479
1474
  }
1480
1475
  return rb_str_new(attr->pValue, attr->ulValueLen);
1481
1476
  }
@@ -1506,11 +1501,11 @@ cCK_MECHANISM_initialize(int argc, VALUE *argv, VALUE self)
1506
1501
  }
1507
1502
 
1508
1503
  /* rb_define_method(cCK_MECHANISM, "mechanism", cCK_MECHANISM_get_mechanism, 0); */
1509
- /* rb_define_method(cCK_MECHANISM, "mechanism=", cCK_MECHANISM_set_mechanism, 0); */
1504
+ /* rb_define_method(cCK_MECHANISM, "mechanism=", cCK_MECHANISM_set_mechanism, 1); */
1510
1505
  PKCS11_IMPLEMENT_ULONG_ACCESSOR(CK_MECHANISM, mechanism);
1511
1506
 
1512
1507
  /* rb_define_method(cCK_MECHANISM, "pParameter", cCK_MECHANISM_get_pParameter, 0); */
1513
- /* rb_define_method(cCK_MECHANISM, "pParameter=", cCK_MECHANISM_set_pParameter, 0); */
1508
+ /* rb_define_method(cCK_MECHANISM, "pParameter=", cCK_MECHANISM_set_pParameter, 1); */
1514
1509
  /* @see PKCS11::CK_MECHANISM#initialize */
1515
1510
  static VALUE
1516
1511
  cCK_MECHANISM_get_pParameter(VALUE self)
@@ -1544,8 +1539,8 @@ cCK_MECHANISM_set_pParameter(VALUE self, VALUE value)
1544
1539
  m->ulParameterLen = RSTRING_LEN(value);
1545
1540
  break;
1546
1541
  case T_DATA:
1547
- m->pParameter = DATA_PTR(value);
1548
1542
  m->ulParameterLen = NUM2LONG(rb_const_get(rb_funcall(value, rb_intern("class"), 0), rb_intern("SIZEOF_STRUCT")));
1543
+ m->pParameter = DATA_PTR(value);
1549
1544
  break;
1550
1545
  default:
1551
1546
  rb_raise(rb_eArgError, "invalid argument");