summaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_rand.c
diff options
context:
space:
mode:
authortechnorama <technorama@ruby-lang.org>2007-12-25 11:31:51 +0000
committertechnorama <technorama@ruby-lang.org>2007-12-25 11:31:51 +0000
commit18280969c32c9b4c63e91bc4ad832166638ef7d1 (patch)
tree79a2156c273cd28f2419303aa960cfb98dfdba37 /ext/openssl/ossl_rand.c
parent893b9693878bbcf6f75f34a34f4e7e6505a9f965 (diff)
downloadruby-openssl-history-18280969c32c9b4c63e91bc4ad832166638ef7d1.tar.gz
* ext/openssl/ossl_ssl.c: Only show a warning if the default
DH callback is actually used. * ext/openssl/ossl_rand.c: New method: random_add(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_rand.c')
-rw-r--r--ext/openssl/ossl_rand.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index 3b6eaf3..c22a735 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -27,6 +27,12 @@ VALUE eRandomError;
/*
* Private
*/
+
+/*
+ * call-seq:
+ * seed(str) -> str
+ *
+ */
static VALUE
ossl_rand_seed(VALUE self, VALUE str)
{
@@ -38,6 +44,20 @@ ossl_rand_seed(VALUE self, VALUE str)
/*
* call-seq:
+ * add(str, entropy) -> self
+ *
+ */
+static VALUE
+ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
+{
+ StringValue(str);
+ RAND_add(RSTRING_PTR(str), RSTRING_LEN(str), NUM2DBL(entropy));
+
+ return self;
+}
+
+/*
+ * call-seq:
* load_random_file(filename) -> true
*
*/
@@ -166,6 +186,7 @@ Init_ossl_rand()
eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
DEFMETH(mRandom, "seed", ossl_rand_seed, 1);
+ DEFMETH(mRandom, "random_add", ossl_rand_add, 2);
DEFMETH(mRandom, "load_random_file", ossl_rand_load_file, 1);
DEFMETH(mRandom, "write_random_file", ossl_rand_write_file, 1);
DEFMETH(mRandom, "random_bytes", ossl_rand_bytes, 1);