From 8073036dd62848b616c6a817c155c3255074ec83 Mon Sep 17 00:00:00 2001 From: "Ralf S. Engelschall" Date: Wed, 10 Feb 1999 09:38:31 +0000 Subject: Overhauled the Perl interface (perl/*): - ported BN stuff to OpenSSL's different BN library - made the perl/ source tree CVS-aware - renamed the package from SSLeay to OpenSSL (the files still contain their history because I've copied them in the repository) - removed obsolete files (the test scripts will be replaced by better Test::Harness variants in the future) --- perl/.cvsignore | 12 + perl/MANIFEST | 25 +-- perl/Makefile.PL | 58 +++-- perl/OpenSSL.pm | 80 +++++++ perl/OpenSSL.xs | 22 +- perl/SSLeay.pm | 78 ------- perl/SSLeay.xs | 65 ------ perl/b.pl | 21 -- perl/bio.pl | 30 --- perl/bio.txt | 36 --- perl/bio.xs | 450 ------------------------------------- perl/bn.pl | 23 -- perl/bn.txt | 38 ---- perl/bn.xs | 589 ------------------------------------------------- perl/callback.c | 103 --------- perl/cipher.pl | 39 ---- perl/cipher.txt | 10 - perl/cipher.xs | 152 ------------- perl/dh.pl | 40 ---- perl/digest.txt | 7 - perl/digest.xs | 83 ------- perl/err.txt | 2 - perl/err.xs | 46 ---- perl/f.pl | 11 - perl/g.pl | 18 -- perl/gen_rsa.pl | 49 ---- perl/mul.pl | 56 ----- perl/openssl.h | 2 +- perl/openssl_bio.xs | 27 +-- perl/openssl_bn.xs | 75 ++++--- perl/openssl_cb.c | 1 - perl/openssl_cipher.xs | 9 +- perl/openssl_digest.xs | 11 +- perl/openssl_err.xs | 5 +- perl/openssl_ssl.xs | 35 +-- perl/openssl_x509.xs | 7 +- perl/p5SSLeay.h | 96 -------- perl/r.pl | 56 ----- perl/s.pl | 72 ------ perl/s2.pl | 49 ---- perl/server.pem | 369 ------------------------------- perl/ss.pl | 64 ------ perl/ssl.pl | 71 ------ perl/ssl.txt | 43 ---- perl/ssl.xs | 474 --------------------------------------- perl/ssl_srvr.pl | 35 --- perl/sslbio.pl | 40 ---- perl/t.pl | 12 - perl/test | 32 --- perl/test.pl | 30 --- perl/test.txt | 36 --- perl/test2.pl | 28 --- perl/test3.pl | 19 -- perl/test8.pl | 19 -- perl/test9.pl | 38 ---- perl/testbn.pl | 23 -- perl/testdec.pl | 14 -- perl/testmd.pl | 26 --- perl/tt.pl | 15 -- perl/typemap | 52 ++--- perl/x509.txt | 6 - perl/x509.xs | 74 ------- perl/xstmp.c | 102 --------- perl/y.pl | 7 - perl/yy.pl | 19 -- perl/z.pl | 32 --- perl/zz.pl | 22 -- 67 files changed, 267 insertions(+), 4023 deletions(-) create mode 100644 perl/.cvsignore create mode 100644 perl/OpenSSL.pm delete mode 100644 perl/SSLeay.pm delete mode 100644 perl/SSLeay.xs delete mode 100644 perl/b.pl delete mode 100644 perl/bio.pl delete mode 100644 perl/bio.txt delete mode 100644 perl/bio.xs delete mode 100644 perl/bn.pl delete mode 100644 perl/bn.txt delete mode 100644 perl/bn.xs delete mode 100644 perl/callback.c delete mode 100644 perl/cipher.pl delete mode 100644 perl/cipher.txt delete mode 100644 perl/cipher.xs delete mode 100644 perl/dh.pl delete mode 100644 perl/digest.txt delete mode 100644 perl/digest.xs delete mode 100644 perl/err.txt delete mode 100644 perl/err.xs delete mode 100644 perl/f.pl delete mode 100644 perl/g.pl delete mode 100644 perl/gen_rsa.pl delete mode 100644 perl/mul.pl delete mode 100644 perl/p5SSLeay.h delete mode 100644 perl/r.pl delete mode 100644 perl/s.pl delete mode 100644 perl/s2.pl delete mode 100644 perl/server.pem delete mode 100644 perl/ss.pl delete mode 100644 perl/ssl.pl delete mode 100644 perl/ssl.txt delete mode 100644 perl/ssl.xs delete mode 100644 perl/ssl_srvr.pl delete mode 100644 perl/sslbio.pl delete mode 100644 perl/t.pl delete mode 100644 perl/test delete mode 100644 perl/test.pl delete mode 100644 perl/test.txt delete mode 100644 perl/test2.pl delete mode 100644 perl/test3.pl delete mode 100644 perl/test8.pl delete mode 100644 perl/test9.pl delete mode 100644 perl/testbn.pl delete mode 100644 perl/testdec.pl delete mode 100644 perl/testmd.pl delete mode 100644 perl/tt.pl delete mode 100644 perl/x509.txt delete mode 100644 perl/x509.xs delete mode 100644 perl/xstmp.c delete mode 100644 perl/y.pl delete mode 100644 perl/yy.pl delete mode 100644 perl/z.pl delete mode 100644 perl/zz.pl (limited to 'perl') diff --git a/perl/.cvsignore b/perl/.cvsignore new file mode 100644 index 0000000000..e3f4b2ec4e --- /dev/null +++ b/perl/.cvsignore @@ -0,0 +1,12 @@ +Makefile +blib +pm_to_blib +OpenSSL.c +openssl_bio.c +openssl_bn.c +openssl_cipher.c +openssl_digest.c +openssl_err.c +openssl_ssl.c +openssl_x509.c +OpenSSL.bs diff --git a/perl/MANIFEST b/perl/MANIFEST index 992db5ed4c..6acbc10af4 100644 --- a/perl/MANIFEST +++ b/perl/MANIFEST @@ -1,17 +1,14 @@ MANIFEST Makefile.PL -SSLeay.pm -bio.xs -bn.xs -cipher.xs -digest.xs -err.xs -ssl.xs -x509.xs -test.pl -test2.pl -test3.pl -test9.pl -testbn.pl -testmd.pl typemap +OpenSSL.pm +OpenSSL.xs +openssl.h +openssl_bio.xs +openssl_bn.xs +openssl_cipher.xs +openssl_digest.xs +openssl_err.xs +openssl_ssl.xs +openssl_x509.xs +openssl_cb.c diff --git a/perl/Makefile.PL b/perl/Makefile.PL index f9998e0a61..77d5af5f21 100644 --- a/perl/Makefile.PL +++ b/perl/Makefile.PL @@ -1,25 +1,37 @@ +## +## Makefile.PL -- Perl MakeMaker specification +## + use ExtUtils::MakeMaker; -# See lib/ExtUtils/MakeMaker.pm for details of how to influence -# the contents of the Makefile that is written. + WriteMakefile( - 'OPTIMIZE' => '-g', - 'DISTNAME' => 'SSLeay-perl5-0.8.5', - 'NAME' => 'SSLeay', - 'VERSION_FROM' => 'SSLeay.pm', - 'LIBS' => ['-L.. -lssl -lcrypto'], - 'DEFINE' => '', - 'INC' => '-I../include', - 'C' => ['callback.c'], - 'H' => ['p5SSLeay.h'], - 'OBJECT' => " SSLeay.o bio.o bn.o cipher.o digest.o err.o - ssl.o x509.o", - 'XS' => { 'SSLeay.xs' => 'SSLeay.c', - 'bio.xs' => 'bio.c', - 'bn.xs' => 'bn.c', - 'cipher.xs' => 'cipher.c', - 'digest.xs' => 'digest.c', - 'err.xs' => 'err.c', - 'ssl.xs' => 'ssl.c', - 'x509.xs' => 'x509.c', - } - ); + 'OPTIMIZE' => '', + 'DISTNAME' => 'OpenSSL-0.9.2', + 'NAME' => 'OpenSSL', + 'VERSION_FROM' => 'OpenSSL.pm', + 'LIBS' => ['-L.. -lssl -lcrypto'], + 'DEFINE' => '', + 'INC' => '-I../include', + 'H' => ['openssl.h'], + 'C' => ['openssl_cb.c'], + 'OBJECT' => + 'OpenSSL.o ' . + 'openssl_bio.o ' . + 'openssl_bn.o ' . + 'openssl_cipher.o ' . + 'openssl_digest.o ' . + 'openssl_err.o ' . + 'openssl_ssl.o ' . + 'openssl_x509.o ', + 'XS' => { + 'OpenSSL.xs' => 'OpenSSL.c', + 'openssl_bio.xs' => 'openssl_bio.c', + 'openssl_bn.xs' => 'openssl_bn.c', + 'openssl_cipher.xs' => 'openssl_cipher.c', + 'openssl_digest.xs' => 'openssl_digest.c', + 'openssl_err.xs' => 'openssl_err.c', + 'openssl_ssl.xs' => 'openssl_ssl.c', + 'openssl_x509.xs' => 'openssl_x509.c', + }, +); + diff --git a/perl/OpenSSL.pm b/perl/OpenSSL.pm new file mode 100644 index 0000000000..21c05a44cf --- /dev/null +++ b/perl/OpenSSL.pm @@ -0,0 +1,80 @@ +## +## OpenSSL.pm +## + +package OpenSSL; + +use Exporter; +use DynaLoader; + +@ISA = qw(Exporter DynaLoader); +@EXPORT = qw(); + +$VERSION='0.92'; +bootstrap penSSL; + +@OpenSSL::BN::ISA= qw(OpenSSL::ERR); +@OpenSSL::MD::ISA= qw(OpenSSL::ERR); +@OpenSSL::Cipher::ISA= qw(OpenSSL::ERR); +@OpenSSL::SSL::CTX::ISA= qw(OpenSSL::ERR); +@OpenSSL::BIO::ISA= qw(OpenSSL::ERR); +@OpenSSL::SSL::ISA= qw(OpenSSL::ERR); + +@BN::ISA= qw(OpenSSL::BN); +@MD::ISA= qw(OpenSSL::MD); +@Cipher::ISA= qw(OpenSSL::Cipher); +@SSL::ISA= qw(OpenSSL::SSL); +@SSL::CTX::ISA= qw(OpenSSL::SSL::CTX); +@BIO::ISA= qw(OpenSSL::BIO); + +@OpenSSL::MD::names=qw(md2 md5 sha sha1 ripemd160 mdc2); + +@OpenSSL::Cipher::names=qw( + des-ecb des-cfb des-ofb des-cbc + des-ede des-ede-cfb des-ede-ofb des-ede-cbc + des-ede3 des-ede3-cfb des-ede3-ofb des-ede3-cbc + desx-cbc rc4 rc4-40 + idea-ecb idea-cfb idea-ofb idea-cbc + rc2-ecb rc2-cbc rc2-40-cbc rc2-cfb rc2-ofb + bf-ecb bf-cfb bf-ofb bf-cbc + cast5-ecb cast5-cfb cast5-ofb cast5-cbc + rc5-ecb rc5-cfb rc5-ofb rc5-cbc + ); + +sub OpenSSL::SSL::CTX::new_ssl { OpenSSL::SSL::new($_[0]); } + +sub OpenSSL::ERR::error + { + my($o)=@_; + my($s,$ret); + + while (($s=$o->get_error()) != 0) + { + $ret.=$s."\n"; + } + return($ret); + } + +@OpenSSL::Cipher::aliases=qw(des desx des3 idea rc2 bf cast); + +package OpenSSL::BN; + +sub bnfix { (ref($_[0]) ne "OpenSSL::BN")?OpenSSL::BN::dec2bn($_[0]):$_[0]; } +use overload +"=" => sub { dup($_[0]); }, +"+" => sub { add($_[0],$_[1]); }, +"-" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; + OpenSSL::BN::sub($_[0],$_[1]); }, +"*" => sub { mul($_[0],$_[1]); }, +"/" => 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]; exp($_[0],$_[1]); }, +"<<" => sub { lshift($_[0],$_[1]); }, +">>" => sub { rshift($_[0],$_[1]); }, +"<=>" => sub { OpenSSL::BN::cmp($_[0],$_[1]); }, +'""' => sub { bn2dec($_[0]); }, +'0+' => sub { dec2bn($_[0]); }, +"bool" => sub { ref($_[0]) eq "OpenSSL::BN"; }; + +sub OpenSSL::BIO::do_accept { OpenSSL::BIO::do_handshake(@_); } +1; diff --git a/perl/OpenSSL.xs b/perl/OpenSSL.xs index 3e3d1debeb..6a975be515 100644 --- a/perl/OpenSSL.xs +++ b/perl/OpenSSL.xs @@ -1,4 +1,8 @@ -#include "p5SSLeay.h" +/* +** OpenSSL.xs +*/ + +#include "openssl.h" SV *new_ref(type,obj,mort) char *type; @@ -47,7 +51,7 @@ fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp); SvREFCNT_dec((SV *)data); } -MODULE = SSLeay PACKAGE = SSLeay +MODULE = OpenSSL PACKAGE = OpenSSL BOOT: boot_bio(); @@ -55,11 +59,11 @@ BOOT: boot_digest(); boot_err(); boot_ssl(); - boot_SSLeay__BN(); - boot_SSLeay__BIO(); - boot_SSLeay__Cipher(); - boot_SSLeay__MD(); - boot_SSLeay__ERR(); - boot_SSLeay__SSL(); - boot_SSLeay__X509(); + boot_OpenSSL__BN(); + boot_OpenSSL__BIO(); + boot_OpenSSL__Cipher(); + boot_OpenSSL__MD(); + boot_OpenSSL__ERR(); + boot_OpenSSL__SSL(); + boot_OpenSSL__X509(); diff --git a/perl/SSLeay.pm b/perl/SSLeay.pm deleted file mode 100644 index f7710039d2..0000000000 --- a/perl/SSLeay.pm +++ /dev/null @@ -1,78 +0,0 @@ -package SSLeay; - -use Exporter; -use DynaLoader; - -@ISA = qw(Exporter DynaLoader); -@EXPORT = qw(); - -$VERSION='0.82'; -$VERSION='0.82'; -bootstrap SSLeay; - -@SSLeay::BN::ISA= qw(SSLeay::ERR); -@SSLeay::MD::ISA= qw(SSLeay::ERR); -@SSLeay::Cipher::ISA= qw(SSLeay::ERR); -@SSLeay::SSL::CTX::ISA= qw(SSLeay::ERR); -@SSLeay::BIO::ISA= qw(SSLeay::ERR); -@SSLeay::SSL::ISA= qw(SSLeay::ERR); - -@BN::ISA= qw(SSLeay::BN); -@MD::ISA= qw(SSLeay::MD); -@Cipher::ISA= qw(SSLeay::Cipher); -@SSL::ISA= qw(SSLeay::SSL); -@SSL::CTX::ISA= qw(SSLeay::SSL::CTX); -@BIO::ISA= qw(SSLeay::BIO); - - -@SSLeay::MD::names=qw(md2 md5 sha sha1 ripemd160 mdc2); - -@SSLeay::Cipher::names=qw( - des-ecb des-cfb des-ofb des-cbc - des-ede des-ede-cfb des-ede-ofb des-ede-cbc - des-ede3 des-ede3-cfb des-ede3-ofb des-ede3-cbc - desx-cbc rc4 rc4-40 - idea-ecb idea-cfb idea-ofb idea-cbc - rc2-ecb rc2-cbc rc2-40-cbc rc2-cfb rc2-ofb - bf-ecb bf-cfb bf-ofb bf-cbc - cast5-ecb cast5-cfb cast5-ofb cast5-cbc - rc5-ecb rc5-cfb rc5-ofb rc5-cbc - ); - -sub SSLeay::SSL::CTX::new_ssl { SSLeay::SSL::new($_[0]); } - -sub SSLeay::ERR::error - { - my($o)=@_; - my($s,$ret); - - while (($s=$o->get_error()) != 0) - { - $ret.=$s."\n"; - } - return($ret); - } - -@SSLeay::Cipher::aliases=qw(des desx des3 idea rc2 bf cast); - -package SSLeay::BN; - -sub bnfix { (ref($_[0]) ne "SSLeay::BN")?SSLeay::BN::dec2bn($_[0]):$_[0]; } -use overload -"=" => sub { dup($_[0]); }, -"+" => sub { add($_[0],$_[1]); }, -"-" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; - SSLeay::BN::sub($_[0],$_[1]); }, -"*" => sub { mul($_[0],$_[1]); }, -"/" => 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]; exp($_[0],$_[1]); }, -"<<" => sub { lshift($_[0],$_[1]); }, -">>" => sub { rshift($_[0],$_[1]); }, -"<=>" => sub { SSLeay::BN::cmp($_[0],$_[1]); }, -'""' => sub { bn2dec($_[0]); }, -'0+' => sub { dec2bn($_[0]); }, -"bool" => sub { ref($_[0]) eq "SSLeay::BN"; }; - -sub SSLeay::BIO::do_accept { SSLeay::BIO::do_handshake(@_); } -1; diff --git a/perl/SSLeay.xs b/perl/SSLeay.xs deleted file mode 100644 index 3e3d1debeb..0000000000 --- a/perl/SSLeay.xs +++ /dev/null @@ -1,65 +0,0 @@ -#include "p5SSLeay.h" - -SV *new_ref(type,obj,mort) -char *type; -char *obj; - { - SV *ret; - - if (mort) - ret=sv_newmortal(); - else - ret=newSViv(0); -printf(">new_ref %d\n",type); - sv_setref_pv(ret,type,(void *)obj); - return(ret); - } - -int ex_new(obj,data,ad,idx,argl,argp) -char *obj; -SV *data; -CRYPTO_EX_DATA *ad; -int idx; -long argl; -char *argp; - { - SV *sv; - -fprintf(stderr,"ex_new %08X %s\n",obj,argp); - sv=sv_newmortal(); - sv_setref_pv(sv,argp,(void *)obj); -printf("%d>new_ref '%s'\n",sv,argp); - CRYPTO_set_ex_data(ad,idx,(char *)sv); - return(1); - } - -void ex_cleanup(obj,data,ad,idx,argl,argp) -char *obj; -SV *data; -CRYPTO_EX_DATA *ad; -int idx; -long argl; -char *argp; - { - pr_name("ex_cleanup"); -fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp); - if (data != NULL) - SvREFCNT_dec((SV *)data); - } - -MODULE = SSLeay PACKAGE = SSLeay - -BOOT: - boot_bio(); - boot_cipher(); - boot_digest(); - boot_err(); - boot_ssl(); - boot_SSLeay__BN(); - boot_SSLeay__BIO(); - boot_SSLeay__Cipher(); - boot_SSLeay__MD(); - boot_SSLeay__ERR(); - boot_SSLeay__SSL(); - boot_SSLeay__X509(); - diff --git a/perl/b.pl b/perl/b.pl deleted file mode 100644 index ac1e52de79..0000000000 --- a/perl/b.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - -$cmd=<<"EOF"; - -EOF - -$conn="localhost:4433"; -$conn=$ARGV[0] if $#ARGV >= 0; -print "X\n"; -$bio=BIO->new("connect"); -print "XX\n"; -$bio->set_callback(sub {print STDERR $_[0]->number_read."\n"; $_[$#_] }); -print "XXX\n"; -$bio->hostname($conn) || die $ssl->error(); -print "XXXX\n"; - -#$ssl=BIO->new("ssl"); diff --git a/perl/bio.pl b/perl/bio.pl deleted file mode 100644 index 70a97e7925..0000000000 --- a/perl/bio.pl +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - -$cmd=<<"EOF"; -GET / HTTP/1.0 - -EOF - -$conn="localhost:4433"; -$conn=$ARGV[0] if $#ARGV >= 0; -$bio=SSLeay::BIO::new("connect"); -#$bio->set_callback(sub {print STDERR SSLeay::BIO::number_read($_[0])."\n"; $_[$#_] }); -#$bio->set_callback(sub {print STDERR "$#_:".$_[0].":$_[1]:$_[2]:$_[3]:$_[4]:\n"; $_[$#_] }); -$bio->hostname($conn) || die $ssl->error(); - - -(($ret=$bio->do_handshake()) > 0) || die $bio->error(); - -(($ret=$bio->syswrite($cmd)) > 0) || die $bio->error(); - -while (1) - { - $ret=$bio->sysread($buf,10240); - last if ($ret <= 0); - print $buf; - } - diff --git a/perl/bio.txt b/perl/bio.txt deleted file mode 100644 index 5b46c9f5ee..0000000000 --- a/perl/bio.txt +++ /dev/null @@ -1,36 +0,0 @@ -BIO::new(type) - "connect" - "accept" - "ssl" - "buffer" - -"connect" - BIO::hostname(name) host:port to connect to - -"accept" - BIO::set_accept_port(port) port to connect too. - -"connect", "accept", "ssl" - BIO::do_andshake do protocol - -"ssl" - BIO::set_ssl(ssl) - BIO::get_ssl() - -BIO::push(bio) -BIO::pop; return BIO -BIO::number_read() -BIO::number_written() -BIO::references() - -BIO::sysread(buf,len[,offset]) -BIO::syswrite(in[,len][,offset]) -BIO::getline() -BIO::puts(in) -BIO::flush() -BIO::type() -BIO::next_bio(); -BIO::set_callback(callback[, args]) - -BIO::new_buffer_ssl_connect(SSL_CTX) -BIO::new_ssl_connect(SSL_CTX) diff --git a/perl/bio.xs b/perl/bio.xs deleted file mode 100644 index a9d32d8408..0000000000 --- a/perl/bio.xs +++ /dev/null @@ -1,450 +0,0 @@ -#include "p5SSLeay.h" - -static int p5_bio_ex_bio_ptr=0; -static int p5_bio_ex_bio_callback=0; -static int p5_bio_ex_bio_callback_data=0; - -static long p5_bio_callback(bio,state,parg,cmd,larg,ret) -BIO *bio; -int state; -char *parg; -int cmd; -long larg; -int ret; - { - int i; - SV *me,*cb; - - me=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); - cb=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_callback); - if (cb != NULL) - { - dSP; - - ENTER ; - SAVETMPS; - - PUSHMARK(sp); - XPUSHs(sv_2mortal(newSViv(me))); - XPUSHs(sv_2mortal(newSViv(state))); - XPUSHs(sv_2mortal(newSViv(cmd))); - if ((state == BIO_CB_READ) || (state == BIO_CB_WRITE)) - { - XPUSHs(sv_2mortal(newSVpv(parg,larg))); - } - else - XPUSHs(&sv_undef); - /* ptr one */ - XPUSHs(sv_2mortal(newSViv(larg))); - XPUSHs(sv_2mortal(newSViv(ret))); - PUTBACK; - - i=perl_call_sv(cb,G_SCALAR); - - SPAGAIN; - if (i == 1) - ret=POPi; - else - ret=1; - PUTBACK; - FREETMPS; - LEAVE; - } - else - { - croak("Internal error in SSL p5_ssl_info_callback"); - } - return(ret); - } - -int boot_bio() - { - p5_bio_ex_bio_ptr= - BIO_get_ex_new_index(0,"SSLeay::BIO",ex_new,NULL, - ex_cleanup); - p5_bio_ex_bio_callback= - BIO_get_ex_new_index(0,"bio_callback",NULL,NULL, - ex_cleanup); - p5_bio_ex_bio_callback_data= - BIO_get_ex_new_index(0,"bio_callback_data",NULL,NULL, - ex_cleanup); - return(1); - } - -MODULE = SSLeay::BIO PACKAGE = SSLeay::BIO PREFIX = p5_BIO_ - -VERSIONCHECK: DISABLE - -void -p5_BIO_new_buffer_ssl_connect(...) - PREINIT: - SSL_CTX *ctx; - BIO *bio; - SV *arg; - PPCODE: - if (items == 1) - arg=ST(0); - else if (items == 2) - arg=ST(1); - else - arg=NULL; - - if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX"))) - croak("Usage: SSLeay::BIO::new_buffer_ssl_connect(SSL_CTX)"); - else - { - IV tmp=SvIV((SV *)SvRV(arg)); - ctx=(SSL_CTX *)tmp; - } - EXTEND(sp,1); - bio=BIO_new_buffer_ssl_connect(ctx); - arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); - PUSHs(arg); - -void -p5_BIO_new_ssl_connect(...) - PREINIT: - SSL_CTX *ctx; - BIO *bio; - SV *arg; - PPCODE: - if (items == 1) - arg=ST(0); - else if (items == 2) - arg=ST(1); - else - arg=NULL; - - if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX"))) - croak("Usage: SSLeay::BIO::new_ssl_connect(SSL_CTX)"); - else - { - IV tmp=SvIV((SV *)SvRV(arg)); - ctx=(SSL_CTX *)tmp; - } - EXTEND(sp,1); - bio=BIO_new_ssl_connect(ctx); - arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); - PUSHs(arg); - -void -p5_BIO_new(...) - PREINIT: - BIO *bio; - char *type; - SV *arg; - PPCODE: - pr_name("p5_BIO_new"); - if ((items == 1) && SvPOK(ST(0))) - type=SvPV(ST(0),na); - else if ((items == 2) && SvPOK(ST(1))) - type=SvPV(ST(1),na); - else - croak("Usage: SSLeay::BIO::new(type)"); - - EXTEND(sp,1); - if (strcmp(type,"connect") == 0) - bio=BIO_new(BIO_s_connect()); - else if (strcmp(type,"accept") == 0) - bio=BIO_new(BIO_s_accept()); - else if (strcmp(type,"ssl") == 0) - bio=BIO_new(BIO_f_ssl()); - else if (strcmp(type,"buffer") == 0) - bio=BIO_new(BIO_f_buffer()); - else - croak("unknown BIO type"); - arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); - PUSHs(arg); - -int -p5_BIO_hostname(bio,name) - BIO *bio; - char *name; - CODE: - RETVAL=BIO_set_conn_hostname(bio,name); - OUTPUT: - RETVAL - -int -p5_BIO_set_accept_port(bio,str) - BIO *bio; - char *str; - CODE: - RETVAL=BIO_set_accept_port(bio,str); - OUTPUT: - RETVAL - -int -p5_BIO_do_handshake(bio) - BIO *bio; - CODE: - RETVAL=BIO_do_handshake(bio); - OUTPUT: - RETVAL - -BIO * -p5_BIO_push(b,bio) - BIO *b; - BIO *bio; - CODE: - /* This reference will be reduced when the reference is - * let go, and then when the BIO_free_all() is called - * inside the SSLeay library by the BIO with this - * pushed into */ - bio->references++; - RETVAL=BIO_push(b,bio); - OUTPUT: - RETVAL - -void -p5_BIO_pop(b) - BIO *b - PREINIT: - BIO *bio; - char *type; - SV *arg; - PPCODE: - bio=BIO_pop(b); - if (bio != NULL) - { - /* This BIO will either be one created in the - * perl library, in which case it will have a perl - * SV, otherwise it will have been created internally, - * inside SSLeay. For the 'pushed in', it needs - * the reference count decememted. */ - arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); - if (arg == NULL) - { - arg=new_ref("SSLeay::BIO",(char *)bio,0); - BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); - PUSHs(arg); - } - else - { - /* it was pushed in */ - SvREFCNT_inc(arg); - PUSHs(arg); -#if 0 /* This does not need to be done. */ - if (bio->references < 1) - abort(); - /* decrement the reference count */ - BIO_free(bio); -#endif - } - } - -int -p5_BIO_sysread(bio,in,num, ...) - BIO *bio; - SV *in; - int num; - PREINIT: - int i,n,olen; - int offset; - char *p; - CODE: - offset=0; - if (!SvPOK(in)) - sv_setpvn(in,"",0); - SvPV(in,olen); - if (items > 3) - { - offset=SvIV(ST(3)); - if (offset < 0) - { - if (-offset > olen) - croak("Offset outside string"); - offset+=olen; - } - } - if ((num+offset) > olen) - { - SvGROW(in,num+offset+1); - p=SvPV(in,i); - memset(&(p[olen]),0,(num+offset)-olen+1); - } - p=SvPV(in,n); - - i=BIO_read(bio,p+offset,num); - RETVAL=i; - if (i <= 0) i=0; - SvCUR_set(in,offset+i); - OUTPUT: - RETVAL - -int -p5_BIO_syswrite(bio,in, ...) - BIO *bio; - SV *in; - PREINIT: - char *ptr; - int len,in_len; - int offset=0; - int n; - CODE: - ptr=SvPV(in,in_len); - if (items > 2) - { - len=SvOK(ST(2))?SvIV(ST(2)):in_len; - if (items > 3) - { - offset=SvIV(ST(3)); - if (offset < 0) - { - if (-offset > in_len) - croak("Offset outside string"); - offset+=in_len; - } - else if ((offset >= in_len) && (in_len > 0)) - croak("Offset outside string"); - } - if (len >= (in_len-offset)) - len=in_len-offset; - } - else - len=in_len; - - RETVAL=BIO_write(bio,ptr+offset,len); - OUTPUT: - RETVAL - -void -p5_BIO_getline(bio) - BIO *bio; - PREINIT: - int i; - char *p; - PPCODE: - pr_name("p5_BIO_gets"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - sv_setpvn(ST(0),"",0); - SvGROW(ST(0),1024); - p=SvPV(ST(0),na); - i=BIO_gets(bio,p,1024); - if (i < 0) i=0; - SvCUR_set(ST(0),i); - -int -p5_BIO_flush(bio) - BIO *bio; - CODE: - RETVAL=BIO_flush(bio); - OUTPUT: - RETVAL - -char * -p5_BIO_type(bio) - BIO *bio; - CODE: - RETVAL=bio->method->name; - OUTPUT: - RETVAL - -void -p5_BIO_next_bio(b) - BIO *b - PREINIT: - BIO *bio; - char *type; - SV *arg; - PPCODE: - bio=b->next_bio; - if (bio != NULL) - { - arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); - if (arg == NULL) - { - arg=new_ref("SSLeay::BIO",(char *)bio,0); - BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); - bio->references++; - PUSHs(arg); - } - else - { - SvREFCNT_inc(arg); - PUSHs(arg); - } - } - -int -p5_BIO_puts(bio,in) - BIO *bio; - SV *in; - PREINIT: - char *ptr; - CODE: - ptr=SvPV(in,na); - RETVAL=BIO_puts(bio,ptr); - OUTPUT: - RETVAL - -void -p5_BIO_set_callback(bio,cb,...) - BIO *bio; - SV *cb; - PREINIT: - SV *arg=NULL; - SV *arg2=NULL; - CODE: - if (items > 3) - croak("Usage: SSLeay::BIO::set_callback(bio,callback[,arg]"); - if (items == 3) - { - arg2=sv_mortalcopy(ST(2)); - SvREFCNT_inc(arg2); - BIO_set_ex_data(bio,p5_bio_ex_bio_callback_data, - (char *)arg2); - } - arg=sv_mortalcopy(ST(1)); - SvREFCNT_inc(arg); - BIO_set_ex_data(bio,p5_bio_ex_bio_callback,(char *)arg); - printf("%08lx < bio_ptr\n",BIO_get_ex_data(bio,p5_bio_ex_bio_ptr)); - BIO_set_callback(bio,p5_bio_callback); - -void -p5_BIO_DESTROY(bio) - BIO *bio - PREINIT: - SV *sv; - PPCODE: - pr_name_d("p5_BIO_DESTROY",bio->references); - printf("p5_BIO_DESTROY <%s> %d\n",bio->method->name,bio->references); - BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,NULL); - BIO_free_all(bio); - -int -p5_BIO_set_ssl(bio,ssl) - BIO *bio; - SSL *ssl; - CODE: - pr_name("p5_BIO_set_ssl"); - ssl->references++; - RETVAL=BIO_set_ssl(bio,ssl,BIO_CLOSE); - OUTPUT: - RETVAL - -int -p5_BIO_number_read(bio) - BIO *bio; - CODE: - RETVAL=BIO_number_read(bio); - OUTPUT: - RETVAL - -int -p5_BIO_number_written(bio) - BIO *bio; - CODE: - RETVAL=BIO_number_written(bio); - OUTPUT: - RETVAL - -int -p5_BIO_references(bio) - BIO *bio; - CODE: - RETVAL=bio->references; - OUTPUT: - RETVAL - diff --git a/perl/bn.pl b/perl/bn.pl deleted file mode 100644 index 388e19c6de..0000000000 --- a/perl/bn.pl +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/local/bin/perl -use ExtUtils::testlib; -use SSLeay; - -$message=SSLeay::BN::new(); -$e=SSLeay::BN::new(); -$mod=SSLeay::BN::new(); - -$mod=SSLeay::BN::dec2bn("114381625757888867669235779976146612010218296721242362562561842935706935245733897830597123563958705058989075147599290026879543541"); -$e=5; -$d=SSLeay::BN::dec2bn("45752650303155547067694311990458644804087318688496945025024737159778909096647814932594914301288138204957467016445183857236173773"); - -$message=SSLeay::BN::bin2bn("The magic words are squeamish ossifrage"); - - - $cipher_text= $message->mod_exp($e,$mod); -print $mod."\n"; -print $mod->num_bits()."\n"; -for (1 .. 1000) - { - $clear= $cipher_text->mod_exp($d,$mod); - } -print $clear->bn2bin()."\n"; diff --git a/perl/bn.txt b/perl/bn.txt deleted file mode 100644 index 784e761558..0000000000 --- a/perl/bn.txt +++ /dev/null @@ -1,38 +0,0 @@ -BN->new() -BN->dup(a) -BN->rand(bits[,top][,bottom]) - -BN->hex2bn(a) -BN->bn2hex(a) -BN->dec2bn(a) -BN->bn2dec(a) -BN->bin2bn(a) -BN->bn2bin(a) -BN->mpi2bn(a) -BN->bn2mpi(a) - -BN->add(a,b) -BN->sub(a,b) -BN->mul(a,b) -(div,mod)=BN->div(a,b) -BN->mod(a,b) -BN->exp(a,p) -BN->mod_mul(a,b,c) -BN->mod_exp(a,b,c) - -BN->is_prime(p,num) -BN->generate_prime(bits,strong,callback) - -BN->num_bits(a) -BN->cmp(a,b) -BN->ucmp(a,b) -BN->is_bit_set(a,pos) -BN->set_bit(a,pos) -BN->clear_bit(a,pos) -BN->lshift(a,num) -BN->rshift(a,num) -BN->mask_bits(a,pos) -BN->clear(a) -BN->gcd(a,b) -BN->mod_inverse(a,mod) - diff --git a/perl/bn.xs b/perl/bn.xs deleted file mode 100644 index c15be3729a..0000000000 --- a/perl/bn.xs +++ /dev/null @@ -1,589 +0,0 @@ -#include "p5SSLeay.h" - -int sv_to_BIGNUM(var,arg,name) -BIGNUM **var; -SV *arg; -char *name; - { - int ret=1; - - if (sv_derived_from(arg,"SSLeay::BN")) - { - IV tmp = SvIV((SV*)SvRV(arg)); - *var = (BIGNUM *) tmp; - } - else if (SvIOK(arg)) { - SV *tmp=sv_newmortal(); - *var=BN_new(); - BN_set_word(*var,SvIV(arg)); - sv_setref_pv(tmp,"SSLeay::BN",(void*)*var); - } - else if (SvPOK(arg)) { - char *ptr; - STRLEN len; - SV *tmp=sv_newmortal(); - *var=BN_new(); - sv_setref_pv(tmp,"SSLeay::BN", (void*)*var); - ptr=SvPV(arg,len); - SvGROW(arg,len+1); - ptr[len]='\0'; - BN_dec2bn(var,ptr); - } - else - { - croak(name); - ret=0; - } - return(ret); - } - -typedef struct gpc_args_st { - SV *cb; - SV *arg; - } GPC_ARGS; - -static void generate_prime_callback(pos,num,arg) -int pos; -int num; -char *arg; - { - dSP ; - int i; - GPC_ARGS *a=(GPC_ARGS *)arg; - - ENTER ; - SAVETMPS ; - - PUSHMARK(sp); - XPUSHs(sv_2mortal(newSViv(pos))); - XPUSHs(sv_2mortal(newSViv(num))); - XPUSHs(sv_2mortal(newSVsv(a->arg))); - PUTBACK; - - i=perl_call_sv(a->cb,G_DISCARD); - - SPAGAIN; - - PUTBACK; - FREETMPS; - LEAVE; - } - -MODULE = SSLeay::BN PACKAGE = SSLeay::BN PREFIX = p5_BN_ - -VERSIONCHECK: DISABLE - -void -p5_BN_new(...) - PREINIT: - BIGNUM *bn; - SV *arg; - PPCODE: - pr_name("p5_BN_new"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - bn=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn); - -void -p5_BN_dup(a) - BIGNUM *a; - PREINIT: - BIGNUM *bn; - PPCODE: - pr_name("p5_BN_dup"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - bn=BN_dup(a); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn); - -void -p5_BN_rand(bits,...) - int bits; - PREINIT: - int top=1; - int bottom=0; - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_rand"); - if ((items < 1) || (items > 3)) - croak("Usage: SSLeay::BN::rand(bits[,top_bit][,bottombit]"); - if (items >= 2) top=(int)SvIV(ST(0)); - if (items >= 3) bottom=(int)SvIV(ST(1)); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - BN_rand(ret,bits,top,bottom); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - -void -p5_BN_bin2bn(a) - datum a; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_bin2bn"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_bin2bn(a.dptr,a.dsize,NULL); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - -void -p5_BN_bn2bin(a) - BIGNUM *a; - PREINIT: - int i; - PPCODE: - pr_name("p5_BN_bn2bin"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - i=BN_num_bytes(a)+2; - sv_setpvn(ST(0),"",1); - SvGROW(ST(0),i+1); - SvCUR_set(ST(0),BN_bn2bin(a,SvPV(ST(0),na))); - -void -p5_BN_mpi2bn(a) - datum a; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_mpi2bn"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_mpi2bn(a.dptr,a.dsize,NULL); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - -void -p5_BN_bn2mpi(a) - BIGNUM *a; - PREINIT: - int i; - PPCODE: - pr_name("p5_BN_bn2mpi"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - i=BN_bn2mpi(a,NULL); - sv_setpvn(ST(0),"",1); - SvGROW(ST(0),i+1); - SvCUR_set(ST(0),BN_bn2mpi(a,SvPV(ST(0),na))); - -void -p5_BN_hex2bn(a) - datum a; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_hex2bn"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_hex2bn(&ret,a.dptr); - -void -p5_BN_dec2bn(a) - datum a; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_dec2bn"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_dec2bn(&ret,a.dptr); - -SV * -p5_BN_bn2hex(a) - BIGNUM *a; - PREINIT: - char *ptr; - int i; - CODE: - pr_name("p5_BN_bn2hex"); - ptr=BN_bn2hex(a); - RETVAL=newSVpv("",0); - i=strlen(ptr); - SvGROW(RETVAL,i+1); - memcpy(SvPV(RETVAL,na),ptr,i+1); - SvCUR_set(RETVAL,i); - Free(ptr); - OUTPUT: - RETVAL - -SV * -p5_BN_bn2dec(a) - BIGNUM *a; - PREINIT: - char *ptr; - int i; - CODE: - pr_name("p5_BN_bn2dec"); - ptr=BN_bn2dec(a); - RETVAL=newSVpv("",0); - i=strlen(ptr); - SvGROW(RETVAL,i+1); - memcpy(SvPV(RETVAL,na),ptr,i+1); - SvCUR_set(RETVAL,i); - Free(ptr); - OUTPUT: - RETVAL - -void -p5_BN_add(a,b) - BIGNUM *a; - BIGNUM *b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_add"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_add(ret,a,b); - -void -p5_BN_sub(a,b) - BIGNUM *a; - BIGNUM *b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_sub"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_sub(ret,a,b); - -void -p5_BN_mul(a,b) - BIGNUM *a; - BIGNUM *b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_mul"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_mul(ret,a,b); - -void -p5_BN_div(a,b) - BIGNUM *a; - BIGNUM *b; - PREINIT: - static BN_CTX *ctx=NULL; - BIGNUM *div,*mod; - PPCODE: - pr_name("p5_BN_div"); - if (ctx == NULL) ctx=BN_CTX_new(); - EXTEND(sp,2); - PUSHs(sv_newmortal()); - PUSHs(sv_newmortal()); - div=BN_new(); - mod=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)div); - sv_setref_pv(ST(1), "SSLeay::BN", (void*)mod); - BN_div(div,mod,a,b,ctx); - -void -p5_BN_mod(a,b) - BIGNUM *a; - BIGNUM *b; - PREINIT: - static BN_CTX *ctx=NULL; - BIGNUM *rem; - PPCODE: - pr_name("p5_BN_mod"); - if (ctx == NULL) ctx=BN_CTX_new(); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - rem=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)rem); - BN_mod(rem,a,b,ctx); - -void -p5_BN_exp(a,p) - BIGNUM *a; - BIGNUM *p; - PREINIT: - BIGNUM *ret; - static BN_CTX *ctx=NULL; - PPCODE: - pr_name("p5_BN_exp"); - if (ctx == NULL) ctx=BN_CTX_new(); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_exp(ret,a,p,ctx); - -void -p5_BN_mod_mul(a,b,c) - BIGNUM *a; - BIGNUM *b; - BIGNUM *c; - PREINIT: - static BN_CTX *ctx=NULL; - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_mod_mul"); - if (ctx == NULL) ctx=BN_CTX_new(); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_mod_mul(ret,a,b,c,ctx); - -void -p5_BN_mod_exp(a,b,c) - BIGNUM *a; - BIGNUM *b; - BIGNUM *c; - PREINIT: - static BN_CTX *ctx=NULL; - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_mod_exp"); - if (ctx == NULL) ctx=BN_CTX_new(); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_mod_exp(ret,a,b,c,ctx); - -void -p5_BN_generate_prime(...) - PREINIT: - int bits=512; - int strong=0; - BIGNUM *ret=NULL; - SV *callback=NULL; - SV *cb_arg=NULL; - GPC_ARGS arg; - dSP; - - PPCODE: - pr_name("p5_BN_generate_prime"); - if ((items < 0) || (items > 4)) - croak("Usage: SSLeay::BN::generate_prime(a[,strong][,callback][,cb_arg]"); - if (items >= 1) bits=(int)SvIV(ST(0)); - if (items >= 2) strong=(int)SvIV(ST(1)); - if (items >= 3) callback=ST(2); - if (items == 4) cb_arg=ST(3); - - if (callback == NULL) - ret=BN_generate_prime(bits,strong,NULL,NULL,NULL,NULL); - else - { - arg.cb=callback; - arg.arg=cb_arg; - - ret=BN_generate_prime(bits,strong,NULL,NULL, - generate_prime_callback,(char *)&arg); - } - - SPAGAIN; - sp-=items; /* a bit evil that I do this */ - - EXTEND(sp,1); - PUSHs(sv_newmortal()); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - -void -p5_BN_is_prime(p,...) - BIGNUM *p; - PREINIT: - int nchecks=5,ret; - SV *callback=NULL; - SV *cb_arg=NULL; - GPC_ARGS arg; - dSP; - static BN_CTX *ctx=NULL; - PPCODE: - pr_name("p5_BN_is_prime"); - if ((items < 1) || (items > 4)) - croak("Usage: SSLeay::BN::is_prime(a[,ncheck][,callback][,callback_arg]"); - if (ctx == NULL) ctx=BN_CTX_new(); - if (items >= 2) nchecks=(int)SvIV(ST(1)); - if (items >= 3) callback=ST(2); - if (items >= 4) cb_arg=ST(3); - arg.arg=cb_arg; - if (callback == NULL) - ret=BN_is_prime(p,nchecks,NULL,ctx,NULL); - else - { - arg.cb=callback; - arg.arg=cb_arg; - ret=BN_is_prime(p,nchecks,generate_prime_callback, - ctx,(char *)&arg); - } - SPAGAIN; - sp-=items; /* a bit evil */ - PUSHs(sv_2mortal(newSViv(ret))); - -int -p5_BN_num_bits(a) - BIGNUM *a; - CODE: - pr_name("p5_BN_num_bits"); - RETVAL=BN_num_bits(a); - OUTPUT: - RETVAL - -int -p5_BN_cmp(a,b) - BIGNUM *a; - BIGNUM *b; - CODE: - pr_name("p5_BN_cmp"); - RETVAL=BN_cmp(a,b); - OUTPUT: - RETVAL - -int -p5_BN_ucmp(a,b) - BIGNUM *a; - BIGNUM *b; - CODE: - pr_name("p5_BN_ucmp"); - RETVAL=BN_ucmp(a,b); - OUTPUT: - RETVAL - -int -p5_BN_is_bit_set(a,b) - BIGNUM *a; - int b; - CODE: - pr_name("p5_BN_is_bit_set"); - RETVAL=BN_is_bit_set(a,b); - OUTPUT: - RETVAL - -void -p5_BN_set_bit(a,b) - BIGNUM *a; - int b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_set_bit"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_dup(a); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_set_bit(ret,b); - -void -p5_BN_clear_bit(a,b) - BIGNUM *a; - int b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_clear_bit"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_dup(a); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_clear_bit(ret,b); - -void -p5_BN_lshift(a,b) - BIGNUM *a; - int b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_lshift"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - if (b == 1) - BN_lshift1(ret,a); - else - BN_lshift(ret,a,b); - -void -p5_BN_rshift(a,b) - BIGNUM *a; - int b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_rshift"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - if (b == 1) - BN_rshift1(ret,a); - else - BN_rshift(ret,a,b); - -void -p5_BN_mask_bits(a,b) - BIGNUM *a; - int b; - PREINIT: - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_mask_bits"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_dup(a); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_mask_bits(ret,b); - -void -p5_BN_clear(a) - BIGNUM *a; - PPCODE: - pr_name("p5_BN_clear"); - BN_clear(a); - -void -p5_BN_gcd(a,b) - BIGNUM *a; - BIGNUM *b; - PREINIT: - static BN_CTX *ctx=NULL; - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_gcd"); - if (ctx == NULL) ctx=BN_CTX_new(); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_gcd(ret,a,b,ctx); - -void -p5_BN_mod_inverse(a,mod) - BIGNUM *a; - BIGNUM *mod; - PREINIT: - static BN_CTX *ctx=NULL; - BIGNUM *ret; - PPCODE: - pr_name("p5_BN_mod_inverse"); - if (ctx == NULL) ctx=BN_CTX_new(); - ret=BN_mod_inverse(a,mod,ctx); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - -void -p5_BN_DESTROY(bn) - BIGNUM *bn - CODE: - pr_name("p5_BN_DESTROY"); - BN_free(bn); - diff --git a/perl/callback.c b/perl/callback.c deleted file mode 100644 index 4e39c16d70..0000000000 --- a/perl/callback.c +++ /dev/null @@ -1,103 +0,0 @@ -/* perl/callback.c */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -SV *new_ref(type,obj,mort) -char *type; -char *obj; - { - SV *ret; - - if (mort) - ret=sv_newmortal(); - else - ret=newSViv(0); - sv_setref_pv(ret,type,(void *)obj); - return(ret); - } - -int ex_new(obj,data,ad,idx,argl,argp) -char *obj; -SV *data; -CRYPTO_EX_DATA *ad; -int idx; -long argl; -char *argp; - { - SV *sv; - -fprintf(stderr,"ex_new idx=%d %08X %s\n",idx,obj,argp); - sv=sv_newmortal(); - sv_setref_pv(sv,argp,(void *)obj); - CRYPTO_set_ex_data(ad,idx,(char *)sv); - return(1); - } - -void ex_cleanup(obj,data,ad,idx,argl,argp) -char *obj; -SV *data; -CRYPTO_EX_DATA *ad; -int idx; -long argl; -char *argp; - { - pr_name("ex_cleanup"); -fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp); - if (data != NULL) - SvREFCNT_dec((SV *)data); - } - diff --git a/perl/cipher.pl b/perl/cipher.pl deleted file mode 100644 index efc712fdf5..0000000000 --- a/perl/cipher.pl +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - -$md=SSLeay::MD::new("md5"); - -foreach (@SSLeay::Cipher::names) - { - ($c=SSLeay::Cipher::new($_)) || - die "'$_' is an unknown cipher algorithm\n"; - - - $data="012345678abcdefghijklmnopqrstuvwxyz"; - $c->init("01234567abcdefghABCDEFGH","zyxwvut",1); - - $in =$c->update(substr($data, 0, 5)); - $in.=$c->update(substr($data, 5,10)); - $in.=$c->update(substr($data,15,1)); - $in.=$c->update(substr($data,16)); - - $in.=$c->final(); - - $c->init("01234567abcdefghABCDEFGH","zyxwvut",0); - $out=$c->update($in); - $out.=$c->final(); - - ($out eq $data) || die "decrypt for $_ failed:$!\n"; - - $md->init(); - $md->update($in); - $digest=$md->final(); - - print unpack("H*",$digest); - printf " %2d %2d %2d %s\n", $c->key_length(), $c->iv_length(), - $c->block_size(), $c->name(); - } - diff --git a/perl/cipher.txt b/perl/cipher.txt deleted file mode 100644 index c47952b5c9..0000000000 --- a/perl/cipher.txt +++ /dev/null @@ -1,10 +0,0 @@ -Cipher::new(name) "des-cbc" etc -Cipher::name() -Cipher::key_length() -Cipher::iv_length() -Cipher::block_size() - -Cipher::init(key,iv,enc) -Cipher::update(in) -Cipher::final() -Cipher::cipher(in) diff --git a/perl/cipher.xs b/perl/cipher.xs deleted file mode 100644 index 1044d7a4ef..0000000000 --- a/perl/cipher.xs +++ /dev/null @@ -1,152 +0,0 @@ -#include "p5SSLeay.h" - -int boot_cipher() - { - SSLeay_add_all_ciphers(); - return(1); - } - -MODULE = SSLeay::Cipher PACKAGE = SSLeay::Cipher PREFIX = p5_EVP_C_ - -VERSIONCHECK: DISABLE - -void -p5_EVP_C_new(...) - PREINIT: - EVP_CIPHER_CTX *ctx; - EVP_CIPHER *c; - char *name; - PPCODE: - if ((items == 1) && SvPOK(ST(0))) - name=SvPV(ST(0),na); - else if ((items == 2) && SvPOK(ST(1))) - name=SvPV(ST(1),na); - else - croak("Usage: SSLeay::Cipher::new(type)"); - PUSHs(sv_newmortal()); - c=EVP_get_cipherbyname(name); - if (c != NULL) - { - ctx=malloc(sizeof(EVP_CIPHER_CTX)); - EVP_EncryptInit(ctx,c,NULL,NULL); - sv_setref_pv(ST(0), "SSLeay::Cipher", (void*)ctx); - } - -datum -p5_EVP_C_name(ctx) - EVP_CIPHER_CTX *ctx - CODE: - RETVAL.dptr=OBJ_nid2ln(EVP_CIPHER_CTX_nid(ctx)); - RETVAL.dsize=strlen(RETVAL.dptr); - OUTPUT: - RETVAL - -int -p5_EVP_C_key_length(ctx) - EVP_CIPHER_CTX *ctx - CODE: - RETVAL=EVP_CIPHER_CTX_key_length(ctx); - OUTPUT: - RETVAL - -int -p5_EVP_C_iv_length(ctx) - EVP_CIPHER_CTX *ctx - CODE: - RETVAL=EVP_CIPHER_CTX_iv_length(ctx); - OUTPUT: - RETVAL - -int -p5_EVP_C_block_size(ctx) - EVP_CIPHER_CTX *ctx - CODE: - RETVAL=EVP_CIPHER_CTX_block_size(ctx); - OUTPUT: - RETVAL - -void -p5_EVP_C_init(ctx,key,iv,enc) - EVP_CIPHER_CTX *ctx - datum key - datum iv - int enc - PREINIT: - char loc_iv[EVP_MAX_IV_LENGTH]; - char loc_key[EVP_MAX_KEY_LENGTH]; - char *ip=loc_iv,*kp=loc_key; - int i; - memset(loc_iv,0,EVP_MAX_IV_LENGTH); - memset(loc_key,0,EVP_MAX_KEY_LENGTH); - CODE: - i=key.dsize; - if (key.dsize > EVP_CIPHER_CTX_key_length(ctx)) - i=EVP_CIPHER_CTX_key_length(ctx); - if (i > 0) - { - memset(kp,0,EVP_MAX_KEY_LENGTH); - memcpy(kp,key.dptr,i); - } - else - kp=NULL; - i=iv.dsize; - if (iv.dsize > EVP_CIPHER_CTX_iv_length(ctx)) - i=EVP_CIPHER_CTX_iv_length(ctx); - if (i > 0) - { - memcpy(ip,iv.dptr,i); - memset(ip,0,EVP_MAX_IV_LENGTH); - } - else - ip=NULL; - EVP_CipherInit(ctx,EVP_CIPHER_CTX_cipher(ctx),kp,ip,enc); - memset(loc_key,0,sizeof(loc_key)); - memset(loc_iv,0,sizeof(loc_iv)); - -SV * -p5_EVP_C_cipher(ctx,in) - EVP_CIPHER_CTX *ctx; - datum in; - CODE: - RETVAL=newSVpv("",0); - SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1); - EVP_Cipher(ctx,SvPV(RETVAL,na),in.dptr,in.dsize); - SvCUR_set(RETVAL,in.dsize); - OUTPUT: - RETVAL - -SV * -p5_EVP_C_update(ctx, in) - EVP_CIPHER_CTX *ctx - datum in - PREINIT: - int i; - CODE: - RETVAL=newSVpv("",0); - SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1); - EVP_CipherUpdate(ctx,SvPV(RETVAL,na),&i,in.dptr,in.dsize); - SvCUR_set(RETVAL,i); - OUTPUT: - RETVAL - -SV * -p5_EVP_C_final(ctx) - EVP_CIPHER_CTX *ctx - PREINIT: - int i; - CODE: - RETVAL=newSVpv("",0); - SvGROW(RETVAL,EVP_CIPHER_CTX_block_size(ctx)+1); - if (!EVP_CipherFinal(ctx,SvPV(RETVAL,na),&i)) - sv_setpv(RETVAL,"BAD DECODE"); - else - SvCUR_set(RETVAL,i); - OUTPUT: - RETVAL - -void -p5_EVP_C_DESTROY(ctx) - EVP_CIPHER_CTX *ctx - CODE: - free((char *)ctx); - diff --git a/perl/dh.pl b/perl/dh.pl deleted file mode 100644 index 61d2debe73..0000000000 --- a/perl/dh.pl +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - -$g=SSLeay::BN::hex2bn("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"); -$p=SSLeay::BN::hex2bn("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"); -$pub=SSLeay::BN::hex2bn("521b5b72d0a23f5f908eff62741b9c43ac65c47ad264a4f8d62d73dfab4938a6e019f81c28d64efd9b47c1b8188566c6184b6064cc42fac2778bd732678148c6cc7601bfe0ed18da76dd7bb976cd2ff0afc7b20f3f81171e2ea6534de061f929"); -$priv=SSLeay::BN::hex2bn("6e15c752af3f4cf6d7425164c451eeba760ec0651d12dc3b0ee5002a95af6191268ca47c0fbb3d836136eee795ae4af3a1adad5e04d0dbb04378cae0406ece23ca3b86839c0fd60064c1019c7d18be4dc0ec4be6c1e9ff6b0f5bd76373585503"); -$his=SSLeay::BN::hex2bn("d0fb51cd44a8578f55eb0822ede90f07504f4720d7367ff4bf76c27fedbce79d9204421ff7e86bd1dd02031bce4ceccd1d3e7c62679b6eb5fda8238fd4fe07bff573d552795f0d46f25753c688300fb9ed396792b59a49fdf89c8429124b668e"); -$sh=SSLeay::BN::hex2bn("66ec34b09bddf86147f6c6efd5ee4e6691e690eb0e90aceda16a742cad0abe531cb61d057aff362001ca19013215140ca2a1dd8966c78105bacbf2161f9cfbd58d351ff87923de77f9c56851037223d48272565416ee769e65a621cefb90b403"); - -$g2=SSLeay::BN::hex2bn("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"); -$p2=SSLeay::BN::hex2bn("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"); -$pub2=SSLeay::BN::hex2bn("d0fb51cd44a8578f55eb0822ede90f07504f4720d7367ff4bf76c27fedbce79d9204421ff7e86bd1dd02031bce4ceccd1d3e7c62679b6eb5fda8238fd4fe07bff573d552795f0d46f25753c688300fb9ed396792b59a49fdf89c8429124b668e"); -$priv2=SSLeay::BN::hex2bn("b81d54f52b687669fc8bd8087ac319accc2f94a2feafe09779f4a81e8e01f77290f5bbe84a08003afc4448145be427fad0b9d047889cf361c9dd378b15c1ebd5bda33e051fbd9eba8bf063e2bd836467cddb61f1db5c4b06bea5c9a77fb87b24"); -$his2=SSLeay::BN::hex2bn("521b5b72d0a23f5f908eff62741b9c43ac65c47ad264a4f8d62d73dfab4938a6e019f81c28d64efd9b47c1b8188566c6184b6064cc42fac2778bd732678148c6cc7601bfe0ed18da76dd7bb976cd2ff0afc7b20f3f81171e2ea6534de061f929"); -$sh2=SSLeay::BN::hex2bn("791faba7a6b592cb68a963945229483dc30f80f5cb295b2b5a59ef618a262d22de0845948a34db83d8bde260b940967ff85593a609e53ee6510aea09b776b4704d5e916917f384458d4790b6e0befcb1cb2f112b850e9ed410a091db80e1db2e"); - -print "g=".$g->bn2hex."\n"; -print "p=".$p->bn2hex."\n"; -print "pub=".$pub->bn2hex."\n"; -print "priv=".$priv->bn2hex."\n"; -print "sh=".$sh->bn2hex."\n"; - -print "new p - p2 = ".($p-$p2)."\n"; - -$tmp=$g->mod_exp($priv,$p); -print "XXXXXXXXXXXXXXXX\n"; -print "new pub - pub = ".($tmp-$pub)."\n"; -$tmp2=$g2->mod_exp($priv2,$p2); -print "XXXXXXXXXXXXXXXX\n"; - -print $p." pub\n"; -print $tmp2." calc pub\n"; -print $pub2." txt pub\n"; - - - diff --git a/perl/digest.txt b/perl/digest.txt deleted file mode 100644 index 6cb3ffedb0..0000000000 --- a/perl/digest.txt +++ /dev/null @@ -1,7 +0,0 @@ -MD::new(name) "md2", "md5" etc -MD::name() -MD::init() -MD::update(in) -MD::final() - - diff --git a/perl/digest.xs b/perl/digest.xs deleted file mode 100644 index 5738b09e48..0000000000 --- a/perl/digest.xs +++ /dev/null @@ -1,83 +0,0 @@ -#include "p5SSLeay.h" - -int boot_digest() - { - SSLeay_add_all_digests(); - return(1); - } - -MODULE = SSLeay::MD PACKAGE = SSLeay::MD PREFIX = p5_EVP_MD_ - -PROTOTYPES: ENABLE -VERSIONCHECK: DISABLE - -# SSLeay::MD::new(name) name= md2, md5, sha, sha1, or mdc2 -# md->name() - returns the name -# md->init() - reinitalises the digest -# md->update(data) - adds more data to digest -# digest=md->final() - returns digest -# - -void -p5_EVP_MD_new(...) - PREINIT: - EVP_MD_CTX *ctx; - EVP_MD *md; - char *name; - PPCODE: - if ((items == 1) && SvPOK(ST(0))) - name=SvPV(ST(0),na); - else if ((items == 2) && SvPOK(ST(1))) - name=SvPV(ST(1),na); - else - croak("Usage: SSLeay::MD::new(type)"); - PUSHs(sv_newmortal()); - md=EVP_get_digestbyname(name); - if (md != NULL) - { - ctx=malloc(sizeof(EVP_MD_CTX)); - EVP_DigestInit(ctx,md); - sv_setref_pv(ST(0), "SSLeay::MD", (void*)ctx); - } - -datum -p5_EVP_MD_name(ctx) - EVP_MD_CTX *ctx - CODE: - RETVAL.dptr=OBJ_nid2ln(EVP_MD_type(EVP_MD_CTX_type(ctx))); - RETVAL.dsize=strlen(RETVAL.dptr); - OUTPUT: - RETVAL - -void -p5_EVP_MD_init(ctx) - EVP_MD_CTX *ctx - CODE: - EVP_DigestInit(ctx,EVP_MD_CTX_type(ctx)); - -void -p5_EVP_MD_update(ctx, in) - EVP_MD_CTX *ctx - datum in - CODE: - EVP_DigestUpdate(ctx,in.dptr,in.dsize); - -datum -p5_EVP_MD_final(ctx) - EVP_MD_CTX *ctx - PREINIT: - char md[EVP_MAX_MD_SIZE]; - int len; - CODE: - EVP_DigestFinal(ctx,md,&len); - RETVAL.dptr=md; - RETVAL.dsize=len; - OUTPUT: - RETVAL - -void -p5_EVP_MD_DESTROY(ctx) - EVP_MD_CTX *ctx - CODE: - free((char *)ctx); - diff --git a/perl/err.txt b/perl/err.txt deleted file mode 100644 index 5e6cdaecdc..0000000000 --- a/perl/err.txt +++ /dev/null @@ -1,2 +0,0 @@ -ERR::get_error() -ERR::peek_error() diff --git a/perl/err.xs b/perl/err.xs deleted file mode 100644 index 6d1aec3ea1..0000000000 --- a/perl/err.xs +++ /dev/null @@ -1,46 +0,0 @@ -#include "p5SSLeay.h" - -int boot_err() - { - SSL_load_error_strings(); - return(1); - } - -MODULE = SSLeay::ERR PACKAGE = SSLeay::ERR PREFIX = p5_ERR_ - -PROTOTYPES: ENABLE -VERSIONCHECK: DISABLE - -# md->error() - returns the last error in text or numeric context - -void -p5_ERR_get_error(...) - PPCODE: - char buf[512]; - unsigned long l; - - pr_name("p5_ERR_get_code"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - l=ERR_get_error(); - ERR_error_string(l,buf); - sv_setiv(ST(0),l); - sv_setpv(ST(0),buf); - SvIOK_on(ST(0)); - -void -p5_ERR_peek_error(...) - PPCODE: - char buf[512]; - unsigned long l; - - pr_name("p5_ERR_get_code"); - EXTEND(sp,1); - PUSHs(sv_newmortal()); - l=ERR_peek_error(); - ERR_error_string(l,buf); - sv_setiv(ST(0),l); - sv_setpv(ST(0),buf); - SvIOK_on(ST(0)); - - diff --git a/perl/f.pl b/perl/f.pl deleted file mode 100644 index 4b6b2b75bf..0000000000 --- a/perl/f.pl +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - -for (7 .. 7926) - { - my $num = SSLeay::BN::dec2bn($_); - print "$_ is ".($num->is_prime ? 'prime' : 'composite'), "\n"; - } diff --git a/perl/g.pl b/perl/g.pl deleted file mode 100644 index 80b1a422f8..0000000000 --- a/perl/g.pl +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/local/bin/perl -use ExtUtils::testlib; -use SSLeay; - -$num=SSLeay::BN::new(); -$shift=SSLeay::BN::new(); - -print "0\n"; -$num=SSLeay::BN::hex2bn("1234329378209857309429670349760347603497603496398"); -print "1\n"; -$s=SSLeay::BN::hex2bn("59"); -print "a\n"; -$r=$num->lshift(59); -print "b"; - -print $num->bn2hex."\n"; -print $s->bn2hex."\n"; -print $r->bn2hex."\n"; diff --git a/perl/gen_rsa.pl b/perl/gen_rsa.pl deleted file mode 100644 index 6acf043c2a..0000000000 --- a/perl/gen_rsa.pl +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - -$bits=512; -$bits=$ARGV[0] if $#ARGV >= 0; - -$p=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."}); -print "\n"; -$q=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."}); -print "\n"; - -$e=SSLeay::BN::hex2bn("10001"); - -$t1=$p-1; -$t2=$q-1; - -($t1->gcd($e) == 1) || die "p failed the gcd test\n"; -($t2->gcd($e) == 1) || die "q failed the gcd test\n"; - -($q,$p)=($p,$q) if ($p < $q); -$n=$p*$q; -$t=($p-1)*($q-1); -($t->gcd($e) == 1) || die "t failed the gcd test\n"; - -$d=$e->mod_inverse($t); - -$dmp1=$d%($p-1); -$dmq1=$d%($q-1); -$iqmp=$q->mod_inverse($p); - -print "n =$n\n"; -print "e =$e\n"; -print "d =$d\n"; -print "dmp1=$dmp1\n"; -print "dmq1=$dmq1\n"; -print "iqmp=$iqmp\n"; - -$a=SSLeay::BN::bin2bn("This is an RSA test"); -print "Test with\n'".$a->bn2bin."' or\n$a\n"; - -$t1=$a->mod_exp($e,$n); -print "$t1\n"; -$t2=$t1->mod_exp($d,$n); -print "'".$t2->bn2bin."'\n"; - - diff --git a/perl/mul.pl b/perl/mul.pl deleted file mode 100644 index d4dea48192..0000000000 --- a/perl/mul.pl +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/local/bin/perl - -use ExtUtils::testlib; - -use SSLeay; - - -sub mul - { - my($ab,$cd,$num)=@_; - - if ($num <= 4096) - { - return($ab*$cd); - } - else - { - my($a,$b,$c,$d,$n,$ac,$bd,$m,$t1,$t2); - - $n=$num/2; - - $a=$ab->mask_bits($n); - $b=$ab->rshift($n); - $c=$cd->mask_bits($n); - $d=$cd->rshift($n); - - $t1=($b-$a); - $t2=($c-$d); - $m= &mul($t1,$t2,$n); - $ac=&mul($a,$c,$n); - $bd=&mul($b,$d,$n); - $m=$m+$ac+$bd; - $m=$m->lshift($n); - $bd=$bd->lshift($num); - - $r=$ac+$m+$bd; - return($r); - } - } - -$num=4096*32; -$a=SSLeay::BN::rand($num); -$b=SSLeay::BN::rand($num); - -#for (1 .. 10) - { - $r=&mul($a,$b,$num); - } - -#for (1 .. 10) - { - $rr=$a*$b; - } - -$res=$rr-$r; -print $res->bn2hex()."\n"; diff --git a/perl/openssl.h b/perl/openssl.h index bcccda7d5f..299d10e372 100644 --- a/perl/openssl.h +++ b/perl/openssl.h @@ -1,4 +1,3 @@ -/* perl/p5SSLeay.h */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -55,6 +54,7 @@ * copied and put under another distribution licence * [including the GNU Public Licence.] */ + #ifdef __cplusplus extern "C" { #endif diff --git a/perl/openssl_bio.xs b/perl/openssl_bio.xs index a9d32d8408..9e204a9f66 100644 --- a/perl/openssl_bio.xs +++ b/perl/openssl_bio.xs @@ -1,4 +1,5 @@ -#include "p5SSLeay.h" + +#include "openssl.h" static int p5_bio_ex_bio_ptr=0; static int p5_bio_ex_bio_callback=0; @@ -60,7 +61,7 @@ int ret; int boot_bio() { p5_bio_ex_bio_ptr= - BIO_get_ex_new_index(0,"SSLeay::BIO",ex_new,NULL, + BIO_get_ex_new_index(0,"OpenSSL::BIO",ex_new,NULL, ex_cleanup); p5_bio_ex_bio_callback= BIO_get_ex_new_index(0,"bio_callback",NULL,NULL, @@ -71,7 +72,7 @@ int boot_bio() return(1); } -MODULE = SSLeay::BIO PACKAGE = SSLeay::BIO PREFIX = p5_BIO_ +MODULE = OpenSSL::BIO PACKAGE = OpenSSL::BIO PREFIX = p5_BIO_ VERSIONCHECK: DISABLE @@ -89,8 +90,8 @@ p5_BIO_new_buffer_ssl_connect(...) else arg=NULL; - if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX"))) - croak("Usage: SSLeay::BIO::new_buffer_ssl_connect(SSL_CTX)"); + if ((arg == NULL) || !(sv_derived_from(arg,"OpenSSL::SSL::CTX"))) + croak("Usage: OpenSSL::BIO::new_buffer_ssl_connect(SSL_CTX)"); else { IV tmp=SvIV((SV *)SvRV(arg)); @@ -115,8 +116,8 @@ p5_BIO_new_ssl_connect(...) else arg=NULL; - if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX"))) - croak("Usage: SSLeay::BIO::new_ssl_connect(SSL_CTX)"); + if ((arg == NULL) || !(sv_derived_from(arg,"OpenSSL::SSL::CTX"))) + croak("Usage: OpenSSL::BIO::new_ssl_connect(SSL_CTX)"); else { IV tmp=SvIV((SV *)SvRV(arg)); @@ -140,7 +141,7 @@ p5_BIO_new(...) else if ((items == 2) && SvPOK(ST(1))) type=SvPV(ST(1),na); else - croak("Usage: SSLeay::BIO::new(type)"); + croak("Usage: OpenSSL::BIO::new(type)"); EXTEND(sp,1); if (strcmp(type,"connect") == 0) @@ -189,7 +190,7 @@ p5_BIO_push(b,bio) CODE: /* This reference will be reduced when the reference is * let go, and then when the BIO_free_all() is called - * inside the SSLeay library by the BIO with this + * inside the OpenSSL library by the BIO with this * pushed into */ bio->references++; RETVAL=BIO_push(b,bio); @@ -210,12 +211,12 @@ p5_BIO_pop(b) /* This BIO will either be one created in the * perl library, in which case it will have a perl * SV, otherwise it will have been created internally, - * inside SSLeay. For the 'pushed in', it needs + * inside OpenSSL. For the 'pushed in', it needs * the reference count decememted. */ arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); if (arg == NULL) { - arg=new_ref("SSLeay::BIO",(char *)bio,0); + arg=new_ref("OpenSSL::BIO",(char *)bio,0); BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); PUSHs(arg); } @@ -355,7 +356,7 @@ p5_BIO_next_bio(b) arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); if (arg == NULL) { - arg=new_ref("SSLeay::BIO",(char *)bio,0); + arg=new_ref("OpenSSL::BIO",(char *)bio,0); BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); bio->references++; PUSHs(arg); @@ -388,7 +389,7 @@ p5_BIO_set_callback(bio,cb,...) SV *arg2=NULL; CODE: if (items > 3) - croak("Usage: SSLeay::BIO::set_callback(bio,callback[,arg]"); + croak("Usage: OpenSSL::BIO::set_callback(bio,callback[,arg]"); if (items == 3) { arg2=sv_mortalcopy(ST(2)); diff --git a/perl/openssl_bn.xs b/perl/openssl_bn.xs index c15be3729a..359e906651 100644 --- a/perl/openssl_bn.xs +++ b/perl/openssl_bn.xs @@ -1,4 +1,5 @@ -#include "p5SSLeay.h" + +#include "openssl.h" int sv_to_BIGNUM(var,arg,name) BIGNUM **var; @@ -7,7 +8,7 @@ char *name; { int ret=1; - if (sv_derived_from(arg,"SSLeay::BN")) + if (sv_derived_from(arg,"OpenSSL::BN")) { IV tmp = SvIV((SV*)SvRV(arg)); *var = (BIGNUM *) tmp; @@ -16,14 +17,14 @@ char *name; SV *tmp=sv_newmortal(); *var=BN_new(); BN_set_word(*var,SvIV(arg)); - sv_setref_pv(tmp,"SSLeay::BN",(void*)*var); + sv_setref_pv(tmp,"OpenSSL::BN",(void*)*var); } else if (SvPOK(arg)) { char *ptr; STRLEN len; SV *tmp=sv_newmortal(); *var=BN_new(); - sv_setref_pv(tmp,"SSLeay::BN", (void*)*var); + sv_setref_pv(tmp,"OpenSSL::BN", (void*)*var); ptr=SvPV(arg,len); SvGROW(arg,len+1); ptr[len]='\0'; @@ -69,7 +70,7 @@ char *arg; LEAVE; } -MODULE = SSLeay::BN PACKAGE = SSLeay::BN PREFIX = p5_BN_ +MODULE = OpenSSL::BN PACKAGE = OpenSSL::BN PREFIX = p5_BN_ VERSIONCHECK: DISABLE @@ -83,7 +84,7 @@ p5_BN_new(...) EXTEND(sp,1); PUSHs(sv_newmortal()); bn=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)bn); void p5_BN_dup(a) @@ -95,7 +96,7 @@ p5_BN_dup(a) EXTEND(sp,1); PUSHs(sv_newmortal()); bn=BN_dup(a); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)bn); void p5_BN_rand(bits,...) @@ -107,14 +108,14 @@ p5_BN_rand(bits,...) PPCODE: pr_name("p5_BN_rand"); if ((items < 1) || (items > 3)) - croak("Usage: SSLeay::BN::rand(bits[,top_bit][,bottombit]"); + croak("Usage: OpenSSL::BN::rand(bits[,top_bit][,bottombit]"); if (items >= 2) top=(int)SvIV(ST(0)); if (items >= 3) bottom=(int)SvIV(ST(1)); EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); BN_rand(ret,bits,top,bottom); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); void p5_BN_bin2bn(a) @@ -126,7 +127,7 @@ p5_BN_bin2bn(a) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_bin2bn(a.dptr,a.dsize,NULL); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); void p5_BN_bn2bin(a) @@ -152,7 +153,7 @@ p5_BN_mpi2bn(a) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_mpi2bn(a.dptr,a.dsize,NULL); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); void p5_BN_bn2mpi(a) @@ -178,7 +179,7 @@ p5_BN_hex2bn(a) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_hex2bn(&ret,a.dptr); void @@ -191,7 +192,7 @@ p5_BN_dec2bn(a) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_dec2bn(&ret,a.dptr); SV * @@ -241,7 +242,7 @@ p5_BN_add(a,b) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_add(ret,a,b); void @@ -255,7 +256,7 @@ p5_BN_sub(a,b) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_sub(ret,a,b); void @@ -263,14 +264,16 @@ p5_BN_mul(a,b) BIGNUM *a; BIGNUM *b; PREINIT: + static BN_CTX *ctx=NULL; BIGNUM *ret; PPCODE: pr_name("p5_BN_mul"); + if (ctx == NULL) ctx=BN_CTX_new(); EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); - BN_mul(ret,a,b); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); + BN_mul(ret,a,b,ctx); void p5_BN_div(a,b) @@ -287,8 +290,8 @@ p5_BN_div(a,b) PUSHs(sv_newmortal()); div=BN_new(); mod=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)div); - sv_setref_pv(ST(1), "SSLeay::BN", (void*)mod); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)div); + sv_setref_pv(ST(1), "OpenSSL::BN", (void*)mod); BN_div(div,mod,a,b,ctx); void @@ -304,7 +307,7 @@ p5_BN_mod(a,b) EXTEND(sp,1); PUSHs(sv_newmortal()); rem=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)rem); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)rem); BN_mod(rem,a,b,ctx); void @@ -320,7 +323,7 @@ p5_BN_exp(a,p) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_exp(ret,a,p,ctx); void @@ -337,7 +340,7 @@ p5_BN_mod_mul(a,b,c) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_mod_mul(ret,a,b,c,ctx); void @@ -354,7 +357,7 @@ p5_BN_mod_exp(a,b,c) EXTEND(sp,1); PUSHs(sv_newmortal()); ret=BN_new(); - sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret); BN_mod_exp(ret,a,b,c,ctx); void @@ -371,20 +374,20 @@ p5_BN_generate_prime(...) PPCODE: pr_name("p5_BN_generate_prime"); if ((items < 0) || (items > 4)) - croak("Usage: SSLeay::BN::generate_prime(a[,strong][,callback][,cb_arg]"); + croak("Usage: OpenSSL::BN::generate_prime(a[,strong][,callback][,cb_arg]"); if (items >= 1) bits=(int)SvIV(ST(0)); if (items >= 2) strong=(int)SvIV(ST(1)); if (items >= 3) callback=ST(2); if (items == 4) cb_arg=ST(3); if (callback == NUL