Commit 84107e6c authored by Ralf S. Engelschall's avatar Ralf S. Engelschall
Browse files

Second round of fixing the OpenSSL perl/ stuff. It now at least compiled fine

under Unix and passes some trivial tests I've now added. But the whole stuff
is horribly incomplete, so a README.1ST with a disclaimer was added to make
sure no one expects that this stuff really works in the OpenSSL 0.9.2 release.
Additionally I've started to clean the XS sources up and fixed a few little
bugs and inconsistencies in OpenSSL.{pm,xs} and openssl_bio.xs.

PS: I'm still not convinces whether we should try to make this
    finally running or kick it out and replace it with some
    other module....
parent 9ea0e64d
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,15 @@


 Changes between 0.9.1c and 0.9.2
 Changes between 0.9.1c and 0.9.2


  *) Second round of fixing the OpenSSL perl/ stuff. It now at least compiled
     fine under Unix and passes some trivial tests I've now added. But the
     whole stuff is horribly incomplete, so a README.1ST with a disclaimer was
     added to make sure no one expects that this stuff really works in the
     OpenSSL 0.9.2 release.  Additionally I've started to clean the XS sources
     up and fixed a few little bugs and inconsistencies in OpenSSL.{pm,xs} and
     openssl_bio.xs.
     [Ralf S. Engelschall]

  *) Fix the generation of two part addresses in perl.
  *) Fix the generation of two part addresses in perl.
     [Kenji Miyake <kenji@miyake.org>, integrated by Ben Laurie]
     [Kenji Miyake <kenji@miyake.org>, integrated by Ben Laurie]


+4 −0
Original line number Original line Diff line number Diff line
README.1ST
MANIFEST
MANIFEST
Makefile.PL
Makefile.PL
typemap
typemap
@@ -12,3 +13,6 @@ openssl_err.xs
openssl_ssl.xs
openssl_ssl.xs
openssl_x509.xs
openssl_x509.xs
openssl_cb.c
openssl_cb.c
t/01-use.t
t/02-version.t
t/03-bio.t
+7 −2
Original line number Original line Diff line number Diff line
@@ -2,14 +2,19 @@
##  Makefile.PL -- Perl MakeMaker specification
##  Makefile.PL -- Perl MakeMaker specification
##
##


$V = '0.9.2';
print "Configuring companion Perl module for OpenSSL $V\n";

use ExtUtils::MakeMaker;
use ExtUtils::MakeMaker;


WriteMakefile(
WriteMakefile(
    'OPTIMIZE'      => '',
    'OPTIMIZE'      => '',
    'DISTNAME'      => 'OpenSSL-0.9.2',
    'DISTNAME'      => "openssl-$V",
    'NAME'          => 'OpenSSL',
    'NAME'          => 'OpenSSL',
    'VERSION_FROM'  => 'OpenSSL.pm',
    'VERSION_FROM'  => 'OpenSSL.pm',
    'LIBS'          => ['-L.. -lssl -lcrypto'],
    'LIBS'          => ( $^O eq 'MSWin32'
                         ? [ '-L../out32dll -lssleay32 -llibeay32' ]
                         : [ '-L.. -lssl -lcrypto' ]                 ),
    'DEFINE'        => '',
    'DEFINE'        => '',
    'INC'           => '-I../include',
    'INC'           => '-I../include',
    'H'             => ['openssl.h'],
    'H'             => ['openssl.h'],
+72 −62
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@


package OpenSSL;
package OpenSSL;


require 5.000;
use Exporter;
use Exporter;
use DynaLoader;
use DynaLoader;


@@ -11,7 +12,7 @@ use DynaLoader;
@EXPORT = qw();
@EXPORT = qw();


$VERSION = '0.92';
$VERSION = '0.92';
bootstrap penSSL;
bootstrap OpenSSL;


@OpenSSL::BN::ISA        = qw(OpenSSL::ERR);
@OpenSSL::BN::ISA        = qw(OpenSSL::ERR);
@OpenSSL::MD::ISA        = qw(OpenSSL::ERR);
@OpenSSL::MD::ISA        = qw(OpenSSL::ERR);
@@ -27,7 +28,9 @@ bootstrap penSSL;
@SSL::CTX::ISA           = qw(OpenSSL::SSL::CTX);
@SSL::CTX::ISA           = qw(OpenSSL::SSL::CTX);
@BIO::ISA                = qw(OpenSSL::BIO);
@BIO::ISA                = qw(OpenSSL::BIO);


@OpenSSL::MD::names=qw(md2 md5 sha sha1 ripemd160 mdc2);
@OpenSSL::MD::names = qw(
    md2 md5 sha sha1 ripemd160 mdc2
);


@OpenSSL::Cipher::names = qw(
@OpenSSL::Cipher::names = qw(
    des-ecb des-cfb des-ofb des-cbc
    des-ecb des-cfb des-ofb des-cbc
@@ -41,34 +44,38 @@ bootstrap penSSL;
    rc5-ecb rc5-cfb rc5-ofb rc5-cbc
    rc5-ecb rc5-cfb rc5-ofb rc5-cbc
);
);


sub OpenSSL::SSL::CTX::new_ssl { OpenSSL::SSL::new($_[0]); }
sub OpenSSL::SSL::CTX::new_ssl { 
    OpenSSL::SSL::new($_[0]);
}


sub OpenSSL::ERR::error
sub OpenSSL::ERR::error {
	{
    my($o) = @_;
    my($o) = @_;
    my($s, $ret);
    my($s, $ret);


	while (($s=$o->get_error()) != 0)
    while (($s = $o->get_error()) != 0) {
		{
        $ret.=$s."\n";
        $ret.=$s."\n";
    }
    }
    return($ret);
    return($ret);
}
}


@OpenSSL::Cipher::aliases=qw(des desx des3 idea rc2 bf cast);
@OpenSSL::Cipher::aliases = qw(
    des desx des3 idea rc2 bf cast
);


package OpenSSL::BN;
package OpenSSL::BN;


sub bnfix { (ref($_[0]) ne "OpenSSL::BN")?OpenSSL::BN::dec2bn($_[0]):$_[0]; }
sub bnfix { 
    (ref($_[0]) ne "OpenSSL::BN") ? OpenSSL::BN::dec2bn($_[0]) : $_[0]; 
}

use overload
use overload
"="    => sub { dup($_[0]); },
"="    => sub { dup($_[0]); },
"+"    => sub { add($_[0],$_[1]); },
"+"    => sub { add($_[0],$_[1]); },
"-"  => sub {	($_[1],$_[0])=($_[0],$_[1]) if $_[2];
"-"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; OpenSSL::BN::sub($_[0],$_[1]); },
		OpenSSL::BN::sub($_[0],$_[1]); },
"*"    => sub { mul($_[0],$_[1]); },
"*"    => sub { mul($_[0],$_[1]); },
"**"   => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; OpenSSL::BN::exp($_[0],$_[1]); },
"/"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; (div($_[0],$_[1]))[0]; },
"/"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; (div($_[0],$_[1]))[0]; },
"%"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; mod($_[0],$_[1]); },
"%"    => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; mod($_[0],$_[1]); },
"**" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; exp($_[0],$_[1]); },
"<<"   => sub { lshift($_[0],$_[1]); },
"<<"   => sub { lshift($_[0],$_[1]); },
">>"   => sub { rshift($_[0],$_[1]); },
">>"   => sub { rshift($_[0],$_[1]); },
"<=>"  => sub { OpenSSL::BN::cmp($_[0],$_[1]); },
"<=>"  => sub { OpenSSL::BN::cmp($_[0],$_[1]); },
@@ -76,5 +83,8 @@ use overload
'0+'   => sub { dec2bn($_[0]); },
'0+'   => sub { dec2bn($_[0]); },
"bool" => sub { ref($_[0]) eq "OpenSSL::BN"; };
"bool" => sub { ref($_[0]) eq "OpenSSL::BN"; };


