diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-01-10 00:43:38 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-01-10 00:43:38 +0000 |
commit | c8c2b576e89e238a6aead38b3cc40a2d3f07f751 (patch) | |
tree | b74df95f5df51dffcc40ba6b9df310f7f502dc4d /ossl_bn.c | |
parent | c7018dfc98fa5ef076caf6dc3186e7271a862be3 (diff) | |
download | ruby-openssl-history-c8c2b576e89e238a6aead38b3cc40a2d3f07f751.tar.gz |
* OpenSSL 0.9.6c support (BN)
* MS_CALLBACK to ossl_pkey_*.c
* Memory checking with OSSL_DEBUG
* API doc style change
Diffstat (limited to 'ossl_bn.c')
-rw-r--r-- | ossl_bn.c | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -481,23 +481,28 @@ BIGNUM_SHIFT(rshift); BIGNUM_RAND(rand); BIGNUM_RAND(pseudo_rand); -static VALUE -ossl_bn_s_rand_range(VALUE klass, VALUE range) -{ - ossl_bn *bnp = NULL; - BIGNUM *result = NULL; - - OSSL_Check_Type(range, cBN); - GetBN(range, bnp); - - if (!(result = BN_new())) - OSSL_Raise(eBNError, ""); - - if (!BN_rand_range(result, bnp->bignum)) - OSSL_Raise(eBNError, ""); - - return ossl_bn_new_nodup(result); +#define BIGNUM_RAND_RANGE(func) \ + static VALUE \ + ossl_bn_s_##func##_range(VALUE klass, VALUE range) \ + { \ + ossl_bn *bnp = NULL; \ + BIGNUM *result = NULL; \ + \ + OSSL_Check_Type(range, cBN); \ + GetBN(range, bnp); \ + \ + if (!(result = BN_new())) \ + OSSL_Raise(eBNError, ""); \ + \ + if (!BN_##func##_range(result, bnp->bignum)) \ + OSSL_Raise(eBNError, ""); \ + \ + return ossl_bn_new_nodup(result); \ } +BIGNUM_RAND_RANGE(rand); +#if OPENSSL_VERSION_NUMBER >= 0x0090603fL /* "OpenSSL 0.9.6c 21 dec 2001" */ + BIGNUM_RAND_RANGE(pseudo_rand); +#endif static VALUE ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass) @@ -696,6 +701,9 @@ Init_bn(VALUE module) rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, 3); rb_define_singleton_method(cBN, "pseudo_rand", ossl_bn_s_pseudo_rand, 3); rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1); +#if OPENSSL_VERSION_NUMBER >= 0x0090603fL /* "OpenSSL 0.9.6c 21 dec 2001" */ + rb_define_singleton_method(cBN, "pseudo_rand_range", ossl_bn_s_pseudo_rand_range, 1); +#endif rb_define_singleton_method(cBN, "generate_prime", ossl_bn_s_generate_prime, -1); rb_define_method(cBN, "num_bytes", ossl_bn_num_bytes, 0); |