pkcs11 0.2.5-x64-mingw32 → 0.2.6-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d28237d5ef32787ef6d68009d44d50d016d05e4
4
- data.tar.gz: 65376ebc6990296dfdf6d9422a6c0151a55f22bb
3
+ metadata.gz: 69a6b9f12bab14182f4da72f64b54ab1684cbb3c
4
+ data.tar.gz: 6d158aed86b0e3046497488b15b28170c2b5869c
5
5
  SHA512:
6
- metadata.gz: 2a1ad87a56ef2843b4563a7ce1a461409f4d605a08b52a8047f2a959f82946b63c3ba53bcafe8b7f624fda7dec3ce16640012fb2a6bc009db18ee2d8b75dbfcb
7
- data.tar.gz: a97fd50c388964fc618c4fa126beb174507981cc0990c21c6b5c47636702f68d63d7b8c39e2d26e36b438bf7f3cd5f13ca313406246b510c54b981cba184cea1
6
+ metadata.gz: 274017b98cfaee5f326159b60f53ba4acf516f8a461514f0c44a554ef45b9f07b9873f34b750dac619a3e69b462a4ca67b25e053986773f47a5486079000c359
7
+ data.tar.gz: 2af93ab679ee28b998f1fdbacc7f8288d356089ae39efebafdc0d4f0c5c6aeebe8b6a01969929048108b653ad79bae0dcc39515eded66cd257474437f57890e3
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - "1.9.3"
5
+ - "2.2.0"
6
+ - rbx
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: rbx
10
+ script: bundle exec rake compile test gem
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ # DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
4
+
5
+ source "https://rubygems.org/"
6
+
7
+
8
+ gem "yard", ">=0.6", :group => [:development, :test]
9
+ gem "rake-compiler", "~>1.0", :group => [:development, :test]
10
+ gem "rake-compiler-dock", "~>0.6.0", :group => [:development, :test]
11
+ gem "minitest", "~>5.7", :group => [:development, :test]
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]
15
+
16
+ # vim: syntax=ruby
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.2.6 / 2017-06-07
2
+
3
+ * Update pkcs11 header files to PKCS11-v2.4.
4
+ * Support binary Windows gems for Ruby-2.0 to 2.4.
5
+
1
6
  === 0.2.5 / 2015-01-26
2
7
 
3
8
  * Fix compatibility with Ruby-2.2
data/README.rdoc CHANGED
@@ -1,4 +1,5 @@
1
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]
2
3
 
3
4
  = PKCS #11/Ruby Interface
4
5
 
@@ -8,35 +9,29 @@
8
9
  This module allows Ruby programs to interface with "RSA Security Inc.
9
10
  PKCS #11 Cryptographic Token Interface (Cryptoki)".
10
11
  PKCS #11 is the de-facto standard to access cryptographic devices.
