diff options
Diffstat (limited to 'ext/openssl/ossl_rand.c')
-rw-r--r-- | ext/openssl/ossl_rand.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c index 4a4f9dd5bf..659dc818b6 100644 --- a/ext/openssl/ossl_rand.c +++ b/ext/openssl/ossl_rand.c @@ -120,36 +120,6 @@ ossl_rand_bytes(VALUE self, VALUE len) return str; } -#if defined(HAVE_RAND_PSEUDO_BYTES) -/* - * call-seq: - * pseudo_bytes(length) -> string - * - * Generates a String with _length_ number of pseudo-random bytes. - * - * Pseudo-random byte sequences generated by ::pseudo_bytes will be unique if - * they are of sufficient length, but are not necessarily unpredictable. - * - * === Example - * - * OpenSSL::Random.pseudo_bytes(12) - * #=> "..." - */ -static VALUE -ossl_rand_pseudo_bytes(VALUE self, VALUE len) -{ - VALUE str; - int n = NUM2INT(len); - - str = rb_str_new(0, n); - if (RAND_pseudo_bytes((unsigned char *)RSTRING_PTR(str), n) < 1) { - ossl_raise(eRandomError, NULL); - } - - return str; -} -#endif - #ifdef HAVE_RAND_EGD /* * call-seq: @@ -219,8 +189,8 @@ Init_ossl_rand(void) rb_define_module_function(mRandom, "load_random_file", ossl_rand_load_file, 1); rb_define_module_function(mRandom, "write_random_file", ossl_rand_write_file, 1); rb_define_module_function(mRandom, "random_bytes", ossl_rand_bytes, 1); -#if defined(HAVE_RAND_PSEUDO_BYTES) - rb_define_module_function(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1); +#if OPENSSL_VERSION_NUMBER < 0x10101000 || defined(LIBRESSL_VERSION_NUMBER) + rb_define_alias(rb_singleton_class(mRandom), "pseudo_bytes", "random_bytes"); #endif #ifdef HAVE_RAND_EGD rb_define_module_function(mRandom, "egd", ossl_rand_egd, 1); |