Bug #4418
OpenSSL::PKey::DH#public_key
| Status: | Assigned | Start date: | 02/21/2011 | |
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | ext | |||
| Target version: | 2.0.0 | |||
| ruby -v: | ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] |
Description
OpenSSL::PKey::DH#public_key がその名前に反して DH パラメータのみを複製して返しています。 require 'openssl' dh = OpenSSL::PKey::DH.generate(1024) # => パラメータと鍵の生成、時間がかかる p dh.pub_key # => 公開鍵の整数を表示 p dh.public_key.pub_key # => nil DH の場合、RSAなどのように「公開鍵とパラメータ」を取り出す需要はあまりない ように思われるので、名前を変える、もしくはメソッドを廃止するのが良いのではと思われます。
History
Updated by MartinBosslet (Martin Bosslet) over 1 year ago
- File fix_dh_dup.tar.gz added
Hi, I had been doing some work in this area, so I looked into this. The problem is that DH parameters are duplicated, but this only duplicates the generator g and the prime p, but not the public key, which can be derived from g and p. The easiest way to fix this is to simply dup the existing value and assign it to the dup'ed DH instance. Patch and test are attached. Regards, Martin
Updated by naruse (Yui NARUSE) over 1 year ago
- Status changed from Open to Assigned
- Assignee set to nahi (Hiroshi Nakamura)
Updated by ohai (Ippei Obayashi) over 1 year ago
Hi, Martin Your fix is appropriate. However, I feel no one needs this (copying only parameters and a public key) method, so it is also a reasonable idea that we simply remove or rename the method.
Updated by MartinBosslet (Martin Bosslet) about 1 year ago
Hi Ippei,
I see your point now. There is some confusion if we look at the EC key agreement interface. There, EC#dh_compute_key takes what is returned by EC#public_key as a parameter, which could be assumed the natural equivalent to what DH#public_key returns. Maybe DH#compute_key could additionally support a version where it takes the "public_key" instead of the "pub_key". This way we would achieve consistency among DH and ECDH interfaces and DH#public_key wouldn't be as useless anymore :)
What do you think?
Regards, Martin
Updated by ohai (Ippei Obayashi) about 1 year ago
Hi, Martin
RSA#public_key returns a RSA object, DSA#public_key returns a DSA object, but EC#public_key does not return a EC object (it returns a EC::Point object). I feel this fact is also confusing.
Updated by MartinBosslet (Martin Bosslet) about 1 year ago
Hello Ippei,
I thought this to be confusing, too - that EC#public_key is an EC::Point instead of an instance of EC itself. But when I had a closer look again, I noticed that EC::Point is in fact a subclass of EC, so the analogy to RSA and DSA is kept. So we could still have the version where DH#compute_key and EC#dh_compute_key take the return value of the corresponding #public_key methods, relying on API common to EC and DH.
Best regards, Martin
Updated by nahi (Hiroshi Nakamura) 11 months ago
- Priority changed from Normal to Low
Updated by MartinBosslet (Martin Bosslet) 11 months ago
Updated by nahi (Hiroshi Nakamura) 11 months ago
- Target version set to 2.0.0