sub OpenSSL::BIO::do_accept { OpenSSL::BIO::do_handshake(@_); }
sub OpenSSL::BIO::do_accept { 
    OpenSSL::BIO::do_handshake(@_);
}

1;
1;
+66 −55
Original line number Original line Diff line number Diff line
@@ -4,7 +4,8 @@


#include "openssl.h"
#include "openssl.h"


SV *new_ref(type,obj,mort)
SV *
new_ref(type, obj, mort)
  char *type;
  char *type;
  char *obj;
  char *obj;
{
{
@@ -14,12 +15,15 @@ char *obj;
        ret = sv_newmortal();
        ret = sv_newmortal();
    else
    else
        ret = newSViv(0);
        ret = newSViv(0);
#ifdef DEBUG
    printf(">new_ref %d\n",type);
    printf(">new_ref %d\n",type);
#endif
    sv_setref_pv(ret, type, (void *)obj);
    sv_setref_pv(ret, type, (void *)obj);
    return(ret);
    return(ret);
}
}


int ex_new(obj,data,ad,idx,argl,argp)
int 
ex_new(obj, data, ad, idx, argl, argp)
  char *obj;
  char *obj;
  SV *data;
  SV *data;
  CRYPTO_EX_DATA *ad;
  CRYPTO_EX_DATA *ad;
@@ -29,15 +33,20 @@ char *argp;
{
{
    SV *sv;
    SV *sv;


fprintf(stderr,"ex_new %08X %s\n",obj,argp);
#ifdef DEBUG
    printf("ex_new %08X %s\n",obj,argp); 
#endif
    sv = sv_newmortal();
    sv = sv_newmortal();
    sv_setref_pv(sv, argp, (void *)obj);
    sv_setref_pv(sv, argp, (void *)obj);
#ifdef DEBUG
    printf("%d>new_ref '%s'\n", sv, argp);
    printf("%d>new_ref '%s'\n", sv, argp);
#endif
    CRYPTO_set_ex_data(ad, idx, (char *)sv);
    CRYPTO_set_ex_data(ad, idx, (char *)sv);
    return(1);
    return(1);
}
}


void ex_cleanup(obj,data,ad,idx,argl,argp)
void 
ex_cleanup(obj, data, ad, idx, argl, argp)
  char *obj;
  char *obj;
  SV *data;
  SV *data;
  CRYPTO_EX_DATA *ad;
  CRYPTO_EX_DATA *ad;
@@ -46,7 +55,9 @@ long argl;
  char *argp;
  char *argp;
{
{
    pr_name("ex_cleanup");
    pr_name("ex_cleanup");
fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp);
#ifdef DEBUG
    printf("ex_cleanup %08X %s\n", obj, argp);
#endif
    if (data != NULL)
    if (data != NULL)
        SvREFCNT_dec((SV *)data);
        SvREFCNT_dec((SV *)data);
}
}
Loading