summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-24 16:27:11 +0000
committerrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-24 16:27:11 +0000
commit8cbd74a362a918b6ce332d6240432318165527b0 (patch)
treea0da55ba61e705738f68f0fc709862f34e53b465
parentb3d3d52cd69cb6ea3848e5eb5b4b18318850142f (diff)
openssl: rename EC#generate_key to EC#generate_key!
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_generate_key): Fix up RDoc. (Init_ossl_ec): Rename EC#generate_key to EC#generate_key!. Make the old name an alias of #generate_key!. This change is for consistency with other PKey types. [ruby-core:45541] [Bug #6567] * test/openssl/test_pkey_ec.rb: Use EC#generate_key! instead of EC#generate_key. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--ext/openssl/ossl_pkey_ec.c15
-rw-r--r--test/openssl/test_pkey_ec.rb4
3 files changed, 24 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 13d7b3efb5d..6d9b83dd003 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed May 25 00:37:16 2016 Kazuki Yamaguchi <k@rhe.jp>
+
+ * ext/openssl/ossl_pkey_ec.c (ossl_ec_key_generate_key): Fix up RDoc.
+ (Init_ossl_ec): Rename EC#generate_key to EC#generate_key!. Make the
+ old name an alias of #generate_key!. This change is for consistency
+ with other PKey types. [ruby-core:45541] [Bug #6567]
+
+ * test/openssl/test_pkey_ec.rb: Use EC#generate_key! instead of
+ EC#generate_key.
+
Wed May 25 00:23:05 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/ruby.h (rb_scan_args_set): check the arity after
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c
index ab6209c7ed8..74bc7abea8d 100644
--- a/ext/openssl/ossl_pkey_ec.c
+++ b/ext/openssl/ossl_pkey_ec.c
@@ -584,9 +584,17 @@ static VALUE ossl_ec_key_to_text(VALUE self)
/*
* call-seq:
- * key.generate_key => self
+ * key.generate_key! => self
*
- * See the OpenSSL documentation for EC_KEY_generate_key()
+ * Generates a new random private and public key.
+ *
+ * See also the OpenSSL documentation for EC_KEY_generate_key()
+ *
+ * === Example
+ * ec = OpenSSL::PKey::EC.new("prime256v1")
+ * p ec.private_key # => nil
+ * ec.generate_key!
+ * p ec.private_key # => #<OpenSSL::BN XXXXXX>
*/
static VALUE ossl_ec_key_generate_key(VALUE self)
{
@@ -1632,7 +1640,8 @@ void Init_ossl_ec(void)
set/get asn1_flag (can use ruby to call self.group.asn1_flag)
set/get precompute_mult
*/
- rb_define_method(cEC, "generate_key", ossl_ec_key_generate_key, 0);
+ rb_define_method(cEC, "generate_key!", ossl_ec_key_generate_key, 0);
+ rb_define_alias(cEC, "generate_key", "generate_key!");
rb_define_method(cEC, "check_key", ossl_ec_key_check_key, 0);
rb_define_method(cEC, "dh_compute_key", ossl_ec_key_dh_compute_key, 1);
diff --git a/test/openssl/test_pkey_ec.rb b/test/openssl/test_pkey_ec.rb
index 302259b242e..712507f609a 100644
--- a/test/openssl/test_pkey_ec.rb
+++ b/test/openssl/test_pkey_ec.rb
@@ -16,7 +16,7 @@ class OpenSSL::TestEC < OpenSSL::TestCase
group = OpenSSL::PKey::EC::Group.new(curve)
key = OpenSSL::PKey::EC.new(group)
- key.generate_key
+ key.generate_key!
@groups << group
@keys << key
@@ -127,7 +127,7 @@ class OpenSSL::TestEC < OpenSSL::TestCase
def test_dh_compute_key
for key in @keys
k = OpenSSL::PKey::EC.new(key.group)
- k.generate_key
+ k.generate_key!
puba = key.public_key
pubb = k.public_key