No, the VAX is not a 64 bit architecture.
[openssl.git] / perl / OpenSSL.pm
1 ##
2 ##  OpenSSL.pm
3 ##
4
5 package OpenSSL;
6
7 require 5.000;
8 use Exporter;
9 use DynaLoader;
10
11 @ISA    = qw(Exporter DynaLoader);
12 @EXPORT = qw();
13
14 $VERSION = '0.94';
15 bootstrap OpenSSL;
16
17 @OpenSSL::BN::ISA        = qw(OpenSSL::ERR);
18 @OpenSSL::MD::ISA        = qw(OpenSSL::ERR);
19 @OpenSSL::Cipher::ISA    = qw(OpenSSL::ERR);
20 @OpenSSL::SSL::CTX::ISA  = qw(OpenSSL::ERR);
21 @OpenSSL::BIO::ISA       = qw(OpenSSL::ERR);
22 @OpenSSL::SSL::ISA       = qw(OpenSSL::ERR);
23
24 @BN::ISA                 = qw(OpenSSL::BN);
25 @MD::ISA                 = qw(OpenSSL::MD);
26 @Cipher::ISA             = qw(OpenSSL::Cipher);
27 @SSL::ISA                = qw(OpenSSL::SSL);
28 @SSL::CTX::ISA           = qw(OpenSSL::SSL::CTX);
29 @BIO::ISA                = qw(OpenSSL::BIO);
30
31 @OpenSSL::MD::names = qw(
32     md2 md5 sha sha1 ripemd160 mdc2
33 );
34
35 @OpenSSL::Cipher::names = qw(
36     des-ecb des-cfb des-ofb des-cbc
37     des-ede des-ede-cfb des-ede-ofb des-ede-cbc
38     des-ede3 des-ede3-cfb des-ede3-ofb des-ede3-cbc
39     desx-cbc rc4 rc4-40
40     idea-ecb idea-cfb idea-ofb idea-cbc
41     rc2-ecb rc2-cbc rc2-40-cbc rc2-cfb rc2-ofb
42     bf-ecb bf-cfb bf-ofb bf-cbc
43     cast5-ecb cast5-cfb cast5-ofb cast5-cbc
44     rc5-ecb rc5-cfb rc5-ofb rc5-cbc
45 );
46
47 sub OpenSSL::SSL::CTX::new_ssl { 
48     OpenSSL::SSL::new($_[0]);
49 }
50
51 sub OpenSSL::ERR::error {
52     my($o) = @_;
53     my($s, $ret);
54
55     while (($s = $o->get_error()) != 0) {
56         $ret.=$s."\n";
57     }
58     return($ret);
59 }
60
61 @OpenSSL::Cipher::aliases = qw(
62     des desx des3 idea rc2 bf cast
63 );
64
65 package OpenSSL::BN;
66
67 sub bnfix { 
68     (ref($_[0]) ne "OpenSSL::BN") ? OpenSSL::BN::dec2bn($_[0]) : $_[0]; 
69 }
70
71 use overload
72 "="    => sub { dup($_[0]); },
73 "+"    => sub { add($_[0],$_[1]); },
74 "-"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; OpenSSL::BN::sub($_[0],$_[1]); },
75 "*"    => sub { mul($_[0],$_[1]); },
76 "**"   => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; OpenSSL::BN::exp($_[0],$_[1]); },
77 "/"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; (div($_[0],$_[1]))[0]; },
78 "%"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; mod($_[0],$_[1]); },
79 "<<"   => sub { lshift($_[0],$_[1]); },
80 ">>"   => sub { rshift($_[0],$_[1]); },
81 "<=>"  => sub { OpenSSL::BN::cmp($_[0],$_[1]); },
82 '""'   => sub { bn2dec($_[0]); },
83 '0+'   => sub { dec2bn($_[0]); },
84 "bool" => sub { ref($_[0]) eq "OpenSSL::BN"; };
85
86 sub OpenSSL::BIO::do_accept { 
87     OpenSSL::BIO::do_handshake(@_);
88 }
89
90 1;