1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/openssl] bn: make BN.pseudo_rand{,_range} an alias of BN.rand{,_range}

BN_pseudo_rand() and BN_pseudo_rand_range() are deprecated in
OpenSSL 3.0. Since they are identical to their non-'pseudo' version
anyway, let's make them alias.

https://github.com/ruby/openssl/commit/2d34e85ddf
This commit is contained in:
Kazuki Yamaguchi 2021-03-21 00:20:04 +09:00
parent 1b5ccc8a0c
commit e19186707a
2 changed files with 6 additions and 16 deletions

View file

@ -826,12 +826,6 @@ BIGNUM_SELF_SHIFT(rshift)
*/ */
BIGNUM_RAND(rand) BIGNUM_RAND(rand)
/*
* Document-method: OpenSSL::BN.pseudo_rand
* BN.pseudo_rand(bits [, fill [, odd]]) -> aBN
*/
BIGNUM_RAND(pseudo_rand)
#define BIGNUM_RAND_RANGE(func) \ #define BIGNUM_RAND_RANGE(func) \
static VALUE \ static VALUE \
ossl_bn_s_##func##_range(VALUE klass, VALUE range) \ ossl_bn_s_##func##_range(VALUE klass, VALUE range) \
@ -857,14 +851,6 @@ BIGNUM_RAND(pseudo_rand)
*/ */
BIGNUM_RAND_RANGE(rand) BIGNUM_RAND_RANGE(rand)
/*
* Document-method: OpenSSL::BN.pseudo_rand_range
* call-seq:
* BN.pseudo_rand_range(range) -> aBN
*
*/
BIGNUM_RAND_RANGE(pseudo_rand)
/* /*
* call-seq: * call-seq:
* BN.generate_prime(bits, [, safe [, add [, rem]]]) => bn * BN.generate_prime(bits, [, safe [, add [, rem]]]) => bn
@ -1278,9 +1264,9 @@ Init_ossl_bn(void)
* get_word */ * get_word */
rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, -1); rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, -1);
rb_define_singleton_method(cBN, "pseudo_rand", ossl_bn_s_pseudo_rand, -1);
rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1); rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1);
rb_define_singleton_method(cBN, "pseudo_rand_range", ossl_bn_s_pseudo_rand_range, 1); rb_define_alias(rb_singleton_class(cBN), "pseudo_rand", "rand");
rb_define_alias(rb_singleton_class(cBN), "pseudo_rand_range", "rand_range");
rb_define_singleton_method(cBN, "generate_prime", ossl_bn_s_generate_prime, -1); rb_define_singleton_method(cBN, "generate_prime", ossl_bn_s_generate_prime, -1);
rb_define_method(cBN, "prime?", ossl_bn_is_prime, -1); rb_define_method(cBN, "prime?", ossl_bn_is_prime, -1);

View file

@ -248,6 +248,10 @@ class OpenSSL::TestBN < OpenSSL::TestCase
r5 = OpenSSL::BN.rand_range(256) r5 = OpenSSL::BN.rand_range(256)
assert_include(0..255, r5) assert_include(0..255, r5)
} }
# Aliases
assert_include(128..255, OpenSSL::BN.pseudo_rand(8))
assert_include(0..255, OpenSSL::BN.pseudo_rand_range(256))
end end
begin begin