Class OpenSSL::PKey::DH

  1. lib/net/ssh/transport/openssl.rb
Parent: Object

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.

Methods

public instance

  1. valid?

Public instance methods

valid? ()

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.)

[show source]
    # File lib/net/ssh/transport/openssl.rb, line 42
42:       def valid?
43:         return false if pub_key.nil? || pub_key < 0
44:         bits_set = 0
45:         pub_key.num_bits.times { |i| bits_set += 1 if pub_key.bit_set?(i) }
46:         return ( bits_set > 1 && pub_key < p )
47:       end