Class: OpenSSL::PKey::DH
- Inherits:
-
Object
- Object
- OpenSSL::PKey::DH
- Defined in:
- lib/net/ssh/transport/openssl.rb
Overview
This class is originally defined in the OpenSSL module. As needed, methods have been added to it by the Net::SSH module for convenience in dealing with SSH functionality.
Instance Method Summary collapse
-
#valid? ⇒ Boolean
Determines whether the pub_key for this key is valid.
Instance Method Details
#valid? ⇒ Boolean
Determines whether the pub_key for this key is valid. (This algorithm lifted more-or-less directly from OpenSSH, dh.c, dh_pub_is_valid.)
43 44 45 46 47 48 |
# File 'lib/net/ssh/transport/openssl.rb', line 43 def valid? return false if pub_key.nil? || pub_key < 0 bits_set = 0 pub_key.num_bits.times { |i| bits_set += 1 if pub_key.bit_set?(i) } return ( bits_set > 1 && pub_key < p ) end |