Class: OpenSSL::BN

Inherits:
Object
  • Object
show all
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

Instance Method Details

#to_sshObject

Converts a BN object to a string. The format used is that which is required by the SSH2 protocol.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/net/ssh/transport/openssl.rb', line 11

def to_ssh
  if zero?
    return [0].pack("N")
  else
    buf = to_s(2)
    if buf.getbyte(0)[7] == 1
      return [buf.length + 1, 0, buf].pack("NCA*")
    else
      return [buf.length, buf].pack("NA*")
    end
  end
end