jruby-openssl 0.11.0-java → 0.13.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.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/History.md +43 -0
  3. data/Mavenfile +21 -26
  4. data/README.md +3 -0
  5. data/Rakefile +21 -35
  6. data/lib/jopenssl/load.rb +49 -14
  7. data/lib/jopenssl/version.rb +2 -1
  8. data/lib/jopenssl.jar +0 -0
  9. data/lib/openssl/bn.rb +40 -9
  10. data/lib/openssl/buffering.rb +478 -9
  11. data/lib/openssl/cipher.rb +67 -9
  12. data/lib/openssl/config.rb +496 -12
  13. data/lib/openssl/digest.rb +73 -9
  14. data/lib/openssl/hmac.rb +13 -0
  15. data/lib/openssl/marshal.rb +30 -0
  16. data/lib/openssl/pkcs5.rb +3 -3
  17. data/lib/openssl/pkey.rb +42 -5
  18. data/lib/openssl/ssl.rb +543 -9
  19. data/lib/openssl/x509.rb +369 -9
  20. data/lib/openssl.rb +3 -1
  21. data/pom.xml +38 -129
  22. metadata +9 -44
  23. data/lib/jopenssl19/openssl/bn.rb +0 -29
  24. data/lib/jopenssl19/openssl/buffering.rb +0 -449
  25. data/lib/jopenssl19/openssl/cipher.rb +0 -28
  26. data/lib/jopenssl19/openssl/config.rb +0 -472
  27. data/lib/jopenssl19/openssl/digest.rb +0 -32
  28. data/lib/jopenssl19/openssl/ssl-internal.rb +0 -223
  29. data/lib/jopenssl19/openssl/ssl.rb +0 -2
  30. data/lib/jopenssl19/openssl/x509-internal.rb +0 -115
  31. data/lib/jopenssl19/openssl/x509.rb +0 -2
  32. data/lib/jopenssl19/openssl.rb +0 -22
  33. data/lib/jopenssl21/openssl/bn.rb +0 -28
  34. data/lib/jopenssl21/openssl/buffering.rb +0 -1
  35. data/lib/jopenssl21/openssl/cipher.rb +0 -1
  36. data/lib/jopenssl21/openssl/config.rb +0 -1
  37. data/lib/jopenssl21/openssl/digest.rb +0 -1
  38. data/lib/jopenssl21/openssl/ssl.rb +0 -1
  39. data/lib/jopenssl21/openssl/x509.rb +0 -119
  40. data/lib/jopenssl21/openssl.rb +0 -22
  41. data/lib/jopenssl22/openssl/bn.rb +0 -39
  42. data/lib/jopenssl22/openssl/buffering.rb +0 -456
  43. data/lib/jopenssl22/openssl/cipher.rb +0 -28
  44. data/lib/jopenssl22/openssl/config.rb +0 -313
  45. data/lib/jopenssl22/openssl/digest.rb +0 -54
  46. data/lib/jopenssl22/openssl/ssl.rb +0 -330
  47. data/lib/jopenssl22/openssl/x509.rb +0 -139
  48. data/lib/jopenssl22/openssl.rb +0 -22
  49. data/lib/jopenssl23/openssl/bn.rb +0 -38
  50. data/lib/jopenssl23/openssl/buffering.rb +0 -455
  51. data/lib/jopenssl23/openssl/cipher.rb +0 -25
  52. data/lib/jopenssl23/openssl/config.rb +0 -474
  53. data/lib/jopenssl23/openssl/digest.rb +0 -43
  54. data/lib/jopenssl23/openssl/pkey.rb +0 -25
  55. data/lib/jopenssl23/openssl/ssl.rb +0 -508
  56. data/lib/jopenssl23/openssl/x509.rb +0 -208
  57. data/lib/jopenssl23/openssl.rb +0 -19
  58. data/lib/openssl/ssl-internal.rb +0 -5
  59. data/lib/openssl/x509-internal.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3b0af65b0a40658f2bfafdd3d8a6bd3112dd0c13
4
- data.tar.gz: a5d16510be892effe0c7e3004823136f5eaaf196
2
+ SHA256:
3
+ metadata.gz: 84f4d596b14dec42d317e4dbce655038025b0fd08901240b63400db474afd86c
4
+ data.tar.gz: b7413e3da9dd4afda4f79093bc5d9993d79286ba34297b2a5256e7ae05b779d4
5
5
  SHA512:
