roostify-pkcs11 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +23 -0
- data/.gemtest +0 -0
- data/.travis.yml +10 -0
- data/.yardopts +1 -0
- data/Gemfile +16 -0
- data/History.txt +62 -0
- data/MIT-LICENSE +22 -0
- data/README.rdoc +186 -0
- data/Rakefile +127 -0
- data/appveyor.yml +38 -0
- data/ext/extconf.rb +7 -0
- data/ext/generate_constants.rb +57 -0
- data/ext/generate_structs.rb +206 -0
- data/ext/generate_thread_funcs.rb +72 -0
- data/ext/include/cryptoki.h +66 -0
- data/ext/include/ct-kip.h +50 -0
- data/ext/include/otp-pkcs11.h +125 -0
- data/ext/include/pkcs-11v2-20a3.h +124 -0
- data/ext/include/pkcs11.h +287 -0
- data/ext/include/pkcs11f.h +900 -0
- data/ext/include/pkcs11t.h +1917 -0
- data/ext/pk11.c +1680 -0
- data/ext/pk11.h +81 -0
- data/ext/pk11_const.c +205 -0
- data/ext/pk11_const_def.inc +539 -0
- data/ext/pk11_const_macros.h +38 -0
- data/ext/pk11_struct.doc +912 -0
- data/ext/pk11_struct_def.inc +346 -0
- data/ext/pk11_struct_impl.inc +346 -0
- data/ext/pk11_struct_macros.h +435 -0
- data/ext/pk11_thread_funcs.c +411 -0
- data/ext/pk11_thread_funcs.h +482 -0
- data/ext/pk11_version.h +6 -0
- data/lib/pkcs11.rb +9 -0
- data/lib/pkcs11/extensions.rb +68 -0
- data/lib/pkcs11/helper.rb +145 -0
- data/lib/pkcs11/library.rb +140 -0
- data/lib/pkcs11/object.rb +171 -0
- data/lib/pkcs11/session.rb +765 -0
- data/lib/pkcs11/slot.rb +102 -0
- data/pkcs11_luna/Manifest.txt +24 -0
- data/pkcs11_luna/README_LUNA.rdoc +103 -0
- data/pkcs11_protect_server/Manifest.txt +14 -0
- data/pkcs11_protect_server/README_PROTECT_SERVER.rdoc +89 -0
- data/test/fixtures/softokn/cert8.db +0 -0
- data/test/fixtures/softokn/key3.db +0 -0
- data/test/fixtures/softokn/secmod.db +0 -0
- data/test/helper.rb +66 -0
- data/test/test_pkcs11.rb +79 -0
- data/test/test_pkcs11_crypt.rb +220 -0
- data/test/test_pkcs11_object.rb +122 -0
- data/test/test_pkcs11_session.rb +123 -0
- data/test/test_pkcs11_slot.rb +78 -0
- data/test/test_pkcs11_structs.rb +166 -0
- data/test/test_pkcs11_thread.rb +43 -0
- metadata +214 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38f485d46433fe18d86d2b1d95f52900f5070bb0
|
4
|
+
data.tar.gz: 27d9b3cdb79b632e4d0f7f7f2f3953979742b52c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0749ad1fd4561b42be42e97e4c8b32bdf8e61adee818a768baf67c604af4581c6b8b9e109e7b479d43a295bd31cec33153bf6cbfbbc6c4560bc2106ed5408726
|
7
|
+
data.tar.gz: b2d1c602558d77298319fbf6a3efcf0c4eb2b1fa5e203eac0967752420abfd0eb436e230e8a2d11e9644d07734e41481c9ac55ce93467e745b944c7a4c5d3a3b
|
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/.gemtest
ADDED
File without changes
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--title "PKCS#11/Ruby Interface" --no-private lib/**/*.rb ext/*.c ext/*.doc
|
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 "rdoc", "~>4.0", :group => [:development, :test]
|
9
|
+
gem "yard", ">=0.6", :group => [:development, :test]
|
10
|
+
gem "rake-compiler", "~>0.9.2", :group => [:development, :test]
|
11
|
+
gem "rake-compiler-dock", "~>0.4.3", :group => [:development, :test]
|
12
|
+
gem "minitest", "~>5.7", :group => [:development, :test]
|
13
|
+
gem "hoe-bundler", "~>1.0", :group => [:development, :test]
|
14
|
+
gem "hoe", "~>3.13", :group => [:development, :test]
|
15
|
+
|
16
|
+
# vim: syntax=ruby
|
data/History.txt
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
=== 0.2.5 / 2015-01-26
|
2
|
+
|
3
|
+
* Fix compatibility with Ruby-2.2
|
4
|
+
* Add Ruby-2.1 and 2.2 to binary Windows gems.
|
5
|
+
|
6
|
+
=== 0.2.4 / 2013-04-05
|
7
|
+
|
8
|
+
* Build and package binary x64 version for Windows in addition to x86.
|
9
|
+
* Allow to use big positive numbers (>0x80000000) in 32bit mode (Anton Fedorov)
|
10
|
+
|
11
|
+
=== 0.2.3 / 2012-01-25
|
12
|
+
|
13
|
+
* fix C_WaitForSlotEvent to be a Library- instead of a Slot-method
|
14
|
+
* allow :sw/:hsm to ProtectServer::Library#load_library in the same way as #initialize
|
15
|
+
* allow Hash argument to Library#C_Initialize in the same way as #initialize
|
16
|
+
|
17
|
+
=== 0.2.2 / 2011-12-12
|
18
|
+
|
19
|
+
* add ability to change PKCS11 base methods in order to use vendor defined attributes, return codes and mechanisms
|
20
|
+
* restructured C code to avoid duplicated code in vendor extension gems
|
21
|
+
* add gem pkcs11_protect_server to cover many ProtectServer specific extensions
|
22
|
+
* update test/helper to find newer libsoftokn3
|
23
|
+
* add task for generating combined docs of PKCS11 and PKCS11::ProtectServer
|
24
|
+
* changed PKCS11#slots to return all slots of the device by default
|
25
|
+
* add ability to set/get multiple attributes with Object#[] and Object#[]=
|
26
|
+
|
27
|
+
=== 0.2.1 / 2011-04-21
|
28
|
+
|
29
|
+
* add some more CK_ULONG and CK_BOOL attributes
|
30
|
+
* add array of structs accessor used in CK_OTP_PARAMS
|
31
|
+
* refactured inc-file generation
|
32
|
+
* bit more documentation
|
33
|
+
* bugfix: print CKR-values as unsigned long
|
34
|
+
* bugfix: Slot#mechanism_info didn't work with Symbol
|
35
|
+
|
36
|
+
|
37
|
+
=== 0.2.0 / 2011-01-18
|
38
|
+
|
39
|
+
* switch API documentation to YARD instead of RDOC
|
40
|
+
* add Ruby classes for all PKCS#11 structures
|
41
|
+
* add CopyObject
|
42
|
+
* add Get/SetOperationState
|
43
|
+
* use distinct Exception classes for different error codes
|
44
|
+
* PKCS#11 function calls don't block other ruby threads any more (only Ruby 1.9, Rubinius)
|
45
|
+
* don't wrap mechanisms any more (GetMechanismList returns plain Integers now)
|
46
|
+
* choose structs as mechanism parameter based on the given mechanism
|
47
|
+
* autogenerate many constants from C header files
|
48
|
+
* finer graded control over library loading
|
49
|
+
* several bug fixes
|
50
|
+
* more unit tests
|
51
|
+
* more documentation
|
52
|
+
|
53
|
+
|
54
|
+
=== 0.1.0 / 2010-05-03
|
55
|
+
|
56
|
+
* first rubygem version
|
57
|
+
* Most functions and operations of PKCS#11 v2.2 are implemented.
|
58
|
+
* The library is based on the work of Ryosuke Kutsuna and GOTOU Yuuzou, but extended in the following ways:
|
59
|
+
- running on Unix and Windows OS
|
60
|
+
- downloadable as rubygem in source and win32 binary version
|
61
|
+
- new API, it's more ruby-like and well documented
|
62
|
+
- most functions are unit tested with help of softokn library
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2008 Ryosuke Kutsuna <ryosuke@deer-n-horse.jp>
|
2
|
+
Copyright (c) 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
3
|
+
Copyright (c) 2010 Lars Kanis <kanis@comcard.de>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,186 @@
|
|
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
|
+
= PKCS #11/Ruby Interface
|
5
|
+
|
6
|
+
* Homepage: http://github.com/larskanis/pkcs11
|
7
|
+
* API documentation: http://rubydoc.info/gems/pkcs11/frames
|
8
|
+
|
9
|
+
This module allows Ruby programs to interface with "RSA Security Inc.
|
10
|
+
PKCS #11 Cryptographic Token Interface (Cryptoki)".
|
11
|
+
PKCS #11 is the de-facto standard to access cryptographic devices.
|
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:
|
13
|
+
* OpenSC[http://www.opensc-project.org] supported Smart Cards
|
14
|
+
* Safenet[http://www.safenet-inc.com] - Protect Server and Luna HSMs
|
15
|
+
* Mozilla_Soft_Token[https://developer.mozilla.org/en/PKCS11] which comes with every firefox installation
|
16
|
+
|
17
|
+
This module works on Unix like operating systems and on Windows.
|
18
|
+
|
19
|
+
== Installation
|
20
|
+
|
21
|
+
$ gem install pkcs11
|
22
|
+
|
23
|
+
This installs the PKCS#11 extension either by compiling (Unix) or by using the precompiled gem for Windows.
|
24
|
+
|
25
|
+
== Usage
|
26
|
+
Cryptoki has a reputation to be complicated to implement and use.
|
27
|
+
While this seems to be true for C, it shouldn't for Ruby.
|
28
|
+
|
29
|
+
* {PKCS11.open} opens a PKCS#11 Unix *.so file or Windows-DLL with a suitable PKCS #11 implementation and returns a {PKCS11::Library}.
|
30
|
+
* {PKCS11::Library#slots} returns a list of {PKCS11::Slot} for all slots accessable by the library.
|
31
|
+
* {PKCS11::Slot#open} opens a {PKCS11::Session} which is used for object handling and cryptographic operations.
|
32
|
+
* {PKCS11::Object} represents a key, data or certificate object.
|
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.)
|
35
|
+
|
36
|
+
=== Example
|
37
|
+
require "rubygems"
|
38
|
+
require "pkcs11"
|
39
|
+
include PKCS11
|
40
|
+
|
41
|
+
pkcs11 = PKCS11.open("/path/to/pkcs11.so")
|
42
|
+
p pkcs11.info # => #<PKCS11::CK_INFO cryptokiVersion=...>
|
43
|
+
pkcs11.active_slots.first.open do |session|
|
44
|
+
session.login(:USER, "1234")
|
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")
|
48
|
+
session.logout
|
49
|
+
end
|
50
|
+
|
51
|
+
This opens a {PKCS11::Library PKCS#11 library} and prints it's {PKCS11::CK_INFO information block}.
|
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.
|
56
|
+
|
57
|
+
Many more usage examples can be found in the unit tests of the <tt>test</tt> directory of the project or gem.
|
58
|
+
|
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.
|
63
|
+
|
64
|
+
=== Vendor extensions
|
65
|
+
Some vendors extend their libraries beyond the standard, in it's own way.
|
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}
|
69
|
+
|
70
|
+
=== Threading
|
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.
|
74
|
+
|
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.
|
77
|
+
|
78
|
+
|
79
|
+
== Compiling for Windows
|
80
|
+
|
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
|
83
|
+
|
84
|
+
$ gem install pkcs11 --platform=ruby
|
85
|
+
|
86
|
+
for installation.
|
87
|
+
In addition precompiled binary Windows gems are provided for convenience.
|
88
|
+
They are installed by default on Windows.
|
89
|
+
|
90
|
+
The binary Windows gems can be compiled per rake-compiler-dock[https://github.com/rake-compiler/rake-compiler-dock] :
|
91
|
+
|
92
|
+
$ rake gem:windows
|
93
|
+
|
94
|
+
If everything works, there should be some files kind of pkcs11-VERSION-ARCH-mingw32.gem in the pkg directory for installation.
|
95
|
+
|
96
|
+
|
97
|
+
== ToDo
|
98
|
+
|
99
|
+
* encoding support for Ruby 1.9+
|
100
|
+
* support for proprietary extensions of other vendors
|
101
|
+
* full support for PKCS#11 v2.40
|
102
|
+
|
103
|
+
== Development Status
|
104
|
+
|
105
|
+
Any operation that is possible with PKCS#11 in C, should be likewise possible in Ruby.
|
106
|
+
Otherwise it is considered as a bug in the binding.
|
107
|
+
|
108
|
+
STATE FUNCTION NOTE
|
109
|
+
------ --------------------- ----------------------------------------
|
110
|
+
DONE C_Initialize
|
111
|
+
DONE C_Finalize
|
112
|
+
DONE C_GetInfo
|
113
|
+
DONE C_GetFunctionList
|
114
|
+
DONE C_GetSlotList
|
115
|
+
DONE C_GetSlotInfo
|
116
|
+
DONE C_GetTokenInfo
|
117
|
+
DONE C_GetMechanismList
|
118
|
+
DONE C_GetMechanismInfo
|
119
|
+
DONE C_InitToken
|
120
|
+
DONE C_InitPIN
|
121
|
+
DONE C_SetPIN
|
122
|
+
DONE C_OpenSession
|
123
|
+
DONE C_CloseSession
|
124
|
+
DONE C_CloseAllSessions
|
125
|
+
DONE C_GetSessionInfo
|
126
|
+
DONE C_GetOperationState
|
127
|
+
DONE C_SetOperationState
|
128
|
+
DONE C_Login
|
129
|
+
DONE C_Logout
|
130
|
+
DONE C_CreateObject
|
131
|
+
DONE C_CopyObject
|
132
|
+
DONE C_DestroyObject
|
133
|
+
DONE C_GetObjectSize
|
134
|
+
DONE C_GetAttributeValue
|
135
|
+
DONE C_SetAttributeValue
|
136
|
+
DONE C_FindObjectsInit
|
137
|
+
DONE C_FindObjects
|
138
|
+
DONE C_FindObjectsFinal
|
139
|
+
DONE C_EncryptInit
|
140
|
+
DONE C_Encrypt
|
141
|
+
DONE C_EncryptUpdate
|
142
|
+
DONE C_EncryptFinal
|
143
|
+
DONE C_DecryptInit
|
144
|
+
DONE C_Decrypt
|
145
|
+
DONE C_DecryptUpdate
|
146
|
+
DONE C_DecryptFinal
|
147
|
+
DONE C_DigestInit
|
148
|
+
DONE C_Digest
|
149
|
+
DONE C_DigestUpdate
|
150
|
+
DONE C_DigestKey
|
151
|
+
DONE C_DigestFinal
|
152
|
+
DONE C_SignInit
|
153
|
+
DONE C_Sign
|
154
|
+
DONE C_SignUpdate
|
155
|
+
DONE C_SignFinal
|
156
|
+
DONE C_SignRecoverInit
|
157
|
+
DONE C_SignRecover
|
158
|
+
DONE C_VerifyInit
|
159
|
+
DONE C_Verify
|
160
|
+
DONE C_VerifyUpdate
|
161
|
+
DONE C_VerifyFinal
|
162
|
+
DONE C_VerifyRecoverInit
|
163
|
+
DONE C_VerifyRecover
|
164
|
+
DONE C_DigestEncryptUpdate
|
165
|
+
DONE C_DecryptDigestUpdate
|
166
|
+
DONE C_SignEncryptUpdate
|
167
|
+
DONE C_DecryptVerifyUpdate
|
168
|
+
DONE C_GenerateKey
|
169
|
+
DONE C_GenerateKeyPair
|
170
|
+
DONE C_WrapKey
|
171
|
+
DONE C_UnwrapKey
|
172
|
+
DONE C_DeriveKey
|
173
|
+
DONE C_SeedRandom
|
174
|
+
DONE C_GenerateRandom
|
175
|
+
N/A C_GetFunctionStatus legacy function
|
176
|
+
N/A C_CancelFunction legacy function
|
177
|
+
DONE C_WaitForSlotEvent
|
178
|
+
|
179
|
+
== Authors
|
180
|
+
* Ryosuke Kutsuna <ryosuke@deer-n-horse.jp>
|
181
|
+
* GOTOU Yuuzou <gotoyuzo@notwork.org>
|
182
|
+
* Lars Kanis <kanis@comcard.de>
|
183
|
+
* Jonathan Patchell <jonathan.patchell@safenet-inc.com>
|
184
|
+
|
185
|
+
== Copying
|
186
|
+
See MIT-LICENSE included in the package.
|
data/Rakefile
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'hoe'
|
6
|
+
require 'rake/extensiontask'
|
7
|
+
require 'rbconfig'
|
8
|
+
|
9
|
+
GENERATED_FILES = [
|
10
|
+
'ext/pk11_struct_impl.inc',
|
11
|
+
'ext/pk11_struct_def.inc',
|
12
|
+
'ext/pk11_const_def.inc',
|
13
|
+
'ext/pk11_struct.doc',
|
14
|
+
'ext/pk11_thread_funcs.h',
|
15
|
+
'ext/pk11_thread_funcs.c',
|
16
|
+
]
|
17
|
+
|
18
|
+
CLEAN.include GENERATED_FILES
|
19
|
+
CLEAN.include 'lib/pkcs11_ext.so'
|
20
|
+
CLEAN.include 'tmp'
|
21
|
+
|
22
|
+
Hoe.plugin :bundler
|
23
|
+
|
24
|
+
# Build a Manifest file to satisfy hoe.
|
25
|
+
IO.write("Manifest.txt", `git ls-files`)
|
26
|
+
|
27
|
+
hoe = Hoe.spec 'roostify-pkcs11' do
|
28
|
+
developer('Ryosuke Kutsuna', 'ryosuke@deer-n-horse.jp')
|
29
|
+
developer('GOTOU Yuuzou', 'gotoyuzo@notwork.org')
|
30
|
+
developer('Lars Kanis', 'kanis@comcard.de')
|
31
|
+
developer('Zee Spencer', 'zee@roostify.com')
|
32
|
+
extra_dev_deps << ['yard', '>= 0.6']
|
33
|
+
extra_dev_deps << ['rake-compiler', '~> 0.9.2']
|
34
|
+
extra_dev_deps << ['rake-compiler-dock', '~> 0.4.3']
|
35
|
+
extra_dev_deps << ['minitest', '~> 5.7']
|
36
|
+
extra_dev_deps << ['hoe-bundler', '~> 1.0']
|
37
|
+
|
38
|
+
self.urls = ['http://github.com/roostify/pkcs11']
|
39
|
+
self.summary = 'PKCS#11 binding for Ruby'
|
40
|
+
self.description = 'This module allows Ruby programs to interface with "RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki)".'
|
41
|
+
|
42
|
+
self.readme_file = 'README.rdoc'
|
43
|
+
self.extra_rdoc_files << self.readme_file << 'ext/pk11.c'
|
44
|
+
spec_extras[:extensions] = 'ext/extconf.rb'
|
45
|
+
spec_extras[:files] = `git ls-files`.split("\n").reject{|f| f=~/^pkcs11_/ }
|
46
|
+
spec_extras[:files] += GENERATED_FILES
|
47
|
+
spec_extras[:has_rdoc] = 'yard'
|
48
|
+
self.rdoc_locations << "http://www.rubydoc.info/gems/roostify-pkcs11"
|
49
|
+
end
|
50
|
+
|
51
|
+
Rake::ExtensionTask.new('pkcs11_ext', hoe.spec) do |ext|
|
52
|
+
ext.ext_dir = 'ext'
|
53
|
+
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
54
|
+
ext.cross_platform = ['i386-mingw32', 'x64-mingw32'] # forces the Windows platform instead of the default one
|
55
|
+
end
|
56
|
+
|
57
|
+
file 'ext/extconf.rb' => ['ext/pk11_struct_def.inc', 'ext/pk11_thread_funcs.c']
|
58
|
+
file 'ext/pk11_struct_def.inc' => 'ext/generate_structs.rb' do
|
59
|
+
sh "#{RbConfig::CONFIG['ruby_install_name']} ext/generate_structs.rb --def ext/pk11_struct_def.inc --impl ext/pk11_struct_impl.inc --doc ext/pk11_struct.doc ext/include/pkcs11t.h"
|
60
|
+
end
|
61
|
+
file 'ext/pk11_struct_impl.inc' => 'ext/pk11_struct_def.inc'
|
62
|
+
file 'ext/pk11_struct.doc' => 'ext/pk11_struct_def.inc'
|
63
|
+
|
64
|
+
file 'ext/pk11_const_def.inc' => 'ext/generate_constants.rb' do
|
65
|
+
sh "#{RbConfig::CONFIG['ruby_install_name']} ext/generate_constants.rb --const ext/pk11_const_def.inc ext/include/pkcs11t.h"
|
66
|
+
end
|
67
|
+
file 'ext/pk11.c' => ['ext/pk11_struct_def.inc', 'ext/pk11_struct_impl.inc', 'ext/pk11_struct_macros.h']
|
68
|
+
file 'ext/pk11_const.c' => ['ext/pk11_const_def.inc', 'ext/pk11_const_macros.h']
|
69
|
+
|
70
|
+
file 'ext/pk11_thread_funcs.h' => 'ext/generate_thread_funcs.rb' do
|
71
|
+
sh "#{RbConfig::CONFIG['ruby_install_name']} ext/generate_thread_funcs.rb --impl ext/pk11_thread_funcs.c --decl ext/pk11_thread_funcs.h ext/include/pkcs11f.h"
|
72
|
+
end
|
73
|
+
file 'ext/pk11_thread_funcs.c' => 'ext/pk11_thread_funcs.h'
|
74
|
+
file 'ext/pk11.h' => 'ext/pk11_thread_funcs.h'
|
75
|
+
|
76
|
+
# To reduce the gem file size strip mingw32 dlls before packaging
|
77
|
+
ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
|
78
|
+
task "tmp/x86-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pkcs11_ext.so" do |t|
|
79
|
+
sh "i686-w64-mingw32-strip -S tmp/x86-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pkcs11_ext.so"
|
80
|
+
end
|
81
|
+
|
82
|
+
task "tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pkcs11_ext.so" do |t|
|
83
|
+
sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/pkcs11_ext.so"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Build windows binary gems per rake-compiler-dock."
|
88
|
+
task "gem:windows" do
|
89
|
+
require "rake_compiler_dock"
|
90
|
+
RakeCompilerDock.sh <<-EOT
|
91
|
+
rake cross native gem MAKE='nice make -j`nproc`'
|
92
|
+
EOT
|
93
|
+
end
|
94
|
+
|
95
|
+
task :docs_of_vendor_extensions do
|
96
|
+
Dir['pkcs11_luna', 'pkcs11_protect_server'].each do |dir|
|
97
|
+
chdir(dir) do
|
98
|
+
sh "rake doc_files"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Generate static HTML documentation with YARD"
|
104
|
+
task :yardoc=>['ext/pk11_struct.doc', :docs_of_vendor_extensions] do
|
105
|
+
luna_docs = "pkcs11_luna/lib/**/*.rb pkcs11_luna/ext/*.c pkcs11_luna/ext/*.doc"
|
106
|
+
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"
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "Publish YARD to wherever you want."
|
110
|
+
task :publish_yard => [:yardoc] do
|
111
|
+
rdoc_locations = hoe.rdoc_locations
|
112
|
+
warn "no rdoc_location values" if rdoc_locations.empty?
|
113
|
+
rdoc_locations.each do |dest|
|
114
|
+
sh %{rsync -av --delete doc/ #{dest}}
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# RDoc-upload task for github (currently on rubyforge)
|
119
|
+
#
|
120
|
+
# require 'grancher/task'
|
121
|
+
# Grancher::Task.new do |g|
|
122
|
+
# g.branch = 'gh-pages' # alternatively, g.refspec = 'ghpages:/refs/heads/ghpages'
|
123
|
+
# g.push_to = 'origin'
|
124
|
+
# g.directory 'doc'
|
125
|
+
# end
|
126
|
+
|
127
|
+
# vim: syntax=ruby
|