* 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/trunk@6487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2004-06-21 16:36:19 +00:00
Родитель c89a62cd98
Коммит 17cb00b6e5
4 изменённых файлов: 57 добавлений и 9 удалений

Просмотреть файл

@ -1,3 +1,23 @@
Tue Jun 22 01:32:40 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* 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=.
Mon Jun 21 09:24:51 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_opendir): should set errno if error occurs

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -129,8 +129,10 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
VALUE arg, pass;
GetPKey(self, pkey);
rb_scan_args(argc, argv, "11", &arg, &pass);
if (FIXNUM_P(arg)) {
if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
dsa = DSA_new();
}
else if (FIXNUM_P(arg)) {
if (!(dsa = dsa_generate(FIX2INT(arg)))) {
ossl_raise(eDSAError, NULL);
}
@ -148,11 +150,11 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
BIO_reset(in);
dsa = PEM_read_bio_DSA_PUBKEY(in, NULL, NULL, NULL);
}
if (!dsa) {
if (!dsa) {
BIO_reset(in);
dsa = d2i_DSAPrivateKey_bio(in, NULL);
}
if (!dsa) {
if (!dsa) {
BIO_reset(in);
dsa = d2i_DSA_PUBKEY_bio(in, NULL);
}
@ -370,6 +372,12 @@ ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
return Qfalse;
}
OSSL_PKEY_BN(dsa, p);
OSSL_PKEY_BN(dsa, q);
OSSL_PKEY_BN(dsa, g);
OSSL_PKEY_BN(dsa, pub_key);
OSSL_PKEY_BN(dsa, priv_key);
/*
* INIT
*/
@ -394,6 +402,12 @@ Init_ossl_dsa()
rb_define_method(cDSA, "syssign", ossl_dsa_sign, 1);
rb_define_method(cDSA, "sysverify", ossl_dsa_verify, 2);
DEF_OSSL_PKEY_BN(cDSA, dsa, p);
DEF_OSSL_PKEY_BN(cDSA, dsa, q);
DEF_OSSL_PKEY_BN(cDSA, dsa, g);
DEF_OSSL_PKEY_BN(cDSA, dsa, pub_key);
DEF_OSSL_PKEY_BN(cDSA, dsa, priv_key);
rb_define_method(cDSA, "params", ossl_dsa_get_params, 0);
}

Просмотреть файл

@ -119,8 +119,10 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
VALUE arg, pass;
GetPKey(self, pkey);
rb_scan_args(argc, argv, "11", &arg, &pass);
if (FIXNUM_P(arg)) {
if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
rsa = RSA_new();
}
else if (FIXNUM_P(arg)) {
rsa = rsa_generate(FIX2INT(arg), NIL_P(pass) ? RSA_F4 : NUM2INT(pass));
if (!rsa) ossl_raise(eRSAError, NULL);
}