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