summaryrefslogtreecommitdiffstats
path: root/perl/openssl_bn.xs
diff options
context:
space:
mode:
Diffstat (limited to 'perl/openssl_bn.xs')
-rw-r--r--perl/openssl_bn.xs75
1 files changed, 39 insertions, 36 deletions
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 == NULL)
- ret=BN_generate_prime(bits,strong,NULL,NULL,NULL,NULL);
+ ret=BN_generate_prime(ret,bits,strong,NULL,NULL,NULL,NULL);
else
{
arg.cb=callback;
arg.arg=cb_arg;
- ret=BN_generate_prime(bits,strong,NULL,NULL,
+ ret=BN_generate_prime(ret,bits,strong,NULL,NULL,
generate_prime_callback,(char *)&arg);
}
@@ -393,7 +396,7 @@ p5_BN_generate_prime(...)
EXTEND(sp,1);
PUSHs(sv_newmortal());
- sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
+ sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret);
void
p5_BN_is_prime(p,...)
@@ -408,7 +411,7 @@ p5_BN_is_prime(p,...)
PPCODE:
pr_name("p5_BN_is_prime");
if ((items < 1) || (items > 4))
- croak("Usage: SSLeay::BN::is_prime(a[,ncheck][,callback][,callback_arg]");
+ croak("Usage: OpenSSL::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);
@@ -477,7 +480,7 @@ p5_BN_set_bit(a,b)
EXTEND(sp,1);
PUSHs(sv_newmortal());
ret=BN_dup(a);
- sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
+ sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret);
BN_set_bit(ret,b);
void
@@ -491,7 +494,7 @@ p5_BN_clear_bit(a,b)
EXTEND(sp,1);
PUSHs(sv_newmortal());
ret=BN_dup(a);
- sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
+ sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret);
BN_clear_bit(ret,b);
void
@@ -505,7 +508,7 @@ p5_BN_lshift(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);
if (b == 1)
BN_lshift1(ret,a);
else
@@ -522,7 +525,7 @@ p5_BN_rshift(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);
if (b == 1)
BN_rshift1(ret,a);
else
@@ -539,7 +542,7 @@ p5_BN_mask_bits(a,b)
EXTEND(sp,1);
PUSHs(sv_newmortal());
ret=BN_dup(a);
- sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
+ sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret);
BN_mask_bits(ret,b);
void
@@ -562,7 +565,7 @@ p5_BN_gcd(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_gcd(ret,a,b,ctx);
void
@@ -575,10 +578,10 @@ p5_BN_mod_inverse(a,mod)
PPCODE:
pr_name("p5_BN_mod_inverse");
if (ctx == NULL) ctx=BN_CTX_new();
- ret=BN_mod_inverse(a,mod,ctx);
+ ret=BN_mod_inverse(ret,a,mod,ctx);
EXTEND(sp,1);
PUSHs(sv_newmortal());
- sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
+ sv_setref_pv(ST(0), "OpenSSL::BN", (void*)ret);
void
p5_BN_DESTROY(bn)