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