summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_bn.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-15 01:54:40 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-15 01:54:40 +0000
commitd89b8333c5bf7b319f0ab774951dfa53993ebdc1 (patch)
tree65e5b11627653d6cc3c5fe49f62b5b1c6899fdd5 /ext/openssl/ossl_bn.c
parent9d24a847b8e6ecd92e735601a1102270b9507fbb (diff)
* ext/openssl/ossl_digest.c (ossl_digest_initialize): [ruby-dev:25198]
* lib/cgi/session.rb (CGI::Session::initialize): generate new session if given session_id does not exist. [ruby-list:40368] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_bn.c')
-rw-r--r--ext/openssl/ossl_bn.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index c3a371a..47a607e 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -107,11 +107,11 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
VALUE str, bs;
int base = 10;
- GetBN(self, bn);
-
if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
base = NUM2INT(bs);
}
+ StringValue(str);
+ GetBN(self, bn);
if (RTEST(rb_obj_is_kind_of(str, cBN))) {
BIGNUM *other;
@@ -121,8 +121,6 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
}
return self;
}
- str = rb_String(str);
- StringValue(str);
switch (base) {
case 0:
@@ -159,11 +157,10 @@ ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
int base = 10, len;
char *buf;
- GetBN(self, bn);
-
if (rb_scan_args(argc, argv, "01", &bs) == 1) {
base = NUM2INT(bs);
}
+ GetBN(self, bn);
switch (base) {
case 0:
len = BN_bn2mpi(bn, NULL);
@@ -380,11 +377,12 @@ BIGNUM_BIT(mask_bits);
static VALUE
ossl_bn_is_bit_set(VALUE self, VALUE bit)
{
+ int b;
BIGNUM *bn;
+ b = NUM2INT(bit);
GetBN(self, bn);
-
- if (BN_is_bit_set(bn, NUM2INT(bit))) {
+ if (BN_is_bit_set(bn, b)) {
return Qtrue;
}
return Qfalse;
@@ -397,8 +395,8 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
BIGNUM *bn, *result; \
int b; \
VALUE obj; \
- GetBN(self, bn); \
b = NUM2INT(bits); \
+ GetBN(self, bn); \
if (!(result = BN_new())) { \
ossl_raise(eBNError, NULL); \
} \
@@ -550,11 +548,10 @@ ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
VALUE vchecks;
int checks = BN_prime_checks;
- GetBN(self, bn);
-
if (rb_scan_args(argc, argv, "01", &vchecks) == 0) {
checks = NUM2INT(vchecks);
}
+ GetBN(self, bn);
switch (BN_is_prime(bn, checks, NULL, ossl_bn_ctx, NULL)) {
case 1:
return Qtrue;
@@ -574,13 +571,12 @@ ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
VALUE vchecks, vtrivdiv;
int checks = BN_prime_checks, do_trial_division = 1;
- GetBN(self, bn);
-
rb_scan_args(argc, argv, "02", &vchecks, &vtrivdiv);
if (!NIL_P(vchecks)) {
checks = NUM2INT(vchecks);
}
+ GetBN(self, bn);
/* handle true/false */
if (vtrivdiv == Qfalse) {
do_trial_division = 0;