summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_pkey_dh.c
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-30 18:34:59 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-30 18:34:59 +0000
commit7922fdd795604d8e6a1589cfbb0f4b9f8cf21eb3 (patch)
treeabb4f202eca96583c1ac828f469edcbdfa88a91e /ext/openssl/ossl_pkey_dh.c
parent907911fedadd71950413f555342bcb8a18252553 (diff)
* ext/openssl/ossl_pkey_dh.c (ossl_dh_initialize): should create
empty pkey object if no argument is passed. [ruby-talk:103328] * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize): ditto. * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_initialize): ditto. * ext/openssl/ossl_pkey_dh.c: add new methods: OpenSSL::PKey::DH#p, OpenSSL::PKey::DH#p=, OpenSSL::PKey::DH#g, OpenSSL::PKey::DH#g=, OpenSSL::PKey::DH#pub_key, OpenSSL::PKey::DH#pub_key=, OpenSSL::PKey::DH#priv_key and OpenSSL::PKey::DH#priv_key=. * ext/openssl/ossl_pkey_dsa.c: add new methods: OpenSSL::PKey::DSA#p, OpenSSL::PKey::DSA#p=, OpenSSL::PKey::DSA#q, OpenSSL::PKey::DSA#q=, OpenSSL::PKey::DSA#g, OpenSSL::PKey::DSA#g=, OpenSSL::PKey::DSA#pub_key, OpenSSL::PKey::DSA#pub_key=, OpenSSL::PKey::DSA#priv_key and OpenSSL::PKey::DSA#priv_key=. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_pkey_dh.c')
-rw-r--r--ext/openssl/ossl_pkey_dh.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index 5b91386..7070cf0 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -129,8 +129,10 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
VALUE arg, gen;
GetPKey(self, pkey);
- rb_scan_args(argc, argv, "11", &arg, &gen);
- if (FIXNUM_P(arg)) {
+ if(rb_scan_args(argc, argv, "02", &arg, &gen) == 0) {
+ dh = DH_new();
+ }
+ else if (FIXNUM_P(arg)) {
if (!NIL_P(gen)) {
g = FIX2INT(gen);
}
@@ -151,7 +153,7 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
}
if (!EVP_PKEY_assign_DH(pkey, dh)) {
DH_free(dh);
- ossl_raise(eRSAError, NULL);
+ ossl_raise(eDHError, NULL);
}
return self;
}
@@ -342,6 +344,11 @@ ossl_dh_compute_key(VALUE self, VALUE pub)
return str;
}
+OSSL_PKEY_BN(dh, p);
+OSSL_PKEY_BN(dh, g);
+OSSL_PKEY_BN(dh, pub_key);
+OSSL_PKEY_BN(dh, priv_key);
+
/*
* INIT
*/
@@ -368,6 +375,11 @@ Init_ossl_dh()
rb_define_method(cDH, "generate_key!", ossl_dh_generate_key, 0);
rb_define_method(cDH, "compute_key", ossl_dh_compute_key, 1);
+ DEF_OSSL_PKEY_BN(cDH, dh, p);
+ DEF_OSSL_PKEY_BN(cDH, dh, g);
+ DEF_OSSL_PKEY_BN(cDH, dh, pub_key);
+ DEF_OSSL_PKEY_BN(cDH, dh, priv_key);
+
rb_define_method(cDH, "params", ossl_dh_get_params, 0);
}