jruby-openssl 0.9.5-java → 0.9.6-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.
@@ -14,16 +14,6 @@
14
14
  $Id$
15
15
  =end
16
16
 
17
- ##
18
- # Should we care what if somebody require this file directly?
19
- #require 'openssl'
20
-
21
- module OpenSSL
22
- class BN
23
- include Comparable
24
- end # BN
25
- end # OpenSSL
26
-
27
17
  ##
28
18
  # Add double dispatch to Integer
29
19
  #
@@ -20,46 +20,9 @@
20
20
 
21
21
  module OpenSSL
22
22
  class Cipher
23
- %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
24
- klass = Class.new(Cipher){
25
- define_method(:initialize){|*args|
26
- cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
27
- super(cipher_name)
28
- }
29
- }
30
- const_set(name, klass)
31
- }
32
-
33
- %w(128 192 256).each{|keylen|
34
- klass = Class.new(Cipher){
35
- define_method(:initialize){|mode|
36
- mode ||= "CBC"
37
- cipher_name = "AES-#{keylen}-#{mode}"
38
- super(cipher_name)
39
- }
40
- }
41
- const_set("AES#{keylen}", klass)
42
- }
43
-
44
- # Generate, set, and return a random key.
45
- # You must call cipher.encrypt or cipher.decrypt before calling this method.
46
- def random_key
47
- str = OpenSSL::Random.random_bytes(self.key_len)
48
- self.key = str
49
- return str
50
- end
51
-
52
- # Generate, set, and return a random iv.
53
- # You must call cipher.encrypt or cipher.decrypt before calling this method.
54
- def random_iv
55
- str = OpenSSL::Random.random_bytes(self.iv_len)
56
- self.iv = str
57
- return str
58
- end
59
-
60
23
  # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
61
24
  class Cipher < Cipher
62
25
  # add warning
63
26
  end
64
27
  end # Cipher
65
- end # OpenSSL
28
+ end # OpenSSL
@@ -20,34 +20,6 @@
20
20
 
21
21
  module OpenSSL
22
22
  class Digest
23
-
24
- alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
25
- if OPENSSL_VERSION_NUMBER > 0x00908000
26
- alg += %w(SHA224 SHA256 SHA384 SHA512)
27
- end
28
-
29
- def self.digest(name, data)
30
- super(data, name)
31
- end
32
-
33
- alg.each{|name|
34
- klass = Class.new(Digest){
35
- define_method(:initialize){|*data|
36
- if data.length > 1
37
- raise ArgumentError,
38
- "wrong number of arguments (#{data.length} for 1)"
39
- end
40
- super(name, data.first)
41
- }
42
- }
43
- singleton = (class << klass; self; end)
44
- singleton.class_eval{
45
- define_method(:digest){|data| Digest.digest(name, data) }
46
- define_method(:hexdigest){|data| Digest.hexdigest(name, data) }
47
- }
48
- const_set(name, klass)
49
- }
50
-
51
23
  # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
52
24
  class Digest < Digest
53
25
  def initialize(*args)
@@ -55,7 +27,6 @@ module OpenSSL
55
27
  super(*args)
56
28
  end
57
29
  end
58
-
59
30
  end # Digest
60
31
  end # OpenSSL
61
32
 
@@ -19,34 +19,6 @@ require "fcntl"
19
19
 
20
20
  module OpenSSL
21
21
  module SSL
22
- class SSLContext
23
- DEFAULT_PARAMS = {
24
- :ssl_version => "SSLv23",
25
- :verify_mode => OpenSSL::SSL::VERIFY_PEER,
26
- :ciphers => "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW",
27
- :options => OpenSSL::SSL::OP_ALL,
28
- }
29
-
30
- DEFAULT_CERT_STORE = OpenSSL::X509::Store.new
31
- DEFAULT_CERT_STORE.set_default_paths
32
- if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL)
33
- DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
34
- end
35
-
36
- def set_params(params={})
37
- params = DEFAULT_PARAMS.merge(params)
38
- # ssl_version need to be set at first.
39
- self.ssl_version = params.delete(:ssl_version)
40
- params.each{|name, value| self.__send__("#{name}=", value) }
41
- if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
42
- unless self.ca_file or self.ca_path or self.cert_store
43
- self.cert_store = DEFAULT_CERT_STORE
44
- end
45
- end
46
- return params
47
- end
48
- end
49
-
50
22
  module SocketForwarder
