jruby-openssl 0.9.4 → 0.14.0-java
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 +7 -0
- data/History.md +652 -0
- data/LICENSE.txt +37 -0
- data/Mavenfile +163 -5
- data/README.md +75 -0
- data/Rakefile +52 -2
- data/lib/jopenssl/_compat23.rb +71 -0
- data/lib/jopenssl/load.rb +75 -16
- data/lib/jopenssl/version.rb +9 -4
- data/lib/jopenssl.jar +0 -0
- data/lib/openssl/bn.rb +40 -5
- data/lib/openssl/buffering.rb +477 -4
- data/lib/openssl/cipher.rb +67 -5
- data/lib/openssl/config.rb +500 -4
- data/lib/openssl/digest.rb +73 -5
- data/lib/openssl/hmac.rb +13 -0
- data/lib/openssl/marshal.rb +30 -0
- data/lib/openssl/pkcs12.rb +60 -99
- data/lib/openssl/pkcs5.rb +22 -0
- data/lib/openssl/pkey.rb +42 -0
- data/lib/openssl/ssl.rb +542 -4
- data/lib/openssl/x509.rb +368 -4
- data/lib/openssl.rb +3 -1
- data/lib/org/bouncycastle/bcpkix-jdk18on/1.71/bcpkix-jdk18on-1.71.jar +0 -0
- data/lib/org/bouncycastle/bcprov-jdk18on/1.71/bcprov-jdk18on-1.71.jar +0 -0
- data/lib/org/bouncycastle/bctls-jdk18on/1.71/bctls-jdk18on-1.71.jar +0 -0
- data/lib/org/bouncycastle/bcutil-jdk18on/1.71/bcutil-jdk18on-1.71.jar +0 -0
- data/pom.xml +772 -0
- metadata +40 -107
- data/History.txt +0 -218
- data/License.txt +0 -30
- data/README.txt +0 -13
- data/TODO-1_9-support.txt +0 -23
- data/lib/jopenssl18/openssl/bn.rb +0 -35
- data/lib/jopenssl18/openssl/buffering.rb +0 -241
- data/lib/jopenssl18/openssl/cipher.rb +0 -65
- data/lib/jopenssl18/openssl/config.rb +0 -316
- data/lib/jopenssl18/openssl/digest.rb +0 -61
- data/lib/jopenssl18/openssl/pkcs7.rb +0 -25
- data/lib/jopenssl18/openssl/ssl-internal.rb +0 -179
- data/lib/jopenssl18/openssl/ssl.rb +0 -1
- data/lib/jopenssl18/openssl/x509-internal.rb +0 -153
- data/lib/jopenssl18/openssl/x509.rb +0 -1
- data/lib/jopenssl18/openssl.rb +0 -67
- data/lib/jopenssl19/openssl/bn.rb +0 -35
- data/lib/jopenssl19/openssl/buffering.rb +0 -449
- data/lib/jopenssl19/openssl/cipher.rb +0 -65
- data/lib/jopenssl19/openssl/config.rb +0 -313
- data/lib/jopenssl19/openssl/digest.rb +0 -72
- data/lib/jopenssl19/openssl/ssl-internal.rb +0 -177
- data/lib/jopenssl19/openssl/ssl.rb +0 -2
- data/lib/jopenssl19/openssl/x509-internal.rb +0 -158
- data/lib/jopenssl19/openssl/x509.rb +0 -2
- data/lib/jopenssl19/openssl.rb +0 -23
- data/lib/openssl/pkcs7.rb +0 -5
- data/lib/openssl/ssl-internal.rb +0 -5
- data/lib/openssl/x509-internal.rb +0 -5
- data/test/java/pkcs7_mime_enveloped.message +0 -19
- data/test/java/pkcs7_mime_signed.message +0 -30
- data/test/java/pkcs7_multipart_signed.message +0 -45
- data/test/java/test_java_attribute.rb +0 -25
- data/test/java/test_java_bio.rb +0 -42
- data/test/java/test_java_mime.rb +0 -173
- data/test/java/test_java_pkcs7.rb +0 -772
- data/test/java/test_java_smime.rb +0 -177
- data/test/test_java.rb +0 -98
- data/test/ut_eof.rb +0 -128
data/LICENSE.txt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
JRuby-OpenSSL is distributed under the same license as JRuby a tri EPL/GPL/LGPL
|
2
|
+
license. You can use it, redistribute it and/or modify it under the terms of the:
|
3
|
+
|
4
|
+
Eclipse Public License version 1.0
|
5
|
+
GNU General Public License version 2.0
|
6
|
+
GNU Lesser General Public License version 2.1
|
7
|
+
|
8
|
+
The contents of this file are subject to the Common Public License Version 1.0
|
9
|
+
(the "License"); you may not use this file except in compliance with the License.
|
10
|
+
You may obtain a copy of the License at http://www.eclipse.org/legal/cpl-v10.html
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
14
|
+
FOR APARTICULAR PURPOSE AND NONINFRINGEMENT.
|
15
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
16
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
17
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
18
|
+
DEALINGS IN THE SOFTWARE.
|
19
|
+
|
20
|
+
Copyright (C) 2007-2009 Ola Bini <ola.bini@gmail.com>
|
21
|
+
Copyright (C) 2009-2018 The JRuby Team
|
22
|
+
|
23
|
+
Alternatively, the contents of this file may be used under the terms of
|
24
|
+
either of the GNU General Public License Version 2 or later (the "GPL"),
|
25
|
+
or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
26
|
+
in which case the provisions of the GPL or the LGPL are applicable instead
|
27
|
+
of those above. If you wish to allow use of your version of this file only
|
28
|
+
under the terms of either the GPL or the LGPL, and not to allow others to
|
29
|
+
use your version of this file under the terms of the EPL, indicate your
|
30
|
+
decision by deleting the provisions above and replace them with the notice
|
31
|
+
and other provisions required by the GPL or the LGPL. If you do not delete
|
32
|
+
the provisions above, a recipient may use your version of this file under
|
33
|
+
the terms of any one of the EPL, the GPL or the LGPL.
|
34
|
+
|
35
|
+
|
36
|
+
JRuby-OpenSSL includes software by The Legion of the Bouncy Castle Inc.
|
37
|
+
Please, visit (http://bouncycastle.org/license.html) for licensing details.
|
data/Mavenfile
CHANGED
@@ -1,11 +1,169 @@
|
|
1
1
|
#-*- mode: ruby -*-
|
2
2
|
|
3
|
-
gemspec
|
3
|
+
gemspec :jar => 'jopenssl', :include_jars => true
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
distribution_management do
|
6
|
+
snapshot_repository :id => :ossrh, :url => 'https://oss.sonatype.org/content/repositories/snapshots'
|
7
|
+
repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
java_target = '1.8'
|
11
|
+
gen_sources = '${basedir}/target/generated-sources' # hard-coded in AnnotationBinder
|
12
|
+
|
13
|
+
plugin( 'org.codehaus.mojo:exec-maven-plugin', '1.3.2' ) do
|
14
|
+
|
15
|
+
=begin
|
16
|
+
invoker_main = '-Djruby.bytecode.version=${compiler.target}'
|
17
|
+
#invoker_main << ' -classpath '
|
18
|
+
invoker_main << ' org.jruby.anno.InvokerGenerator'
|
19
|
+
invoker_main << " #{gen_sources}/annotated_classes.txt ${project.build.outputDirectory}"
|
20
|
+
|
21
|
+
dependency 'org.jruby', 'jruby-core', '${jruby.version}'
|
22
|
+
|
23
|
+
execute_goal :java, :id => 'invoker-generator', :phase => 'process-classes',
|
24
|
+
:mainClass => 'org.jruby.anno.InvokerGenerator', :classpathScope => 'compile',
|
25
|
+
#:arguments => [ '${gen.sources}/annotated_classes.txt', '${project.build.outputDirectory}' ] do
|
26
|
+
:commandlineArgs => "#{gen_sources}/annotated_classes.txt ${project.build.outputDirectory}",
|
27
|
+
:classpathScope => 'runtime', :additionalClasspathElements => [ '${project.build.outputDirectory}' ],
|
28
|
+
:includeProjectDependencies => false, :includePluginDependencies => true do
|
29
|
+
|
30
|
+
#systemProperties do
|
31
|
+
# property '-Djruby.bytecode.version=${compiler.target}'
|
32
|
+
#end
|
33
|
+
=end
|
34
|
+
|
35
|
+
execute_goal :exec, :id => 'invoker-generator', :phase => 'process-classes',
|
36
|
+
:executable => 'java', :classpathScope => 'compile',
|
37
|
+
:arguments => [ "-Djruby.bytecode.version=#{java_target}",
|
38
|
+
'-classpath', xml( '<classpath/>' ),
|
39
|
+
'org.jruby.anno.InvokerGenerator',
|
40
|
+
"#{gen_sources}/annotated_classes.txt",
|
41
|
+
'${project.build.outputDirectory}' ]
|
42
|
+
end
|
43
|
+
|
44
|
+
plugin( 'org.codehaus.mojo:build-helper-maven-plugin', '1.9' ) do
|
45
|
+
execute_goal 'add-source', :phase => 'process-classes', :sources => [ gen_sources ]
|
46
|
+
end
|
47
|
+
|
48
|
+
compiler_configuration = {
|
49
|
+
:source => '1.8', :target => java_target, :release => '8',
|
50
|
+
:encoding => 'UTF-8', :debug => true,
|
51
|
+
:showWarnings => true, :showDeprecation => true,
|
52
|
+
:excludes => [ 'module-info.java' ],
|
53
|
+
#:jdkToolchain => { :version => '[1.7,11)' },
|
54
|
+
:generatedSourcesDirectory => gen_sources,
|
55
|
+
:annotationProcessors => [ 'org.jruby.anno.AnnotationBinder' ]
|
56
|
+
}
|
57
|
+
compiler_configuration.delete(:release) if ENV_JAVA['java.specification.version'] == '1.8'
|
58
|
+
|
59
|
+
plugin( :compiler, '3.9.0', compiler_configuration) do
|
60
|
+
|
61
|
+
#execute_goal :compile, :id => 'annotation-binder', :phase => 'compile',
|
62
|
+
# :generatedSourcesDirectory => gen_sources, #:outputDirectory => gen_sources,
|
63
|
+
# :annotationProcessors => [ 'org.jruby.anno.AnnotationBinder' ],
|
64
|
+
# :proc => 'only', # :compilerReuseStrategy => 'alwaysNew',
|
65
|
+
# :useIncrementalCompilation => false, :fork => true, :verbose => true,
|
66
|
+
# :compilerArgs => [ '-XDignore.symbol.file=true', '-J-Dfile.encoding=UTF-8' ]
|
67
|
+
|
68
|
+
execute_goal :compile,
|
69
|
+
:id => 'compile-populators', :phase => 'process-classes',
|
70
|
+
:includes => [ 'org/jruby/gen/**/*.java' ],
|
71
|
+
:optimize => true,
|
72
|
+
:compilerArgs => [ '', '-XDignore.symbol.file=true' ]
|
73
|
+
end
|
74
|
+
|
75
|
+
plugin :clean do
|
76
|
+
execute_goals( 'clean', :id => 'default-clean', :phase => 'clean',
|
77
|
+
'filesets' => [
|
78
|
+
{ :directory => 'lib', :includes => [ 'jopenssl.jar' ] },
|
79
|
+
{ :directory => 'lib/org' },
|
80
|
+
{ :directory => 'target', :includes => [ '*' ] }
|
81
|
+
],
|
82
|
+
'failOnError' => 'false' )
|
83
|
+
end
|
84
|
+
|
85
|
+
jar 'org.jruby:jruby-core', '9.1.11.0', :scope => :provided
|
86
|
+
# for invoker generated classes we need to add javax.annotation when on Java > 8
|
87
|
+
jar 'javax.annotation:javax.annotation-api', '1.3.1', :scope => :compile
|
88
|
+
jar 'junit:junit', '[4.13.1,)', :scope => :test
|
89
|
+
|
90
|
+
# NOTE: to build on Java 11 - installing gems fails (due old jossl) with:
|
91
|
+
# load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException
|
92
|
+
MVN_JRUBY_VERSION = ENV_JAVA['java.version'].to_i >= 9 ? '9.2.19.0' : '9.1.17.0'
|
93
|
+
|
94
|
+
jruby_plugin! :gem do
|
95
|
+
# when installing dependent gems we want to use the built in openssl not the one from this lib directory
|
96
|
+
execute_goal :id => 'default-package', :addProjectClasspath => false, :libDirectory => 'something-which-does-not-exists'
|
97
|
+
execute_goals :id => 'default-push', :skip => true
|
98
|
+
end
|
99
|
+
|
100
|
+
# we want to have the snapshots on oss.sonatype.org and the released gems on maven central
|
101
|
+
plugin :deploy, '2.8.1' do
|
102
|
+
execute_goals( :deploy, :skip => false )
|
103
|
+
end
|
104
|
+
|
105
|
+
supported_bc_versions = %w{ 1.60 1.61 1.62 1.63 1.64 1.65 1.66 1.67 1.68 }
|
106
|
+
|
107
|
+
default_bc_version = File.read File.expand_path('lib/jopenssl/version.rb', File.dirname(__FILE__))
|
108
|
+
default_bc_version = default_bc_version[/BOUNCY_CASTLE_VERSION\s?=\s?'(.*?)'/, 1]
|
109
|
+
|
110
|
+
properties( 'jruby.plugins.version' => '2.0.1', # 2.0.1
|
111
|
+
'jruby.switches' => '-W0', # https://github.com/torquebox/jruby-maven-plugins/issues/94
|
112
|
+
'bc.versions' => default_bc_version,
|
113
|
+
'invoker.test' => '${bc.versions}',
|
114
|
+
# allow to skip all tests with -Dmaven.test.skip
|
115
|
+
'invoker.skip' => '${maven.test.skip}',
|
116
|
+
'runit.dir' => 'src/test/ruby/**/test_*.rb',
|
117
|
+
'mavengem.wagon.version' => '1.0.3', # for jruby plugin
|
118
|
+
'mavengem-wagon.version' => '1.0.3', # for polyglot-ruby
|
119
|
+
# use this version of jruby for the jruby-maven-plugins
|
120
|
+
'jruby.versions' => MVN_JRUBY_VERSION, 'jruby.version' => MVN_JRUBY_VERSION,
|
121
|
+
# dump pom.xml when running 'rmvn'
|
122
|
+
'polyglot.dump.pom' => 'pom.xml', 'polyglot.dump.readonly' => false )
|
123
|
+
|
124
|
+
# make sure we have the embedded jars in place before we run runit plugin
|
125
|
+
plugin! :dependency do
|
126
|
+
execute_goal 'copy-dependencies',
|
127
|
+
:phase => 'generate-test-resources',
|
128
|
+
:outputDirectory => '${basedir}/lib',
|
129
|
+
:useRepositoryLayout => true,
|
130
|
+
:includeGroupIds => 'org.bouncycastle'
|
131
|
+
end
|
132
|
+
|
133
|
+
jruby_plugin(:runit) { execute_goal( :test, :runitDirectory => '${runit.dir}' ) }
|
134
|
+
|
135
|
+
invoker_run_options = {
|
136
|
+
:id => 'tests-with-different-bc-versions',
|
137
|
+
:projectsDirectory => 'integration',
|
138
|
+
:pomIncludes => [ '*/pom.xml' ],
|
139
|
+
:streamLogs => true,
|
140
|
+
# pass those properties on to the test project
|
141
|
+
:properties => {
|
142
|
+
'jruby.versions' => '${jruby.versions}',
|
143
|
+
'jruby.modes' => '${jruby.modes}',
|
144
|
+
'jruby.openssl.version' => '${project.version}',
|
145
|
+
'bc.versions' => '${bc.versions}',
|
146
|
+
'runit.dir' => '${runit.dir}' }
|
147
|
+
}
|
148
|
+
|
149
|
+
jruby_9_K_versions = %w{ 9.1.2.0 9.1.8.0 9.1.12.0 9.1.16.0 9.1.17.0 }
|
150
|
+
jruby_9_K_versions += %w{ 9.2.0.0 9.2.5.0 9.2.10.0 9.2.17.0 9.2.19.0 }
|
151
|
+
|
152
|
+
jruby_9_K_versions.each { |version|
|
153
|
+
profile :id => "test-#{version}" do
|
154
|
+
plugin :invoker, '1.8' do
|
155
|
+
execute_goals( :install, :run, invoker_run_options )
|
156
|
+
end
|
157
|
+
properties 'jruby.version' => version,
|
158
|
+
'jruby.versions' => version,
|
159
|
+
'bc.versions' => supported_bc_versions.join(',')
|
160
|
+
end
|
161
|
+
}
|
162
|
+
|
163
|
+
profile :id => 'release' do
|
164
|
+
plugin :gpg, '1.6' do
|
165
|
+
execute_goal :sign, :phase => :verify
|
166
|
+
end
|
167
|
+
end
|
10
168
|
|
11
169
|
# vim: syntax=Ruby
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# JRuby-OpenSSL
|
2
|
+
|
3
|
+
[JRuby-OpenSSL](https://github.com/jruby/jruby-openssl) is an add-on gem for
|
4
|
+
[JRuby](http://jruby.org) that emulates the Ruby OpenSSL native library.
|
5
|
+
|
6
|
+
Under the hood uses the [Bouncy Castle Crypto APIs](http://www.bouncycastle.org/).
|
7
|
+
|
8
|
+
Each jruby-openssl gem release includes a certain version, usually the latest available,
|
9
|
+
of the library (namely BC Provider and PKIX/CMS/EAC/PKCS/OCSP/TSP/OPENSSL jars).
|
10
|
+
|
11
|
+
Please report bugs and incompatibilities (preferably with test-cases) to either
|
12
|
+
the JRuby [mailing list][1] or the [bug tracker][2].
|
13
|
+
|
14
|
+
## Compatibility
|
15
|
+
|
16
|
+
|
17
|
+
| JRuby-OpenSSL | JRuby compat | JVM compat | supported BC |
|
18
|
+
| ------------- |:-------------:| ----------:| ------------:|
|
19
|
+
| 0.9.6 | 1.6.8-9.0.2 | Java 6-8 | 1.47-1.50 |
|
20
|
+
| 0.9.12 | 1.6.8-9.0.5 | Java 6-8 | 1.47-1.52 |
|
21
|
+
| 0.9.13 | 1.6.8-9.1.2 | Java 6-8 | 1.49-1.52 |
|
22
|
+
| 0.9.14 | 1.6.8-9.1.5 | Java 6-8 | 1.49-1.54 |
|
23
|
+
| 0.9.17 | 1.6.8-9.1.5 | Java 6-8 | 1.50-1.54 |
|
24
|
+
| ~>0.9.18 | 1.6.8-9.1.x | Java 6-8 | 1.50-1.55 |
|
25
|
+
| 0.10.0 | 1.7.20-9.2.x | Java 7-10 | 1.55-1.59 |
|
26
|
+
| 0.10.3 | 1.7.20-9.2.x | Java 7-11 | 1.56-1.62 |
|
27
|
+
| ~>0.10.5 | 1.7.20-9.3.x | Java 7-11 | 1.60-1.68 |
|
28
|
+
| ~>0.11.x | 9.0.x-9.3.x | Java 7-11 | 1.62-1.68 |
|
29
|
+
| ~>0.12.x | 9.1.x-9.3.x | Java 8-15 | 1.65-1.68 |
|
30
|
+
| ~>0.13.x | 9.1.x-9.3.x | Java 8-17 | 1.68-1.69 |
|
31
|
+
| ~>0.14.x | 9.1.x-9.3.x | Java 8-17 | 1.71 |
|
32
|
+
|
33
|
+
NOTE: backwards JRuby compatibility was not handled for versions <= **0.9.6**
|
34
|
+
|
35
|
+
## Security
|
36
|
+
|
37
|
+
JRuby-OpenSSL is an essential part of [JRuby](http://jruby.org), please report security
|
38
|
+
vulnerabilities to `security@jruby.org` as detailed on JRuby's [security page](http://jruby.org/security).
|
39
|
+
|
40
|
+
Please note that most OpenSSL vulnerabilities do not effect JRuby since its not using
|
41
|
+
any of OpenSSL's C code, only Ruby parts (*.rb) are the same as in MRI's OpenSSL library.
|
42
|
+
|
43
|
+
## Testing
|
44
|
+
|
45
|
+
[![Build Status][0]](http://travis-ci.org/jruby/jruby-openssl)
|
46
|
+
|
47
|
+
rake jar:all # creates pom.xml and generates jopenssl.jar under lib
|
48
|
+
mvn test
|
49
|
+
|
50
|
+
will run (junit as well as ruby) tests and a some ruby tests against the default
|
51
|
+
jruby version. to pick a different JRuby version run
|
52
|
+
|
53
|
+
mvn test -Djruby.versions=9.2.8.0
|
54
|
+
|
55
|
+
for running integration-tests the gem will be first installed and then the same
|
56
|
+
tests run for each possible bouncy-castle version (see [listing][3]), run with
|
57
|
+
|
58
|
+
mvn verify -P test-9.2.9.0,test-9.1.17.0
|
59
|
+
|
60
|
+
or pick a bouncy-castle version
|
61
|
+
|
62
|
+
mvn verify -P test-9.2.9.0 -Dbc.versions=1.60
|
63
|
+
|
64
|
+
NOTE: you can pick any jruby version which is on [central][4] or on [ci.jruby][5]
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
(c) 2009-2020 JRuby distributed under EPL 1.0/GPL 2.0/LGPL 2.1
|
69
|
+
|
70
|
+
[0]: https://secure.travis-ci.org/jruby/jruby-openssl.svg
|
71
|
+
[1]: http://xircles.codehaus.org/projects/jruby/lists
|
72
|
+
[2]: https://github.com/jruby/jruby/issues
|
73
|
+
[3]: https://github.com/jruby/jruby-openssl/tree/master/integration
|
74
|
+
[4]: http://central.maven.org/maven2/org/jruby/
|
75
|
+
[5]: http://ci.jruby.org/snapshots/maven/org.jruby/
|
data/Rakefile
CHANGED
@@ -1,7 +1,57 @@
|
|
1
1
|
#-*- mode: ruby -*-
|
2
2
|
|
3
|
-
|
3
|
+
#Rake::Task[:jar].clear rescue nil
|
4
|
+
desc "Package jopenssl.jar with the compiled classes"
|
5
|
+
task :jar do
|
6
|
+
sh( './mvnw prepare-package -Dmaven.test.skip=true' )
|
7
|
+
end
|
8
|
+
namespace :jar do
|
9
|
+
desc "Package jopenssl.jar file (and dependendent jars)"
|
10
|
+
task :all do
|
11
|
+
sh( './mvnw package -Dmaven.test.skip=true' )
|
12
|
+
end
|
13
|
+
end
|
14
|
+
task :test_prepare do
|
15
|
+
sh( './mvnw prepare-package -Dmaven.test.skip=true' )
|
16
|
+
sh( './mvnw test-compile' ) # separate step due -Dmaven.test.skip=true
|
17
|
+
end
|
4
18
|
|
5
|
-
|
19
|
+
task :clean do
|
20
|
+
sh( './mvnw clean' )
|
21
|
+
end
|
22
|
+
|
23
|
+
task :build do
|
24
|
+
sh( './mvnw clean package -Dmaven.test.skip=true' )
|
25
|
+
end
|
6
26
|
|
7
27
|
task :default => :build
|
28
|
+
|
29
|
+
file('lib/jopenssl.jar') { Rake::Task['jar'].invoke }
|
30
|
+
|
31
|
+
require 'rake/testtask'
|
32
|
+
Rake::TestTask.new do |task|
|
33
|
+
task.libs << File.expand_path('src/test/ruby', File.dirname(__FILE__))
|
34
|
+
test_files = FileList['src/test/ruby/**/test*.rb'].to_a
|
35
|
+
task.test_files = test_files.map { |path| path.sub('src/test/ruby/', '') }
|
36
|
+
task.verbose = true
|
37
|
+
task.loader = :direct
|
38
|
+
task.ruby_opts = [ '-C', 'src/test/ruby', '-rbundler/setup' ]
|
39
|
+
end
|
40
|
+
task :test => 'lib/jopenssl.jar'
|
41
|
+
|
42
|
+
namespace :integration do
|
43
|
+
it_path = File.expand_path('../src/test/integration', __FILE__)
|
44
|
+
task :install do
|
45
|
+
ruby "-C #{it_path} -S bundle install"
|
46
|
+
end
|
47
|
+
# desc "Run IT tests"
|
48
|
+
task :test => 'lib/jopenssl.jar' do
|
49
|
+
unless File.exist?(File.join(it_path, 'Gemfile.lock'))
|
50
|
+
raise "bundle not installed, run `rake integration:install'"
|
51
|
+
end
|
52
|
+
loader = "ARGV.each { |f| require f }"
|
53
|
+
lib = [ File.expand_path('../lib', __FILE__), it_path ]
|
54
|
+
test_files = FileList['src/test/integration/*_test.rb'].map { |path| path.sub('src/test/integration/', '') }
|
55
|
+
ruby "-I#{lib.join(':')} -C src/test/integration -e \"#{loader}\" #{test_files.map { |f| "\"#{f}\"" }.join(' ')}"
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
module OpenSSL
|
4
|
+
|
5
|
+
module PKey
|
6
|
+
|
7
|
+
class DH
|
8
|
+
|
9
|
+
def set_key(pub_key, priv_key)
|
10
|
+
self.pub_key = pub_key
|
11
|
+
self.priv_key = priv_key
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_pqg(p, q, g)
|
16
|
+
self.p = p
|
17
|
+
if respond_to?(:q)
|
18
|
+
self.q = q
|
19
|
+
else # TODO self.q = q
|
20
|
+
OpenSSL.warn "JRuby-OpenSSL does not support setting q param on #{inspect}" if q
|
21
|
+
end
|
22
|
+
self.g = g
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class DSA
|
29
|
+
|
30
|
+
def set_key(pub_key, priv_key)
|
31
|
+
self.pub_key = pub_key
|
32
|
+
self.priv_key = priv_key
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_pqg(p, q, g)
|
37
|
+
self.p = p
|
38
|
+
self.q = q
|
39
|
+
self.g = g
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class RSA
|
46
|
+
|
47
|
+
def set_key(n, e, d)
|
48
|
+
self.n = n
|
49
|
+
self.e = e
|
50
|
+
self.d = d
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_factors(p, q)
|
55
|
+
self.p = p
|
56
|
+
self.q = q
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_crt_params(dmp1, dmq1, iqmp)
|
61
|
+
self.dmp1 = dmp1
|
62
|
+
self.dmq1 = dmq1
|
63
|
+
self.iqmp = iqmp
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/lib/jopenssl/load.rb
CHANGED
@@ -1,23 +1,82 @@
|
|
1
|
-
unless defined? JRUBY_VERSION
|
2
|
-
|
3
|
-
|
1
|
+
warn 'Loading jruby-openssl gem in a non-JRuby interpreter' unless defined? JRUBY_VERSION
|
2
|
+
|
3
|
+
require 'jopenssl/version'
|
4
4
|
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
# NOTE: assuming user does pull in BC .jars from somewhere else on the CP
|
6
|
+
unless ENV_JAVA['jruby.openssl.load.jars'].eql?('false')
|
7
|
+
version = JOpenSSL::BOUNCY_CASTLE_VERSION
|
8
|
+
begin
|
9
|
+
require 'jar-dependencies'
|
10
|
+
# if we have jar-dependencies we let it track the jars
|
11
|
+
require_jar 'org.bouncycastle', 'bcprov-jdk18on', version
|
12
|
+
require_jar 'org.bouncycastle', 'bcpkix-jdk18on', version
|
13
|
+
require_jar 'org.bouncycastle', 'bcutil-jdk18on', version
|
14
|
+
require_jar 'org.bouncycastle', 'bctls-jdk18on', version
|
15
|
+
bc_jars = true
|
16
|
+
rescue LoadError, RuntimeError
|
17
|
+
bc_jars = false
|
18
|
+
end
|
19
|
+
unless bc_jars
|
20
|
+
load "org/bouncycastle/bcprov-jdk18on/#{version}/bcprov-jdk18on-#{version}.jar"
|
21
|
+
load "org/bouncycastle/bcpkix-jdk18on/#{version}/bcpkix-jdk18on-#{version}.jar"
|
22
|
+
load "org/bouncycastle/bcutil-jdk18on/#{version}/bcutil-jdk18on-#{version}.jar"
|
23
|
+
load "org/bouncycastle/bctls-jdk18on/#{version}/bctls-jdk18on-#{version}.jar"
|
24
|
+
end
|
10
25
|
end
|
11
26
|
|
12
|
-
# Load extension
|
13
|
-
require 'jruby'
|
14
27
|
require 'jopenssl.jar'
|
15
|
-
org.jruby.ext.openssl.OSSLLibrary.new.load(JRuby.runtime, false)
|
16
28
|
|
17
|
-
if
|
18
|
-
|
19
|
-
else
|
20
|
-
load(
|
29
|
+
if JRuby::Util.respond_to?(:load_ext) # JRuby 9.2
|
30
|
+
JRuby::Util.load_ext('org.jruby.ext.openssl.OpenSSL')
|
31
|
+
else; require 'jruby'
|
32
|
+
org.jruby.ext.openssl.OpenSSL.load(JRuby.runtime)
|
33
|
+
end
|
34
|
+
|
35
|
+
if RUBY_VERSION > '2.3'
|
36
|
+
load 'jopenssl/_compat23.rb'
|
37
|
+
end
|
38
|
+
|
39
|
+
# NOTE: content bellow should live in *lib/openssl.rb* but due RubyGems/Bundler
|
40
|
+
# `autoload :OpenSSL` this will cause issues if an older version (0.11) is the
|
41
|
+
# default gem under JRuby 9.2 (which on auto-load does not trigger a dynamic
|
42
|
+
# require - this is only fixed in JRuby 9.3)
|
43
|
+
|
44
|
+
module OpenSSL
|
45
|
+
autoload :Config, 'openssl/config' unless const_defined?(:Config, false)
|
46
|
+
autoload :PKCS12, 'openssl/pkcs12'
|
21
47
|
end
|
22
48
|
|
23
|
-
|
49
|
+
=begin
|
50
|
+
= Info
|
51
|
+
'OpenSSL for Ruby 2' project
|
52
|
+
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
53
|
+
All rights reserved.
|
54
|
+
|
55
|
+
= Licence
|
56
|
+
This program is licensed under the same licence as Ruby.
|
57
|
+
(See the file 'LICENCE'.)
|
58
|
+
=end
|
59
|
+
|
60
|
+
require 'openssl/bn'
|
61
|
+
require 'openssl/pkey'
|
62
|
+
require 'openssl/cipher'
|
63
|
+
#require 'openssl/config' if OpenSSL.const_defined?(:Config, false)
|
64
|
+
require 'openssl/digest'
|
65
|
+
require 'openssl/hmac'
|
66
|
+
require 'openssl/x509'
|
67
|
+
require 'openssl/ssl'
|
68
|
+
require 'openssl/pkcs5'
|
69
|
+
|
70
|
+
module OpenSSL
|
71
|
+
# call-seq:
|
72
|
+
# OpenSSL.secure_compare(string, string) -> boolean
|
73
|
+
#
|
74
|
+
# Constant time memory comparison. Inputs are hashed using SHA-256 to mask
|
75
|
+
# the length of the secret. Returns +true+ if the strings are identical,
|
76
|
+
# +false+ otherwise.
|
77
|
+
def self.secure_compare(a, b)
|
78
|
+
hashed_a = OpenSSL::Digest.digest('SHA256', a)
|
79
|
+
hashed_b = OpenSSL::Digest.digest('SHA256', b)
|
80
|
+
OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
|
81
|
+
end
|
82
|
+
end
|
data/lib/jopenssl/version.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module JOpenSSL
|
2
|
+
VERSION = '0.14.0'
|
3
|
+
BOUNCY_CASTLE_VERSION = '1.71'
|
4
|
+
end
|
5
|
+
|
6
|
+
Object.class_eval do
|
7
|
+
Jopenssl = JOpenSSL
|
8
|
+
private_constant :Jopenssl if respond_to?(:private_constant)
|
9
|
+
deprecate_constant :Jopenssl if respond_to?(:deprecate_constant)
|
5
10
|
end
|
data/lib/jopenssl.jar
CHANGED
Binary file
|
data/lib/openssl/bn.rb
CHANGED
@@ -1,5 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#--
|
3
|
+
#
|
4
|
+
# = Ruby-space definitions that completes C-space funcs for BN
|
5
|
+
#
|
6
|
+
# = Info
|
7
|
+
# 'OpenSSL for Ruby 2' project
|
8
|
+
# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
9
|
+
# All rights reserved.
|
10
|
+
#
|
11
|
+
# = Licence
|
12
|
+
# This program is licensed under the same licence as Ruby.
|
13
|
+
# (See the file 'LICENCE'.)
|
14
|
+
#++
|
15
|
+
|
16
|
+
module OpenSSL
|
17
|
+
class BN
|
18
|
+
include Comparable
|
19
|
+
|
20
|
+
def pretty_print(q)
|
21
|
+
q.object_group(self) {
|
22
|
+
q.text ' '
|
23
|
+
q.text to_i.to_s
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end # BN
|
27
|
+
end # OpenSSL
|
28
|
+
|
29
|
+
##
|
30
|
+
#--
|
31
|
+
# Add double dispatch to Integer
|
32
|
+
#++
|
33
|
+
class Integer
|
34
|
+
# Casts an Integer as an OpenSSL::BN
|
35
|
+
#
|
36
|
+
# See `man bn` for more info.
|
37
|
+
def to_bn
|
38
|
+
OpenSSL::BN::new(self)
|
39
|
+
end
|
40
|
+
end # Integer
|