Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in "builtin" SSL support from jruby-ossl library.
Squashed commit of the following: commit acfe60c Merge: 6e45697 27868fe Author: Charles Oliver Nutter <headius@headius.com> Date: Sat Apr 28 10:00:13 2012 -0500 Merge remote-tracking branch 'origin/master' into builtin_ssl commit 6e45697 Author: Charles Oliver Nutter <headius@headius.com> Date: Sat Apr 28 09:57:38 2012 -0500 Move OpenSSL .rb files under 1.8 lib and import 1.9 files. commit 79b52ff Author: Charles Oliver Nutter <headius@headius.com> Date: Sat Apr 28 09:51:30 2012 -0500 A few minor fixes for a large number of SSL test failures. commit 81fc6eb Merge: 185faa0 ab2fd75 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Apr 26 23:40:22 2012 -0500 Merge branch 'master' into builtin_ssl commit 185faa0 Author: Charles Oliver Nutter <headius@headius.com> Date: Sat Apr 7 10:43:23 2012 -0500 Remove old OpenSSL stubs, fix OSSL version, basic tests passing. commit 3dabec5 Author: Charles Oliver Nutter <headius@headius.com> Date: Fri Apr 6 16:58:13 2012 -0500 Add bouncy castle jars. commit 52c25ca Author: Charles Oliver Nutter <headius@headius.com> Date: Tue Jan 31 13:58:07 2012 -0600 Spike of rolling jossl directly into JRuby.
- Loading branch information
Showing
140 changed files
with
35,462 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=begin | ||
= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions | ||
= Info | ||
'OpenSSL for Ruby 2' project | ||
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz> | ||
All rights reserved. | ||
= Licence | ||
This program is licenced under the same licence as Ruby. | ||
(See the file 'LICENCE'.) | ||
= Version | ||
$Id: openssl.rb 12496 2007-06-08 15:02:04Z technorama $ | ||
=end | ||
|
||
require 'jopenssl' | ||
require 'openssl/bn' | ||
require 'openssl/cipher' | ||
require 'openssl/config' | ||
require 'openssl/digest' | ||
require 'openssl/pkcs7' | ||
require 'openssl/ssl' | ||
require 'openssl/x509' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
=begin | ||
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN | ||
= Info | ||
'OpenSSL for Ruby 2' project | ||
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz> | ||
All rights reserved. | ||
= Licence | ||
This program is licenced under the same licence as Ruby. | ||
(See the file 'LICENCE'.) | ||
= Version | ||
$Id: bn.rb 11708 2007-02-12 23:01:19Z shyouhei $ | ||
=end | ||
|
||
## | ||
# Should we care what if somebody require this file directly? | ||
#require 'openssl' | ||
|
||
module OpenSSL | ||
class BN | ||
include Comparable | ||
end # BN | ||
end # OpenSSL | ||
|
||
## | ||
# Add double dispatch to Integer | ||
# | ||
class Integer | ||
def to_bn | ||
OpenSSL::BN::new(self) | ||
end | ||
end # Integer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
=begin | ||
= $RCSfile$ -- Buffering mix-in module. | ||
= Info | ||
'OpenSSL for Ruby 2' project | ||
Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org> | ||
All rights reserved. | ||
= Licence | ||
This program is licenced under the same licence as Ruby. | ||
(See the file 'LICENCE'.) | ||
= Version | ||
$Id: buffering.rb 13706 2007-10-15 08:29:08Z usa $ | ||
=end | ||
|
||
module Buffering | ||
include Enumerable | ||
attr_accessor :sync | ||
BLOCK_SIZE = 1024*16 | ||
|
||
def initialize(*args) | ||
@eof = false | ||
@rbuffer = "" | ||
@sync = @io.sync | ||
end | ||
|
||
# | ||
# for reading. | ||
# | ||
private | ||
|
||
def fill_rbuff | ||
begin | ||
@rbuffer << self.sysread(BLOCK_SIZE) | ||
rescue Errno::EAGAIN | ||
retry | ||
rescue EOFError | ||
@eof = true | ||
end | ||
end | ||
|
||
def consume_rbuff(size=nil) | ||
if @rbuffer.empty? | ||
nil | ||
else | ||
size = @rbuffer.size unless size | ||
ret = @rbuffer[0, size] | ||
@rbuffer[0, size] = "" | ||
ret | ||
end | ||
end | ||
|
||
public | ||
|
||
def read(size=nil, buf=nil) | ||
if size == 0 | ||
if buf | ||
buf.clear | ||
else | ||
buf = "" | ||
end | ||
return @eof ? nil : buf | ||
end | ||
until @eof | ||
break if size && size <= @rbuffer.size | ||
fill_rbuff | ||
end | ||
ret = consume_rbuff(size) || "" | ||
if buf | ||
buf.replace(ret) | ||
ret = buf | ||
end | ||
(size && ret.empty?) ? nil : ret | ||
end | ||
|
||
def readpartial(maxlen, buf=nil) | ||
if maxlen == 0 | ||
if buf | ||
buf.clear | ||
else | ||
buf = "" | ||
end | ||
return @eof ? nil : buf | ||
end | ||
if @rbuffer.empty? | ||
begin | ||
return sysread(maxlen, buf) | ||
rescue Errno::EAGAIN | ||
retry | ||
end | ||
end | ||
ret = consume_rbuff(maxlen) | ||
if buf | ||
buf.replace(ret) | ||
ret = buf | ||
end | ||
raise EOFError if ret.empty? | ||
ret | ||
end | ||
|
||
def gets(eol=$/) | ||
idx = @rbuffer.index(eol) | ||
until @eof | ||
break if idx | ||
fill_rbuff | ||
idx = @rbuffer.index(eol) | ||
end | ||
if eol.is_a?(Regexp) | ||
size = idx ? idx+$&.size : nil | ||
else | ||
size = idx ? idx+eol.size : nil | ||
end | ||
consume_rbuff(size) | ||
end | ||
|
||
def each(eol=$/) | ||
while line = self.gets(eol) | ||
yield line | ||
end | ||
end | ||
alias each_line each | ||
|
||
def readlines(eol=$/) | ||
ary = [] | ||
while line = self.gets(eol) | ||
ary << line | ||
end | ||
ary | ||
end | ||
|
||
def readline(eol=$/) | ||
raise EOFError if eof? | ||
gets(eol) | ||
end | ||
|
||
def getc | ||
c = read(1) | ||
c ? c[0] : nil | ||
end | ||
|
||
def each_byte | ||
while c = getc | ||
yield(c) | ||
end | ||
end | ||
|
||
def readchar | ||
raise EOFError if eof? | ||
getc | ||
end | ||
|
||
def ungetc(c) | ||
@rbuffer[0,0] = c.chr | ||
end | ||
|
||
def eof? | ||
fill_rbuff if !@eof && @rbuffer.empty? | ||
@eof && @rbuffer.empty? | ||
end | ||
alias eof eof? | ||
|
||
# | ||
# for writing. | ||
# | ||
private | ||
|
||
def do_write(s) | ||
@wbuffer = "" unless defined? @wbuffer | ||
@wbuffer << s | ||
@sync ||= false | ||
if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/) | ||
remain = idx ? idx + $/.size : @wbuffer.length | ||
nwritten = 0 | ||
while remain > 0 | ||
str = @wbuffer[nwritten,remain] | ||
begin | ||
nwrote = syswrite(str) | ||
rescue Errno::EAGAIN | ||
retry | ||
end | ||
remain -= nwrote | ||
nwritten += nwrote | ||
end | ||
@wbuffer[0,nwritten] = "" | ||
end | ||
end | ||
|
||
public | ||
|
||
def write(s) | ||
do_write(s) | ||
s.length | ||
end | ||
|
||
def << (s) | ||
do_write(s) | ||
self | ||
end | ||
|
||
def puts(*args) | ||
s = "" | ||
if args.empty? | ||
s << "\n" | ||
end | ||
args.each{|arg| | ||
s << arg.to_s | ||
if $/ && /\n\z/ !~ s | ||
s << "\n" | ||
end | ||
} | ||
do_write(s) | ||
nil | ||
end | ||
|
||
def print(*args) | ||
s = "" | ||
args.each{ |arg| s << arg.to_s } | ||
do_write(s) | ||
nil | ||
end | ||
|
||
def printf(s, *args) | ||
do_write(s % args) | ||
nil | ||
end | ||
|
||
def flush | ||
osync = @sync | ||
@sync = true | ||
do_write "" | ||
@sync = osync | ||
end | ||
|
||
def close | ||
flush rescue nil | ||
sysclose | ||
end | ||
end |
Oops, something went wrong.