diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-01-16 12:12:29 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-01-16 12:12:29 +0000 |
commit | f9fedb332a1f46758b1014a6ccf999b57dd3ff54 (patch) | |
tree | 106bf198a3ebb480f24557f87e6c10c4e1987f32 /lib/openssl.rb | |
parent | 00aaf208f74d5933a2bb67604a30290b9e1a530a (diff) | |
download | ruby-openssl-history-f9fedb332a1f46758b1014a6ccf999b57dd3ff54.tar.gz |
* selfdipatch BN implementation (test only)
* removed strncasecmp (for WIN32 made alias to _strnicmp)
* fixed missing/strptime.c (Hynek Rostinsky)
Diffstat (limited to 'lib/openssl.rb')
-rw-r--r-- | lib/openssl.rb | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/openssl.rb b/lib/openssl.rb index 9952ae6..ea6975a 100644 --- a/lib/openssl.rb +++ b/lib/openssl.rb @@ -262,14 +262,38 @@ end # defined? RSA end # X509 class BN - def BN::new(arg) - BN::new_from_dec(arg.to_s) + def initialize(arg=nil, type="dec") + return if arg.nil? + t = arg.class + while t + t.name.downcase =~ /(\S*::)*(\S+)/ + method = "from_#{$2}".intern + return send(method, arg, type) if respond_to?(method, true) + t = t.superclass + end + raise "Don't how to init #{self.class.name} from #{arg.class}" + end + + def from_bn(arg, dummy=nil) + copy(arg) + end + + def from_integer(arg, type="dec") + from_string(arg.to_s, type) end + + def from_string(arg, type="dec") + send("from_#{type.downcase}", arg) + end + + private :from_bn, :from_integer, :from_string - alias :to_str :to_dec + def to_s(type="dec") + send("to_s_#{type.downcase}") + end def to_i - self.to_str.to_i + self.to_s.to_i end end # BN end # OpenSSL |