51
23
  def addr
52
24
  to_io.addr
@@ -95,7 +67,11 @@ module OpenSSL
95
67
  should_verify_common_name = false
96
68
  reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
97
69
  return true if /\A#{reg}\z/i =~ hostname
98
- elsif /\AIP Address:(.*)/ =~ general_name
70
+ # NOTE: somehow we need the IP: canonical form
71
+ # seems there were failures elsewhere when not
72
+ # not sure how that's possible possible to-do!
73
+ elsif /\AIP(?: Address)?:(.*)/ =~ general_name
74
+ #elsif /\AIP Address:(.*)/ =~ general_name
99
75
  should_verify_common_name = false
100
76
  return true if $1 == hostname
101
77
  end
@@ -16,49 +16,6 @@
16
16
 
17
17
  module OpenSSL
18
18
  module X509
19
- class ExtensionFactory
20
- def create_extension(*arg)
21
- if arg.size > 1
22
- create_ext(*arg)
23
- else
24
- send("create_ext_from_"+arg[0].class.name.downcase, arg[0])
25
- end
26
- end
27
-
28
- def create_ext_from_array(ary)
29
- raise ExtensionError, "unexpected array form" if ary.size > 3
30
- create_ext(ary[0], ary[1], ary[2])
31
- end
32
-
33
- def create_ext_from_string(str) # "oid = critical, value"
34
- oid, value = str.split(/=/, 2)
35
- oid.strip!
36
- value.strip!
37
- create_ext(oid, value)
38
- end
39
-
40
- def create_ext_from_hash(hash)
41
- create_ext(hash["oid"], hash["value"], hash["critical"])
42
- end
43
- end
44
-
45
- class Extension
46
- def to_s # "oid = critical, value"
47
- str = self.oid
48
- str << " = "
49
- str << "critical, " if self.critical?
50
- str << self.value.gsub(/\n/, ", ")
51
- end
52
-
53
- def to_h # {"oid"=>sn|ln, "value"=>value, "critical"=>true|false}
54
- {"oid"=>self.oid,"value"=>self.value,"critical"=>self.critical?}
55
- end
56
-
57
- def to_a
58
- [ self.oid, self.value, self.critical? ]
59
- end
60
- end
61
-
62
19
  class Name
63
20
  module RFC2253DN
64
21
  Special = ',=+<>#;'
@@ -20,4 +20,3 @@ require 'openssl/config'
20
20
  require 'openssl/digest'
21
21
  require 'openssl/ssl-internal'
22
22
  require 'openssl/x509-internal'
23
- require 'krypt/ossl'
@@ -3,33 +3,27 @@
3
3
  # $RCSfile$
4
4
  #
5
5
  # = Ruby-space definitions that completes C-space funcs for BN
6
- #
6
+ #
7
7
  # = Info
8
8
  # 'OpenSSL for Ruby 2' project
9
9
  # Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # = Licence
13
13
  # This program is licenced under the same licence as Ruby.
14
14
  # (See the file 'LICENCE'.)
15
- #
15
+ #
16
16
  # = Version
17
17
  # $Id$
18
18
  #
19
19
  #++
20
20
 
21
- module OpenSSL
22
- class BN
23
- include Comparable
24
- end # BN
25
- end # OpenSSL
26
-
27
21
  ##
28
22
  # Add double dispatch to Integer
29
23
  #
30
24
  class Integer
31
25
  def to_bn