11
- You must have a PKCS #11 v2.20 implementation library installed in
12
- order to use this module. Tested implementations of PKCS#11 librarys
13
- include:
12
+ You must have a PKCS #11 v2.x implementation library installed in order to use this module. Tested implementations of PKCS#11 librarys include:
14
13
  * OpenSC[http://www.opensc-project.org] supported Smart Cards
15
- * Safenet[http://www.safenet-inc.com] - Protect Server HSMs
14
+ * Safenet[http://www.safenet-inc.com] - Protect Server and Luna HSMs
16
15
  * Mozilla_Soft_Token[https://developer.mozilla.org/en/PKCS11] which comes with every firefox installation
17
16
 
18
- This module works on the Unix like operating systems and win32.
17
+ This module works on Unix like operating systems and on Windows.
19
18
 
20
19
  == Installation
21
20
 
22
- gem install pkcs11
21
+ $ gem install pkcs11
23
22
 
24
- This installs the PKCS#11 extension either by compiling (Unix) or by using the precompiled gem for Win32.
23
+ This installs the PKCS#11 extension either by compiling (Unix) or by using the precompiled gem for Windows.
25
24
 
26
25
  == Usage
27
26
  Cryptoki has a reputation to be complicated to implement and use.
28
27
  While this seems to be true for C, it shouldn't for Ruby.
29
28
 
30
- * {PKCS11.open} opens a PKCS#11 Unix *.so file or Windows-DLL with a suitable PKCS #11 implementation
31
- and returns a {PKCS11::Library}.
29
+ * {PKCS11.open} opens a PKCS#11 Unix *.so file or Windows-DLL with a suitable PKCS #11 implementation and returns a {PKCS11::Library}.
32
30
  * {PKCS11::Library#slots} returns a list of {PKCS11::Slot} for all slots accessable by the library.
33
- * {PKCS11::Slot#open} opens a {PKCS11::Session} which is used for object handling
34
- and cryptographic operations.
31
+ * {PKCS11::Slot#open} opens a {PKCS11::Session} which is used for object handling and cryptographic operations.
35
32
  * {PKCS11::Object} represents a key, data or certificate object.
36
- * all constants defined in PKCS#11 v2.20 are available in the module {PKCS11}
37
- and contain the associated Integer value (CKA_KEY_TYPE, CKK_AES, CKM_SHA_1 etc.)
38
- * also all PKCS#11 v2.20 structs are available in the module {PKCS11} as proper ruby classes
39
- ({PKCS11::CK_VERSION}, {PKCS11::CK_OTP_PARAMS} etc.)
33
+ * all constants defined in PKCS#11 v2.40 are available in the module {PKCS11} and contain the associated Integer value (CKA_KEY_TYPE, CKK_AES, CKM_SHA_1 etc.)
34
+ * also all PKCS#11 v2.40 structs are available in the module {PKCS11} as proper ruby classes ({PKCS11::CK_VERSION}, {PKCS11::CK_OTP_PARAMS} etc.)
40
35
 
41
36
  === Example
42
37
  require "rubygems"
@@ -54,71 +49,56 @@ While this seems to be true for C, it shouldn't for Ruby.
54
49
  end
55
50
 
56
51
  This opens a {PKCS11::Library PKCS#11 library} and prints it's {PKCS11::CK_INFO information block}.
57
- Then a {PKCS11::Session} to the first {PKCS11::Library#active_slots active slot} of the device is opened and
58
- a {PKCS11::Session#login login} is done on the user account. Now, a 112 bit DES3 {PKCS11::Object key object} is generated and
59
- some plaintext is {PKCS11::Session#encrypt encrypted} with it. A 8-byte zero IV is used. In many cases method parameters
60
- can be Integer (like PKCS11::CKA_LABEL) or, as in the sample, Symbol (:LABEL) which is internally
61
- converted.
52
+ Then a {PKCS11::Session} to the first {PKCS11::Library#active_slots active slot} of the device is opened and a {PKCS11::Session#login login} is done on the user account.
53
+ Now, a 112 bit DES3 {PKCS11::Object key object} is generated and some plaintext is {PKCS11::Session#encrypt encrypted} with it.
54
+ A 8-byte zero IV is used.
55
+ In many cases method parameters can be Integer (like PKCS11::CKA_LABEL) or, as in the sample, Symbol (:LABEL) which is internally converted.
62
56
 
63
- Many more usage examples can be found in the unit tests of the <tt>test</tt>
64
- directory of the project or gem.
57
+ Many more usage examples can be found in the unit tests of the <tt>test</tt> directory of the project or gem.
65
58
 
66
- Detail information for the API specification is provided by RSA Security Inc.
67
- Please refer the URL: http://www.rsa.com/rsalabs/node.asp?id=2133. Browsable HTML
68
- can be found at http://www.cryptsoft.com/pkcs11doc.
59
+ Detail information for the API specification is provided by the OASIS PKCS 11 Technical Committee.
60
+ Please refer the URL: https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=pkcs11
61
+
62
+ Browsable HTML can be found at http://www.cryptsoft.com/pkcs11doc.
69
63
 
70
64
  === Vendor extensions
71
65
  Some vendors extend their libraries beyond the standard, in it's own way.
72
66
  This can be used by vendor specific packages:
73
67
  * Safenet ProtectServer: {file:pkcs11_protect_server/README_PROTECT_SERVER.rdoc}
68
+ * Safenet Luna: {file:pkcs11_luna/README_LUNA.rdoc}
74
69
 
75
70
  === Threading
76
71
 
77
72
  The pkcs11 binding fully supports native, background Ruby threads.
78
- This of course only applies to Rubinius and Ruby 1.9.x or higher since
79
- earlier versions of Ruby do not support native threads.
80
-
81
- According to the standard, calling the Cryptoki library from multiple threads simultaneously,
82
- requires to open it with flag PKCS11::CKF_OS_LOCKING_OK.
83
- Application-supplied synchronization primitives
84
- (CreateMutex, DestroyMutex, LockMutex, UnlockMutex) are not supported.
85
-
86
-
87
- == Cross compiling for Windows
88
-
89
- Using rake-compiler a cross compiled pkcs11-gem can be build on a linux host for
90
- the win32 platform. There are no runtime dependencies to any but the standard Windows DLLs.
91
-
92
- Install mingw32. On a debian based system this should work:
93
-
94
- apt-get install mingw32
73
+ This of course only applies to Rubinius and Ruby 1.9 or higher since earlier versions of Ruby do not support native threads.
95
74
 
96
- On MacOS X, if you have MacPorts installed:
75
+ According to the standard, calling the Cryptoki library from multiple threads simultaneously, requires to open it with flag PKCS11::CKF_OS_LOCKING_OK.
76
+ Application-supplied synchronization primitives (CreateMutex, DestroyMutex, LockMutex, UnlockMutex) are not supported.
97
77
 
98
- port install i386-mingw32-gcc
99
78
 
100
- Install the rake-compiler:
79
+ == Compiling for Windows
101
80
 
102
- gem install rake-compiler
81
+ The pkcs11 source gem can be built on Windows (with help of the RubyInstaller's DevKit[http://rubyinstaller.org/add-ons/devkit/] ) .
82
+ Use
103
83
 
104
- Download and cross compile ruby for win32:
84
+ $ gem install pkcs11 --platform=ruby
105
85
 
106
- rake-compiler cross-ruby VERSION=1.8.7-p352
107
- rake-compiler cross-ruby VERSION=1.9.2-p290
86
+ for installation.
87
+ In addition precompiled binary Windows gems are provided for convenience.
88
+ They are installed by default on Windows.
108
89
 
109
- Download and cross compile pkcs11 for win32 (MRI 1.8+1.9 fat gem):
90
+ The binary Windows gems can be compiled per rake-compiler-dock[https://github.com/rake-compiler/rake-compiler-dock] :
110
91
 
111
- rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2
92
+ $ rake gem:windows
112
93
 
113
- If everything works, there should be pkcs11-VERSION-x86-mingw32.gem in the pkg
114
- directory.
94
+ If everything works, there should be some files kind of pkcs11-VERSION-ARCH-mingw32.gem in the pkg directory for installation.
115
95
 
116
96
 
117
97
  == ToDo
118
98
 
119
- * encoding support for Ruby 1.9
120
- * support for proprietary extensions of different vendors (done for Safenet-ProtectServer)
121
- * PKCS#11 v2.3
99
+ * encoding support for Ruby 1.9+
100
+ * support for proprietary extensions of other vendors
101
+ * full support for PKCS#11 v2.40
122
102
 
123
103
  == Development Status
124
104
 
@@ -200,6 +180,7 @@ Otherwise it is considered as a bug in the binding.
200
180
  * Ryosuke Kutsuna <ryosuke@deer-n-horse.jp>
201
181
  * GOTOU Yuuzou <gotoyuzo@notwork.org>
202
182
  * Lars Kanis <kanis@comcard.de>
183
+ * Jonathan Patchell <jonathan.patchell@safenet-inc.com>
203
184
 
204
185
  == Copying
205
186
  See MIT-LICENSE included in the package.
data/Rakefile CHANGED
@@ -19,12 +19,20 @@ CLEAN.include GENERATED_FILES
19
19
  CLEAN.include 'lib/pkcs11_ext.so'
20
20
  CLEAN.include 'tmp'
21
21
 
22
+ Hoe.plugin :bundler
23
+
24
+ # Build a Manifest file to satisfy hoe.
25
+ IO.write("Manifest.txt", `git ls-files`)
26
+
22
27
  hoe = Hoe.spec 'pkcs11' do
23
28
  developer('Ryosuke Kutsuna', 'ryosuke@deer-n-horse.jp')
24
29
  developer('GOTOU Yuuzou', 'gotoyuzo@notwork.org')
25
30
  developer('Lars Kanis', 'kanis@comcard.de')
26
31
  extra_dev_deps << ['yard', '>= 0.6']
27
- extra_dev_deps << ['rake-compiler', '>= 0.7']
32
+ extra_dev_deps << ['rake-compiler', '~> 1.0']
33
+ extra_dev_deps << ['rake-compiler-dock', '~> 0.6.0']
34
+ extra_dev_deps << ['minitest', '~> 5.7']
35
+ extra_dev_deps << ['hoe-bundler', '~> 1.0']
28
36
 
29
37
  self.urls = ['http://github.com/larskanis/pkcs11']
30
38
  self.summary = 'PKCS#11 binding for Ruby'
@@ -33,18 +41,16 @@ hoe = Hoe.spec 'pkcs11' do
33
41
  self.readme_file = 'README.rdoc'
34
42
  self.extra_rdoc_files << self.readme_file << 'ext/pk11.c'
35
43
  spec_extras[:extensions] = 'ext/extconf.rb'
36
- spec_extras[:files] = File.read_utf("Manifest.txt").split(/\r?\n\r?/).reject{|f| f=~/^pkcs11_/ }
44
+ spec_extras[:files] = `git ls-files`.split("\n").reject{|f| f=~/^pkcs11_/ }
37
45
  spec_extras[:files] += GENERATED_FILES
38
46
  spec_extras[:has_rdoc] = 'yard'
39
- self.rdoc_locations << "larskanis@rack.rubyforge.org:/var/www/gforge-projects/pkcs11/pkcs11/"
47
+ self.rdoc_locations << "http://www.rubydoc.info/gems/pkcs11"
40
48
  end
41
49
 
42
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0:2.1.1:2.2.0'
43
-
44
50
  Rake::ExtensionTask.new('pkcs11_ext', hoe.spec) do |ext|
45
51
  ext.ext_dir = 'ext'
46
52
  ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
47
- ext.cross_platform = ['i386-mingw32', 'x64-mingw32'] # forces the Windows platform instead of the default one
53
+ ext.cross_platform = ['x86-mingw32', 'x64-mingw32', 'x86-linux', 'x86_64-linux']
48
54
  end
49
55
 
50
56
  file 'ext/extconf.rb' => ['ext/pk11_struct_def.inc', 'ext/pk11_thread_funcs.c']
@@ -77,8 +83,16 @@ ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
77
83
  end
78
84
  end
79
85
 
86
+ desc "Build windows and Linux binary gems per rake-compiler-dock."
87
+ task "gem:native" do
88
+ require "rake_compiler_dock"
89
+ RakeCompilerDock.sh <<-EOT
90
+ rake cross native gem MAKE='nice make -j`nproc`'
91
+ EOT
92
+ end
93
+
80
94
  task :docs_of_vendor_extensions do
81
- Dir['pkcs11_*'].each do |dir|
95
+ Dir['pkcs11_luna', 'pkcs11_protect_server'].each do |dir|
82
96
  chdir(dir) do
83
97
  sh "rake doc_files"
84
98
  end
@@ -87,7 +101,8 @@ end
87
101
 
88
102
  desc "Generate static HTML documentation with YARD"
89
103
  task :yardoc=>['ext/pk11_struct.doc', :docs_of_vendor_extensions] do
90
- 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 - pkcs11_protect_server/README_PROTECT_SERVER.rdoc"
104
+ luna_docs = "pkcs11_luna/lib/**/*.rb pkcs11_luna/ext/*.c pkcs11_luna/ext/*.doc"
105
+ 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"
91
106
  end
92
107
 
93
108
  desc "Publish YARD to wherever you want."
data/appveyor.yml ADDED
@@ -0,0 +1,38 @@
1
+ install:
2
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
3
+ - SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
4
+ - SET RAKEOPT=-rdevkit
5
+ - ruby --version
6
+ - gem --version
7
+ - bundle install
8
+
9
+ # When running ruby-x86, we make use of the softokn3.dll that is part of the
10
+ # pre-installed firefox. The test helper will find it automatically.
11
+ # When running ruby-x64, we equally need a 64 bit softokn3.dll to test against.
12
+ # However it is not part of any installed software on appveyor, nor is it
13
+ # officially released as a windows binary, so we download and install a 64 bit
14
+ # firefox version and use it's softokn3.dll.
15
+ - ps: |
16
+ if ($env:isx64 -eq "1")
17
+ {
18
+ $(new-object net.webclient).DownloadFile('http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/40.0b4/win64/en-US/Firefox%20Setup%2040.0b4.exe', 'C:\firefox-setup.exe')
19
+ cmd /c C:\firefox-setup.exe -ms
20
+ $env:SOFTOKN_PATH = 'C:\Program Files\Mozilla Firefox\softokn3.dll'
21
+ $env:PATH = 'C:\Program Files\Mozilla Firefox;' + $env:PATH
22
+ }
23
+
24
+ build: off
25
+
26
+ test_script:
27
+ - bundle exec rake compile test gem
28
+
29
+ environment:
30
+ matrix:
31
+ - ruby_version: "193"
32
+ #- ruby_version: "200"
33
+ #- ruby_version: "200-x64"
34
+ #- ruby_version: "21"
35
+ #- ruby_version: "21-x64"
36
+ - ruby_version: "22"
37
+ - ruby_version: "22-x64"
38
+ isx64: "1"
data/ext/include/pkcs11.h CHANGED
@@ -1,299 +1,287 @@
1
- /* pkcs11.h include file for PKCS #11. */
2
- /* $Revision: 1.4 $ */
3
-
4
- /* License to copy and use this software is granted provided that it is
5
- * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
6
- * (Cryptoki)" in all material mentioning or referencing this software.
7
-
8
- * License is also granted to make and use derivative works provided that
9
- * such works are identified as "derived from the RSA Security Inc. PKCS #11
10
- * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
11
- * referencing the derived work.
12
-
13
- * RSA Security Inc. makes no representations concerning either the
14
- * merchantability of this software or the suitability of this software for
15
- * any particular purpose. It is provided "as is" without express or implied
16
- * warranty of any kind.
17
- */
18
-
19
- #ifndef _PKCS11_H_
20
- #define _PKCS11_H_ 1
21
-
22
- #ifdef __cplusplus
23
- extern "C" {
24
- #endif
25
-
26
- /* Before including this file (pkcs11.h) (or pkcs11t.h by
27
- * itself), 6 platform-specific macros must be defined. These
28
- * macros are described below, and typical definitions for them
29
- * are also given. Be advised that these definitions can depend
30
- * on both the platform and the compiler used (and possibly also
31
- * on whether a Cryptoki library is linked statically or
32
- * dynamically).
33
- *
34
- * In addition to defining these 6 macros, the packing convention
35
- * for Cryptoki structures should be set. The Cryptoki
36
- * convention on packing is that structures should be 1-byte
37
- * aligned.
38
- *
39
- * If you're using Microsoft Developer Studio 5.0 to produce
40
- * Win32 stuff, this might be done by using the following
41
- * preprocessor directive before including pkcs11.h or pkcs11t.h:
42
- *
43
- * #pragma pack(push, cryptoki, 1)
44
- *
45
- * and using the following preprocessor directive after including
46
- * pkcs11.h or pkcs11t.h:
47
- *
48
- * #pragma pack(pop, cryptoki)
49
- *
50
- * If you're using an earlier version of Microsoft Developer
51
- * Studio to produce Win16 stuff, this might be done by using
52
- * the following preprocessor directive before including
53
- * pkcs11.h or pkcs11t.h:
54
- *
55
- * #pragma pack(1)
56
- *
57
- * In a UNIX environment, you're on your own for this. You might
58
- * not need to do (or be able to do!) anything.
59
- *
60
- *
61
- * Now for the macros:
62
- *
63
- *
64
- * 1. CK_PTR: The indirection string for making a pointer to an
65
- * object. It can be used like this:
66
- *
67
- * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
68
- *
69
- * If you're using Microsoft Developer Studio 5.0 to produce
70
- * Win32 stuff, it might be defined by:
71
- *
72
- * #define CK_PTR *
73
- *
74
- * If you're using an earlier version of Microsoft Developer
75
- * Studio to produce Win16 stuff, it might be defined by:
76
- *
77
- * #define CK_PTR far *
78
- *
79
- * In a typical UNIX environment, it might be defined by:
80
- *
81
- * #define CK_PTR *
82
- *
83
- *
84
- * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes
85
- * an exportable Cryptoki library function definition out of a
86
- * return type and a function name. It should be used in the
87
- * following fashion to define the exposed Cryptoki functions in
88
- * a Cryptoki library:
89
- *
90
- * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
91
- * CK_VOID_PTR pReserved
92
- * )
93
- * {
94
- * ...
95
- * }
96
- *
97
- * If you're using Microsoft Developer Studio 5.0 to define a
98
- * function in a Win32 Cryptoki .dll, it might be defined by:
99
- *
100
- * #define CK_DEFINE_FUNCTION(returnType, name) \
101
- * returnType __declspec(dllexport) name
102
- *
103
- * If you're using an earlier version of Microsoft Developer
104
- * Studio to define a function in a Win16 Cryptoki .dll, it
105
- * might be defined by:
106
- *
107
- * #define CK_DEFINE_FUNCTION(returnType, name) \
108
- * returnType __export _far _pascal name
109
- *
110
- * In a UNIX environment, it might be defined by:
111
- *
112
- * #define CK_DEFINE_FUNCTION(returnType, name) \
113
- * returnType name
114
- *
115
- *
116
- * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
117
- * an importable Cryptoki library function declaration out of a
118
- * return type and a function name. It should be used in the
119
- * following fashion:
120
- *
121
- * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
122
- * CK_VOID_PTR pReserved
123
- * );
124
- *
125
- * If you're using Microsoft Developer Studio 5.0 to declare a
126
- * function in a Win32 Cryptoki .dll, it might be defined by:
127
- *
128
- * #define CK_DECLARE_FUNCTION(returnType, name) \
129
- * returnType __declspec(dllimport) name
130
- *
131
- * If you're using an earlier version of Microsoft Developer
132
- * Studio to declare a function in a Win16 Cryptoki .dll, it
133
- * might be defined by:
134
- *
135
- * #define CK_DECLARE_FUNCTION(returnType, name) \
136
- * returnType __export _far _pascal name
137
- *
138
- * In a UNIX environment, it might be defined by:
139
- *
140
- * #define CK_DECLARE_FUNCTION(returnType, name) \
141
- * returnType name
142
- *
143
- *
144
- * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
145
- * which makes a Cryptoki API function pointer declaration or
146
- * function pointer type declaration out of a return type and a
147
- * function name. It should be used in the following fashion:
148
- *
149
- * // Define funcPtr to be a pointer to a Cryptoki API function
150
- * // taking arguments args and returning CK_RV.
151
- * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
152
- *
153
- * or
154
- *
155
- * // Define funcPtrType to be the type of a pointer to a
156
- * // Cryptoki API function taking arguments args and returning
157
- * // CK_RV, and then define funcPtr to be a variable of type
158
- * // funcPtrType.
159
- * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
160
- * funcPtrType funcPtr;
161
- *
162
- * If you're using Microsoft Developer Studio 5.0 to access
163
- * functions in a Win32 Cryptoki .dll, in might be defined by:
164
- *
165
- * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
166
- * returnType __declspec(dllimport) (* name)
167
- *
168
- * If you're using an earlier version of Microsoft Developer
169
- * Studio to access functions in a Win16 Cryptoki .dll, it might
170
- * be defined by:
171
- *
172
- * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
173
- * returnType __export _far _pascal (* name)
174
- *
175
- * In a UNIX environment, it might be defined by:
176
- *
177
- * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
178
- * returnType (* name)
179
- *
180
- *
181
- * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
182
- * a function pointer type for an application callback out of
183
- * a return type for the callback and a name for the callback.
184
- * It should be used in the following fashion:
185
- *
186
- * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
187
- *
188
- * to declare a function pointer, myCallback, to a callback
189
- * which takes arguments args and returns a CK_RV. It can also
190
- * be used like this:
191
- *
192
- * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
193
- * myCallbackType myCallback;
194
- *
195
- * If you're using Microsoft Developer Studio 5.0 to do Win32
196
- * Cryptoki development, it might be defined by:
197
- *
198
- * #define CK_CALLBACK_FUNCTION(returnType, name) \
199
- * returnType (* name)
200
- *
201
- * If you're using an earlier version of Microsoft Developer
202
- * Studio to do Win16 development, it might be defined by:
203
- *
204
- * #define CK_CALLBACK_FUNCTION(returnType, name) \
205
- * returnType _far _pascal (* name)
206
- *
207
- * In a UNIX environment, it might be defined by:
208
- *
209
- * #define CK_CALLBACK_FUNCTION(returnType, name) \
210
- * returnType (* name)
211
- *
212
- *
213
- * 6. NULL_PTR: This macro is the value of a NULL pointer.
214
- *
215
- * In any ANSI/ISO C environment (and in many others as well),
216
- * this should best be defined by
217
- *
218
- * #ifndef NULL_PTR
219
- * #define NULL_PTR 0
220
- * #endif
221
- */
222
-
223
-
224
- /* All the various Cryptoki types and #define'd values are in the
225
- * file pkcs11t.h. */
226
- #include "pkcs11t.h"
227
-
228
- #define __PASTE(x,y) x##y
229
-
230
-
231
- /* ==============================================================
232
- * Define the "extern" form of all the entry points.
233
- * ==============================================================
234
- */
235
-
236
- #define CK_NEED_ARG_LIST 1
237
- #define CK_PKCS11_FUNCTION_INFO(name) \
238
- extern CK_DECLARE_FUNCTION(CK_RV, name)
239
-
240
- /* pkcs11f.h has all the information about the Cryptoki
241
- * function prototypes. */
242
- #include "pkcs11f.h"
243
-
244
- #undef CK_NEED_ARG_LIST
245
- #undef CK_PKCS11_FUNCTION_INFO
246
-
247
-
248
- /* ==============================================================
249
- * Define the typedef form of all the entry points. That is, for
250
- * each Cryptoki function C_XXX, define a type CK_C_XXX which is
251
- * a pointer to that kind of function.
252
- * ==============================================================
253
- */
254
-
255
- #define CK_NEED_ARG_LIST 1
256
- #define CK_PKCS11_FUNCTION_INFO(name) \
257
- typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
258
-
259
- /* pkcs11f.h has all the information about the Cryptoki
260
- * function prototypes. */
261
- #include "pkcs11f.h"
262
-
263
- #undef CK_NEED_ARG_LIST
264
- #undef CK_PKCS11_FUNCTION_INFO
265
-
266
-
267
- /* ==============================================================
268
- * Define structed vector of entry points. A CK_FUNCTION_LIST
269
- * contains a CK_VERSION indicating a library's Cryptoki version
270
- * and then a whole slew of function pointers to the routines in
271
- * the library. This type was declared, but not defined, in
272
- * pkcs11t.h.
273
- * ==============================================================
274
- */
275
-
276
- #define CK_PKCS11_FUNCTION_INFO(name) \
277
- __PASTE(CK_,name) name;
278
-
279
- struct CK_FUNCTION_LIST {
280
-
281
- CK_VERSION version; /* Cryptoki version */
282
-
283
- /* Pile all the function pointers into the CK_FUNCTION_LIST. */
284
- /* pkcs11f.h has all the information about the Cryptoki
285
- * function prototypes. */
286
- #include "pkcs11f.h"
287
-
288
- };
289
-
290
- #undef CK_PKCS11_FUNCTION_INFO
291
-
292
-
293
- #undef __PASTE
294
-
295
- #ifdef __cplusplus
296
- }
297
- #endif
298
-
299
- #endif
1
+ /*
2
+ * Copyright (C) OASIS Open 2014. All rights reserved.
3
+ * OASIS trademark, IPR and other policies apply.
4
+ * http://www.oasis-open.org/policies-guidelines/ipr
5
+ */
6
+
7
+ #ifndef _PKCS11_H_
8
+ #define _PKCS11_H_ 1
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ /* Before including this file (pkcs11.h) (or pkcs11t.h by
15
+ * itself), 6 platform-specific macros must be defined. These
16
+ * macros are described below, and typical definitions for them
17
+ * are also given. Be advised that these definitions can depend
18
+ * on both the platform and the compiler used (and possibly also
19
+ * on whether a Cryptoki library is linked statically or
20
+ * dynamically).
21
+ *
22
+ * In addition to defining these 6 macros, the packing convention
23
+ * for Cryptoki structures should be set. The Cryptoki
24
+ * convention on packing is that structures should be 1-byte
25
+ * aligned.
26
+ *
27
+ * If you're using Microsoft Developer Studio 5.0 to produce
28
+ * Win32 stuff, this might be done by using the following
29
+ * preprocessor directive before including pkcs11.h or pkcs11t.h:
30
+ *
31
+ * #pragma pack(push, cryptoki, 1)
32
+ *
33
+ * and using the following preprocessor directive after including
34
+ * pkcs11.h or pkcs11t.h:
35
+ *
36
+ * #pragma pack(pop, cryptoki)
37
+ *
38
+ * If you're using an earlier version of Microsoft Developer
39
+ * Studio to produce Win16 stuff, this might be done by using
40
+ * the following preprocessor directive before including
41
+ * pkcs11.h or pkcs11t.h:
42
+ *
43
+ * #pragma pack(1)
44
+ *
45
+ * In a UNIX environment, you're on your own for this. You might
46
+ * not need to do (or be able to do!) anything.
47
+ *
48
+ *
49
+ * Now for the macros:
50
+ *
51
+ *
52
+ * 1. CK_PTR: The indirection string for making a pointer to an
53
+ * object. It can be used like this:
54
+ *
55
+ * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
56
+ *
57
+ * If you're using Microsoft Developer Studio 5.0 to produce
58
+ * Win32 stuff, it might be defined by:
59
+ *
60
+ * #define CK_PTR *
61
+ *
62
+ * If you're using an earlier version of Microsoft Developer
63
+ * Studio to produce Win16 stuff, it might be defined by:
64
+ *
65
+ * #define CK_PTR far *
66
+ *
67
+ * In a typical UNIX environment, it might be defined by:
68
+ *
69
+ * #define CK_PTR *
70
+ *
71
+ *
72
+ * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes
73
+ * an exportable Cryptoki library function definition out of a
74
+ * return type and a function name. It should be used in the
75
+ * following fashion to define the exposed Cryptoki functions in
76
+ * a Cryptoki library:
77
+ *
78
+ * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
79
+ * CK_VOID_PTR pReserved
80
+ * )
81
+ * {
82
+ * ...
83
+ * }
84
+ *
85
+ * If you're using Microsoft Developer Studio 5.0 to define a
86
+ * function in a Win32 Cryptoki .dll, it might be defined by:
87
+ *
88
+ * #define CK_DEFINE_FUNCTION(returnType, name) \
89
+ * returnType __declspec(dllexport) name
90
+ *
91
+ * If you're using an earlier version of Microsoft Developer
92
+ * Studio to define a function in a Win16 Cryptoki .dll, it
93
+ * might be defined by:
94
+ *
95
+ * #define CK_DEFINE_FUNCTION(returnType, name) \
96
+ * returnType __export _far _pascal name
97
+ *
98
+ * In a UNIX environment, it might be defined by:
99
+ *
100
+ * #define CK_DEFINE_FUNCTION(returnType, name) \
101
+ * returnType name
102
+ *
103
+ *
104
+ * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
105
+ * an importable Cryptoki library function declaration out of a
106
+ * return type and a function name. It should be used in the
107
+ * following fashion:
108
+ *
109
+ * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
110
+ * CK_VOID_PTR pReserved
111
+ * );
112
+ *
113
+ * If you're using Microsoft Developer Studio 5.0 to declare a
114
+ * function in a Win32 Cryptoki .dll, it might be defined by:
115
+ *
116
+ * #define CK_DECLARE_FUNCTION(returnType, name) \
117
+ * returnType __declspec(dllimport) name
118
+ *
119
+ * If you're using an earlier version of Microsoft Developer
120
+ * Studio to declare a function in a Win16 Cryptoki .dll, it
121
+ * might be defined by:
122
+ *
123
+ * #define CK_DECLARE_FUNCTION(returnType, name) \
124
+ * returnType __export _far _pascal name
125
+ *
126
+ * In a UNIX environment, it might be defined by:
127
+ *
128
+ * #define CK_DECLARE_FUNCTION(returnType, name) \
129
+ * returnType name
130
+ *
131
+ *
132
+ * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
133
+ * which makes a Cryptoki API function pointer declaration or
134
+ * function pointer type declaration out of a return type and a
135
+ * function name. It should be used in the following fashion:
136
+ *
137
+ * // Define funcPtr to be a pointer to a Cryptoki API function
138
+ * // taking arguments args and returning CK_RV.
139
+ * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
140
+ *
141
+ * or
142
+ *
143
+ * // Define funcPtrType to be the type of a pointer to a
144
+ * // Cryptoki API function taking arguments args and returning
145
+ * // CK_RV, and then define funcPtr to be a variable of type
146
+ * // funcPtrType.
147
+ * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
148
+ * funcPtrType funcPtr;
149
+ *
150
+ * If you're using Microsoft Developer Studio 5.0 to access
151
+ * functions in a Win32 Cryptoki .dll, in might be defined by:
152
+ *
153
+ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
154
+ * returnType __declspec(dllimport) (* name)
155
+ *
156
+ * If you're using an earlier version of Microsoft Developer
157
+ * Studio to access functions in a Win16 Cryptoki .dll, it might
158
+ * be defined by:
159
+ *
160
+ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
161
+ * returnType __export _far _pascal (* name)
162
+ *
163
+ * In a UNIX environment, it might be defined by:
164
+ *
165
+ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
166
+ * returnType (* name)
167
+ *
168
+ *
169
+ * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
170
+ * a function pointer type for an application callback out of
171
+ * a return type for the callback and a name for the callback.
172
+ * It should be used in the following fashion:
173
+ *
174
+ * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
175
+ *
176
+ * to declare a function pointer, myCallback, to a callback
177
+ * which takes arguments args and returns a CK_RV. It can also
178
+ * be used like this:
179
+ *
180
+ * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
181
+ * myCallbackType myCallback;
182
+ *
183
+ * If you're using Microsoft Developer Studio 5.0 to do Win32
184
+ * Cryptoki development, it might be defined by:
185
+ *
186
+ * #define CK_CALLBACK_FUNCTION(returnType, name) \
187
+ * returnType (* name)
188
+ *
189
+ * If you're using an earlier version of Microsoft Developer
190
+ * Studio to do Win16 development, it might be defined by:
191
+ *
192
+ * #define CK_CALLBACK_FUNCTION(returnType, name) \
193
+ * returnType _far _pascal (* name)
194
+ *
195
+ * In a UNIX environment, it might be defined by:
196
+ *
197
+ * #define CK_CALLBACK_FUNCTION(returnType, name) \
198
+ * returnType (* name)
199
+ *
200
+ *
201
+ * 6. NULL_PTR: This macro is the value of a NULL pointer.
202
+ *
203
+ * In any ANSI/ISO C environment (and in many others as well),
204
+ * this should best be defined by
205
+ *
206
+ * #ifndef NULL_PTR
207
+ * #define NULL_PTR 0
208
+ * #endif
209
+ */
210
+
211
+
212
+ /* All the various Cryptoki types and #define'd values are in the
213
+ * file pkcs11t.h. */
214
+ #include "pkcs11t.h"
215
+
216
+ #define __PASTE(x,y) x##y
217
+
218
+
219
+ /* ==============================================================
220
+ * Define the "extern" form of all the entry points.
221
+ * ==============================================================
222
+ */
223
+
224
+ #define CK_NEED_ARG_LIST 1
225
+ #define CK_PKCS11_FUNCTION_INFO(name) \
226
+ extern CK_DECLARE_FUNCTION(CK_RV, name)
227
+
228
+ /* pkcs11f.h has all the information about the Cryptoki
229
+ * function prototypes. */
230
+ #include "pkcs11f.h"
231
+
232
+ #undef CK_NEED_ARG_LIST
233
+ #undef CK_PKCS11_FUNCTION_INFO
234
+
235
+
236
+ /* ==============================================================
237
+ * Define the typedef form of all the entry points. That is, for
238
+ * each Cryptoki function C_XXX, define a type CK_C_XXX which is
239
+ * a pointer to that kind of function.
240
+ * ==============================================================
241
+ */
242
+
243
+ #define CK_NEED_ARG_LIST 1
244
+ #define CK_PKCS11_FUNCTION_INFO(name) \
245
+ typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
246
+
247
+ /* pkcs11f.h has all the information about the Cryptoki
248
+ * function prototypes. */
249
+ #include "pkcs11f.h"
250
+
251
+ #undef CK_NEED_ARG_LIST
252
+ #undef CK_PKCS11_FUNCTION_INFO
253
+
254
+
255
+ /* ==============================================================
256
+ * Define structed vector of entry points. A CK_FUNCTION_LIST
257
+ * contains a CK_VERSION indicating a library's Cryptoki version
258
+ * and then a whole slew of function pointers to the routines in
259
+ * the library. This type was declared, but not defined, in
260
+ * pkcs11t.h.
261
+ * ==============================================================
262
+ */
263
+
264
+ #define CK_PKCS11_FUNCTION_INFO(name) \
265
+ __PASTE(CK_,name) name;
266
+
267
+ struct CK_FUNCTION_LIST {
268
+
269
+ CK_VERSION version; /* Cryptoki version */
270
+
271
+ /* Pile all the function pointers into the CK_FUNCTION_LIST. */
272
+ /* pkcs11f.h has all the information about the Cryptoki
273
+ * function prototypes. */
274
+ #include "pkcs11f.h"
275
+
276
+ };
277
+
278
+ #undef CK_PKCS11_FUNCTION_INFO
279
+
280
+
281
+ #undef __PASTE
282
+
283
+ #ifdef __cplusplus
284
+ }
285
+ #endif
286
+
287
+ #endif