6
- metadata.gz: 14b8ac25affa194b9de7637468d1cf73934c99d6eaa35e6d1882de3e42aaaba27c86409423850c23b9f554f21d6bb9fc64688655de32361723ef9a1cd469df5a
7
- data.tar.gz: 48cb81a70fd513ffec64a8eea55132eaaa244e61c0a1b809e7fbc32650eb8960345c4b3d527b30e0927a0158d736026d764b23dd2857982c29682e366dd11ec0
6
+ metadata.gz: c78e50af357bf7adcdaac3ee38b437d17a7a83b98d664cc48dec957828b5e3aa15bb4378900a9796e7efe6f94fd1e3dbc54843e48fa1a4fe9a5b5f73806a4709
7
+ data.tar.gz: b0a8990ed96db10431e440f1f2551686efa4cc04d902a5ecdc89ec5b11c81fc5b9f814da50d0bd74ae8bcb9bcd0fa8726494f4f1912cc2d5455dad6197ac4303
data/History.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## 0.13.0
2
+
3
+ * [fix] ASN1::EndOfContent ancestor hierarchy (#228)
4
+ * [fix] handle X509::Name type conversion (#206)
5
+ * [fix] handle invalid type when creating `X509::Name`
6
+ * [fix] `OpenSSL::X509::Name#inspect` compatibility
7
+ * [fix] escaping with `OpenSSL::X509::Name::RFC2253`
8
+ * [feat] implement `OpenSSL::X509::Name#to_utf8`
9
+ * [fix] compat missing `OpenSSL::SSL::OP_NO_TLSv1_3`
10
+ * [refactor] performance - do not encode/decode cert objects
11
+ * [fix] make sure `Context.ciphers` are not mutated (#219)
12
+ * [feat] support `to_java` conversion for CRL
13
+ * [feat] support `to_java` protocol for PKey (#250)
14
+
15
+ ## 0.12.2
16
+
17
+ * [fix] work-around JRuby 9.2 autoload behavior (#248)
18
+ to be able to install jruby-openssl >= 0.12 on JRuby 9.2
19
+ while the default gem (shipped with JRuby) is < 0.12
20
+ * [feat] support alpn negotiation in ssl context (#247)
21
+ * [feat] support Java cipher names on `SSLContext#ciphers=`
22
+ * [fix] properly handle `require_jar` fallback
23
+
24
+ ## 0.12.1
25
+
26
+ * improved compatibility with the openssl gem (version 2.2.1)
27
+ * JOSSL now ships with a single set of openssl .rb files
28
+ - providing compat with `required_ruby_version = '>= 2.3.0'`
29
+ - flat set of .rb files at *lib/openssl/* (based on openssl gem)
30
+ * revisited `OpenSSL::SSL::SSLContext::DEFAULT_PARAMS` defaults
31
+ - implicit `verify_hostname` default .rb callback still a noop
32
+ - TLS continues to rely on the Java SSL engine for hostname checks
33
+ * working TLS 1.3 support
34
+ * droped Java 1.7 support (at least Java 8 needed to use the gem)
35
+ * fixed `SSLContext#options` matches C OpenSSL (using `OP_ALL`)
36
+ * no longer filter out SSLv2 (for improved OpenSSL compatibility)
37
+ * implemented naive `SSLContext#ciphers` caching to speed-up TLS
38
+ * `StoreError` raised due a Java exception now retain native cause
39
+
40
+ ## 0.12.0 (yanked)
41
+
42
+ There were Java 8 and JRuby 9.3 regressions in this release, use 0.12.1 instead.
43
+
1
44
  ## 0.11.0
2
45
 
3
46
  NOTE: This release aims to adapt the certificate verification logic to be aligned
data/Mavenfile CHANGED
@@ -7,7 +7,7 @@ distribution_management do
7
7
  repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
8
8
  end
9
9
 
10
- java_target = '1.7'
10
+ java_target = '1.8'
11
11
  gen_sources = '${basedir}/target/generated-sources' # hard-coded in AnnotationBinder
12
12
 
13
13
  plugin( 'org.codehaus.mojo:exec-maven-plugin', '1.3.2' ) do
@@ -45,15 +45,18 @@ plugin( 'org.codehaus.mojo:build-helper-maven-plugin', '1.9' ) do
45
45
  execute_goal 'add-source', :phase => 'process-classes', :sources => [ gen_sources ]
46
46
  end
47
47
 
48
- plugin( :compiler, '3.1',
49
- :source => '1.7', :target => java_target,
50
- :encoding => 'UTF-8', :debug => true,
51
- :showWarnings => true, :showDeprecation => true,
52
- :excludes => [ 'module-info.java' ],
53
- #:jdkToolchain => { :version => '[1.7,11)' },
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'
54
58
 
55
- :generatedSourcesDirectory => gen_sources,
56
- :annotationProcessors => [ 'org.jruby.anno.AnnotationBinder' ]) do
59
+ plugin( :compiler, '3.9.0', compiler_configuration) do
57
60
 
58
61
  #execute_goal :compile, :id => 'annotation-binder', :phase => 'compile',
59
62
  # :generatedSourcesDirectory => gen_sources, #:outputDirectory => gen_sources,
@@ -69,14 +72,6 @@ plugin( :compiler, '3.1',
69
72
  :compilerArgs => [ '', '-XDignore.symbol.file=true' ]
70
73
  end
71
74
 
72
- profile 'module-info' do
73
- activation { jdk '[9,)' }
74
- plugin :compiler, '3.8.1',
75
- :source => '9', :target => java_target,
76
- :release => '9',
77
- :includes => [ 'module-info.java' ]
78
- end
79
-
80
75
  plugin :clean do
81
76
  execute_goals( 'clean', :id => 'default-clean', :phase => 'clean',
82
77
  'filesets' => [
@@ -87,18 +82,18 @@ plugin :clean do
87
82
  'failOnError' => 'false' )
88
83
  end
89
84
 
90
- jar 'org.jruby:jruby-core', '1.7.20', :scope => :provided
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
91
88
  jar 'junit:junit', '[4.13.1,)', :scope => :test
92
89
 
93
- # 9.1.17.0 is Java 7 compatible (till supporting JRuby 1.7)
94
90
  # NOTE: to build on Java 11 - installing gems fails (due old jossl) with:
95
91
  # load error: jopenssl/load -- java.lang.StringIndexOutOfBoundsException
96
- MVN_JRUBY_VERSION = ENV_JAVA['java.version'].to_i >= 9 ? '9.2.9.0' : '9.1.17.0'
92
+ MVN_JRUBY_VERSION = ENV_JAVA['java.version'].to_i >= 9 ? '9.2.19.0' : '9.1.17.0'
97
93
 
98
94
  jruby_plugin! :gem do
99
95
  # when installing dependent gems we want to use the built in openssl not the one from this lib directory
100
- # we compile against jruby-core-1.7.20 and want to keep this out of the plugin execution here
101
- execute_goal :id => 'default-initialize', :addProjectClasspath => false, :libDirectory => 'something-which-does-not-exists'
96
+ execute_goal :id => 'default-package', :addProjectClasspath => false, :libDirectory => 'something-which-does-not-exists'
102
97
  execute_goals :id => 'default-push', :skip => true
103
98
  end
104
99
 
@@ -107,12 +102,12 @@ plugin :deploy, '2.8.1' do
107
102
  execute_goals( :deploy, :skip => false )
108
103
  end
109
104
 
110
- supported_bc_versions = %w{ 1.58 1.59 1.60 1.61 1.62 1.63 1.64 1.65 }
105
+ supported_bc_versions = %w{ 1.60 1.61 1.62 1.63 1.64 1.65 1.66 1.67 1.68 }
111
106
 
112
107
  default_bc_version = File.read File.expand_path('lib/jopenssl/version.rb', File.dirname(__FILE__))
113
108
  default_bc_version = default_bc_version[/BOUNCY_CASTLE_VERSION\s?=\s?'(.*?)'/, 1]
114
109
 
115
- properties( 'jruby.plugins.version' => '1.1.8',
110
+ properties( 'jruby.plugins.version' => '2.0.1', # 2.0.1
116
111
  'jruby.switches' => '-W0', # https://github.com/torquebox/jruby-maven-plugins/issues/94
117
112
  'bc.versions' => default_bc_version,
118
113
  'invoker.test' => '${bc.versions}',
@@ -151,8 +146,8 @@ invoker_run_options = {
151
146
  'runit.dir' => '${runit.dir}' }
152
147
  }
153
148
 
154
- jruby_9_K_versions = %w{ 9.0.5.0 9.1.2.0 9.1.8.0 9.1.12.0 9.1.16.0 9.1.17.0 }
155
- jruby_9_K_versions += %w{ 9.2.0.0 9.2.5.0 9.2.6.0 9.2.7.0 9.2.8.0 9.2.9.0 }
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 }
156
151
 
157
152
  jruby_9_K_versions.each { |version|
158
153
  profile :id => "test-#{version}" do
data/README.md CHANGED
@@ -24,6 +24,9 @@ the JRuby [mailing list][1] or the [bug tracker][2].
24
24
  | ~>0.9.18 | 1.6.8-9.1.x | Java 6-8 | 1.50-1.55 |
25
25
  | 0.10.0 | 1.7.20-9.2.x | Java 7-10 | 1.55-1.59 |
26
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 |
27
30
 
28
31
  NOTE: backwards JRuby compatibility was not handled for versions <= **0.9.6**
29
32
 
data/Rakefile CHANGED
@@ -1,40 +1,27 @@
1
1
  #-*- mode: ruby -*-
2
2
 
3
- begin
4
- require 'ruby-maven'
5
- rescue LoadError
6
- warn "ruby-maven not available - some tasks will not work " <<
7
- "either `gem install ruby-maven' or use mvn instead of rake"
8
- desc "Package jopenssl.jar with the compiled classes"
9
- task :jar do
10
- sh "mvn prepare-package -Dmaven.test.skip=true"
11
- end
12
- namespace :jar do
13
- desc "Package jopenssl.jar file (and dependendent jars)"
14
- task :all do
15
- sh "mvn package -Dmaven.test.skip=true"
16
- end
17
- end
18
- else
19
- #Rake::Task[:jar].clear rescue nil
20
- desc "Package jopenssl.jar with the compiled classes"
21
- task :jar do
22
- RubyMaven.exec( 'prepare-package -Dmaven.test.skip=true' )
23
- end
24
- namespace :jar do
25
- desc "Package jopenssl.jar file (and dependendent jars)"
26
- task :all do
27
- RubyMaven.exec( 'package -Dmaven.test.skip=true' )
28
- end
29
- end
30
- task :test_prepare do
31
- RubyMaven.exec( 'prepare-package -Dmaven.test.skip=true' )
32
- RubyMaven.exec( 'test-compile' ) # separate step due -Dmaven.test.skip=true
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' )
33
12
  end
34
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
18
+
19
+ task :clean do
20
+ sh( './mvnw clean' )
21
+ end
35
22
 
36
23
  task :build do
37
- RubyMaven.exec('package -Dmaven.test.skip')
24
+ sh( './mvnw clean package -Dmaven.test.skip=true' )
38
25
  end
39
26
 
40
27
  task :default => :build
@@ -55,16 +42,15 @@ task :test => 'lib/jopenssl.jar'
55
42
  namespace :integration do
56
43
  it_path = File.expand_path('../src/test/integration', __FILE__)
57
44
  task :install do
58
- Dir.chdir(it_path) do
59
- ruby "-S bundle install --gemfile '#{it_path}/Gemfile'"
60
- end
45
+ ruby "-C #{it_path} -S bundle install"
61
46
  end
62
47
  # desc "Run IT tests"
63
48
  task :test => 'lib/jopenssl.jar' do
64
49
  unless File.exist?(File.join(it_path, 'Gemfile.lock'))
65
50
  raise "bundle not installed, run `rake integration:install'"
66
51
  end
67
- loader = "ARGV.each { |f| require f }" ; lib = [ 'lib', it_path ]
52
+ loader = "ARGV.each { |f| require f }"
53
+ lib = [ File.expand_path('../lib', __FILE__), it_path ]
68
54
  test_files = FileList['src/test/integration/*_test.rb'].map { |path| path.sub('src/test/integration/', '') }
69
55
  ruby "-I#{lib.join(':')} -C src/test/integration -e \"#{loader}\" #{test_files.map { |f| "\"#{f}\"" }.join(' ')}"
70
56
  end
data/lib/jopenssl/load.rb CHANGED
@@ -2,20 +2,22 @@ warn 'Loading jruby-openssl gem in a non-JRuby interpreter' unless defined? JRUB
2
2
 
3
3
  require 'jopenssl/version'
4
4
 
5
- warn "JRuby #{JRUBY_VERSION} is not supported by jruby-openssl #{JOpenSSL::VERSION}" if JRUBY_VERSION < '1.7.20'
6
-
7
5
  # NOTE: assuming user does pull in BC .jars from somewhere else on the CP
8
6
  unless ENV_JAVA['jruby.openssl.load.jars'].eql?('false')
9
7
  version = JOpenSSL::BOUNCY_CASTLE_VERSION
10
- bc_jars = nil
11
8
  begin
12
9
  require 'jar-dependencies'
13
10
  # if we have jar-dependencies we let it track the jars
14
- require_jar( 'org.bouncycastle', 'bcprov-jdk15on', version )
15
- require_jar( 'org.bouncycastle', 'bcpkix-jdk15on', version )
16
- require_jar( 'org.bouncycastle', 'bctls-jdk15on', version )
11
+ require_jar 'org.bouncycastle', 'bcprov-jdk15on', version
12
+ require_jar 'org.bouncycastle', 'bcpkix-jdk15on', version
13
+ require_jar 'org.bouncycastle', 'bctls-jdk15on', version
14
+ begin # bcutil got extracted from bcprov in BC 1.69
15
+ require_jar 'org.bouncycastle', 'bcutil-jdk15to18', version
16
+ rescue LoadError, RuntimeError
17
+ # continue without loading the jar - assume we got BC < 1.69
18
+ end
17
19
  bc_jars = true
18
- rescue LoadError
20
+ rescue LoadError, RuntimeError
19
21
  bc_jars = false
20
22
  end
21
23
  unless bc_jars
@@ -34,17 +36,50 @@ else; require 'jruby'
34
36
  end
35
37
 
36
38
  if RUBY_VERSION > '2.3'
37
- load 'jopenssl23/openssl.rb'
38
39
  load 'jopenssl/_compat23.rb'
39
- elsif RUBY_VERSION > '2.2'
40
- load 'jopenssl22/openssl.rb'
41
- elsif RUBY_VERSION > '2.1'
42
- load 'jopenssl21/openssl.rb'
43
- else
44
- load 'jopenssl19/openssl.rb'
45
40
  end
46
41
 
42
+ # NOTE: content bellow should live in *lib/openssl.rb* but due RubyGems/Bundler
43
+ # `autoload :OpenSSL` this will cause issues if an older version (0.11) is the
44
+ # default gem under JRuby 9.2 (which on auto-load does not trigger a dynamic
45
+ # require - this is only fixed in JRuby 9.3)
46
+
47
47
  module OpenSSL
48
48
  autoload :Config, 'openssl/config' unless const_defined?(:Config, false)
49
49
  autoload :PKCS12, 'openssl/pkcs12'
50
50
  end
51
+
52
+ =begin
53
+ = Info
54
+ 'OpenSSL for Ruby 2' project
55
+ Copyright (C) 2002 Michal Rokos <[email protected]>
56
+ All rights reserved.
57
+
58
+ = Licence
59
+ This program is licensed under the same licence as Ruby.
60
+ (See the file 'LICENCE'.)
61
+ =end
62
+
63
+ require 'openssl/bn'
64
+ require 'openssl/pkey'
65
+ require 'openssl/cipher'
66
+ #require 'openssl/config' if OpenSSL.const_defined?(:Config, false)
67
+ require 'openssl/digest'
68
+ require 'openssl/hmac'
69
+ require 'openssl/x509'
70
+ require 'openssl/ssl'
71
+ require 'openssl/pkcs5'
72
+
73
+ module OpenSSL
74
+ # call-seq:
75
+ # OpenSSL.secure_compare(string, string) -> boolean
76
+ #
77
+ # Constant time memory comparison. Inputs are hashed using SHA-256 to mask
78
+ # the length of the secret. Returns +true+ if the strings are identical,
79
+ # +false+ otherwise.
80
+ def self.secure_compare(a, b)
81
+ hashed_a = OpenSSL::Digest.digest('SHA256', a)
82
+ hashed_b = OpenSSL::Digest.digest('SHA256', b)
83
+ OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
84
+ end
85
+ end
@@ -1,9 +1,10 @@
1
1
  module JOpenSSL
2
- VERSION = '0.11.0'
2
+ VERSION = '0.13.0'
3
3
  BOUNCY_CASTLE_VERSION = '1.68'
4
4
  end
5
5
 
6
6
  Object.class_eval do
7
7
  Jopenssl = JOpenSSL
8
8
  private_constant :Jopenssl if respond_to?(:private_constant)
9
+ deprecate_constant :Jopenssl if respond_to?(:deprecate_constant)
9
10
  end
data/lib/jopenssl.jar CHANGED
Binary file
data/lib/openssl/bn.rb CHANGED
@@ -1,9 +1,40 @@
1
- if RUBY_VERSION > '2.3'
2
- load "jopenssl23/openssl/#{File.basename(__FILE__)}"
3
- elsif RUBY_VERSION > '2.2'
4
- load "jopenssl22/openssl/#{File.basename(__FILE__)}"
5
- elsif RUBY_VERSION > '2.1'
6
- load "jopenssl21/openssl/#{File.basename(__FILE__)}"
7
- else
8
- load "jopenssl19/openssl/#{File.basename(__FILE__)}"
9
- end
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.[email protected]>
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