32
- OpenSSL::BN::new(self.to_s(16), 16)
26
+ OpenSSL::BN::new(self)
33
27
  end
34
28
  end # Integer
35
29
 
@@ -3,16 +3,16 @@
3
3
  # $RCSfile$
4
4
  #
5
5
  # = Ruby-space predefined Cipher subclasses
6
- #
6
+ #
7
7
  # = Info
8
8
  # 'OpenSSL for Ruby 2' project
9
9
  # Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # = Licence
13
13
  # This program is licenced under the same licence as Ruby.
14
14
  # (See the file 'LICENCE'.)
15
- #
15
+ #
16
16
  # = Version
17
17
  # $Id$
18
18
  #
@@ -20,46 +20,9 @@
20
20
 
21
21
  module OpenSSL
22
22
  class Cipher
23
- %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
24
- klass = Class.new(Cipher){
25
- define_method(:initialize){|*args|
26
- cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
27
- super(cipher_name)
28
- }
29
- }
30
- const_set(name, klass)
31
- }
32
-
33
- %w(128 192 256).each{|keylen|
34
- klass = Class.new(Cipher){
35
- define_method(:initialize){|mode|
36
- mode ||= "CBC"
37
- cipher_name = "AES-#{keylen}-#{mode}"
38
- super(cipher_name)
39
- }
40
- }
41
- const_set("AES#{keylen}", klass)
42
- }
43
-
44
- # Generate, set, and return a random key.
45
- # You must call cipher.encrypt or cipher.decrypt before calling this method.
46
- def random_key
47
- str = OpenSSL::Random.random_bytes(self.key_len)
48
- self.key = str
49
- return str
50
- end
51
-
52
- # Generate, set, and return a random iv.
53
- # You must call cipher.encrypt or cipher.decrypt before calling this method.
54
- def random_iv
55
- str = OpenSSL::Random.random_bytes(self.iv_len)
56
- self.iv = str
57
- return str
58
- end
59
-
60
23
  # This class is only provided for backwards compatibility. Use OpenSSL::Cipher in the future.
61
24
  class Cipher < Cipher
62
25
  # add warning
63
26
  end
64
27
  end # Cipher
65
- end # OpenSSL
28
+ end # OpenSSL
@@ -3,16 +3,16 @@
3
3
  # $RCSfile$
4
4
  #
5
5
  # = Ruby-space predefined Digest subclasses
6
- #
6
+ #
7
7
  # = Info
8
8
  # 'OpenSSL for Ruby 2' project
9
9
  # Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # = Licence
13
13
  # This program is licenced under the same licence as Ruby.
14
14
  # (See the file 'LICENCE'.)
15
- #
15
+ #
16
16
  # = Version
17
17
  # $Id$
18
18
  #
@@ -20,45 +20,6 @@
20
20
 
21
21
  module OpenSSL
22
22
  class Digest
23
-
24
- alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
25
- if OPENSSL_VERSION_NUMBER > 0x00908000
26
- alg += %w(SHA224 SHA256 SHA384 SHA512)
27
- end
28
-
29
- # Return the +data+ hash computed with +name+ Digest. +name+ is either the
30
- # long name or short name of a supported digest algorithm.
31
- #
32
- # === Examples
33
- #
34
- # OpenSSL::Digest.digest("SHA256, "abc")
35
- #
36
- # which is equivalent to:
37
- #
38
- # OpenSSL::Digest::SHA256.digest("abc")
39
-
40
- def self.digest(name, data)
41
- super(data, name)
42
- end
43
-
44
- alg.each{|name|
45
- klass = Class.new(Digest){
46
- define_method(:initialize){|*data|
47
- if data.length > 1
48
- raise ArgumentError,
49
- "wrong number of arguments (#{data.length} for 1)"
50
- end
51
- super(name, data.first)
52
- }
53
- }
54
- singleton = (class << klass; self; end)
55
- singleton.class_eval{
56
- define_method(:digest){|data| Digest.digest(name, data) }
57
- define_method(:hexdigest){|data| Digest.hexdigest(name, data) }
58
- }
59
- const_set(name, klass)
60
- }
61
-
62
23
  # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
