OpenSSL::PKey::DH#public_key

Issue #4418 has been updated by Hiroshi NAKAMURA.

Priority changed from Normal to Low

I agree with DH interface is confusing.

  • DH#p … DH parameter p
  • DH#g … DH parameter g
  • DH#public_key … DH parameter (DHParameterSpec in Java)
  • DH#priv_key … private value: S
  • DH#pub_key … exchange value: g^S mod p

We should have PKey::DH::Params class as same as PKey::EC::Point in the
future though I don’t know it’s good to define it as a subclass of DH.

Back to the topic, DH#public_key is needed for exchanging DH parameters
(p and g) so we cannot drop it. And we would need new method DH#params
as a copy of DH#public_key when we implement DH::Params class.

Bug #4418: OpenSSL::PKey::DH#public_key

Author: Ippei Obayashi
Status: Assigned
Priority: Low
Assignee: Hiroshi NAKAMURA
Category: ext
Target version:
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

=begin
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などのように「公開鍵とパラメータ」を取り出す需要はあまりない
ように思われるので、名前を変える、もしくはメソッドを廃止するのが良いのではと思われます。
=end