diff options
author | technorama <technorama@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 11:31:51 +0000 |
---|---|---|
committer | technorama <technorama@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 11:31:51 +0000 |
commit | 0a79e4c9b1413ccda6133405cc9523a605728531 (patch) | |
tree | 52bdce8a8a457f6cfda0c7f5de46b5f1dd7fa6b5 /ext | |
parent | 1bbc1e11c5153c45a2e6cbf6247cc579746be077 (diff) | |
download | ruby-0a79e4c9b1413ccda6133405cc9523a605728531.tar.gz ruby-0a79e4c9b1413ccda6133405cc9523a605728531.tar.xz ruby-0a79e4c9b1413ccda6133405cc9523a605728531.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@14696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl_rand.c | 21 | ||||
-rw-r--r-- | ext/openssl/ossl_ssl.c | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c index 3b6eaf3f4..c22a7357b 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); diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index c345a3fdc..7b2620e4b 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -270,6 +270,8 @@ ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength) static DH* ossl_default_tmp_dh_callback(SSL *ssl, int is_export, int keylength) { + rb_warning("using default DH parameters."); + switch(keylength){ case 512: return OSSL_DEFAULT_DH_512; @@ -463,7 +465,6 @@ ossl_sslctx_setup(VALUE self) SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback); } else{ - rb_warning("using default DH parameters."); SSL_CTX_set_tmp_dh_callback(ctx, ossl_default_tmp_dh_callback); } #endif |