63
24
  class Digest < Digest
64
25
  def initialize(*args)
@@ -66,7 +27,6 @@ module OpenSSL
66
27
  super(*args)
67
28
  end
68
29
  end
69
-
70
30
  end # Digest
71
31
  end # OpenSSL
72
32
 
@@ -19,32 +19,6 @@ require "fcntl"
19
19
 
20
20
  module OpenSSL
21
21
  module SSL
22
- class SSLContext
23
- DEFAULT_PARAMS = {
24
- :ssl_version => "SSLv23",
25
- :verify_mode => OpenSSL::SSL::VERIFY_PEER,
26
- :ciphers => "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW",
27
- :options => OpenSSL::SSL::OP_ALL,
28
- }
29
-
30
- DEFAULT_CERT_STORE = OpenSSL::X509::Store.new
31
- DEFAULT_CERT_STORE.set_default_paths
32
- if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL)
33
- DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
34
- end
35
-
36
- def set_params(params={})
37
- params = DEFAULT_PARAMS.merge(params)
38
- params.each{|name, value| self.__send__("#{name}=", value) }
39
- if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
40
- unless self.ca_file or self.ca_path or self.cert_store
41
- self.cert_store = DEFAULT_CERT_STORE
42
- end
43
- end
44
- return params
45
- end
46
- end
47
-
48
22
  module SocketForwarder
49
23
  def addr
50
24
  to_io.addr
@@ -93,7 +67,11 @@ module OpenSSL
93
67
  should_verify_common_name = false
94
68
  reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
95
69
  return true if /\A#{reg}\z/i =~ hostname
96
- elsif /\AIP Address:(.*)/ =~ general_name
70
+ # NOTE: somehow we need the IP: canonical form
71
+ # seems there were failures elsewhere when not
72
+ # not sure how that's possible possible to-do!
73
+ elsif /\AIP(?: Address)?:(.*)/ =~ general_name
74
+ #elsif /\AIP Address:(.*)/ =~ general_name
97
75
  should_verify_common_name = false
98
76
  return true if $1 == hostname
99
77
  end
@@ -16,49 +16,6 @@
16
16
 
17
17
  module OpenSSL
18
18
  module X509
19
- class ExtensionFactory
20
- def create_extension(*arg)
21
- if arg.size > 1
22
- create_ext(*arg)
23
- else
24
- send("create_ext_from_"+arg[0].class.name.downcase, arg[0])
25
- end
26
- end
27
-
28
- def create_ext_from_array(ary)
29
- raise ExtensionError, "unexpected array form" if ary.size > 3
30
- create_ext(ary[0], ary[1], ary[2])
31
- end
32
-
33
- def create_ext_from_string(str) # "oid = critical, value"
34
- oid, value = str.split(/=/, 2)
35
- oid.strip!
36
- value.strip!
37
- create_ext(oid, value)
38
- end
39
-
40
- def create_ext_from_hash(hash)
41
- create_ext(hash["oid"], hash["value"], hash["critical"])
42
- end
43
- end
44
-
45
- class Extension
46
- def to_s # "oid = critical, value"
47
- str = self.oid
48
- str << " = "
49
- str << "critical, " if self.critical?
50
- str << self.value.gsub(/\n/, ", ")
51
- end
52
-
53
- def to_h # {"oid"=>sn|ln, "value"=>value, "critical"=>true|false}
54
- {"oid"=>self.oid,"value"=>self.value,"critical"=>self.critical?}
55
- end
56
-
57
- def to_a
58
- [ self.oid, self.value, self.critical? ]
59
- end
60
- end
61
-
62
19
  class Name
63
20
  module RFC2253DN
64
21
  Special = ',=+<>#;'