The implementation of a reader buffer that can read bignums and keys.
Methods
Public Instance methods
Read a bignum (OpenSSL::BN) from the buffer, in SSH2 format. It is essentially just a string, which is reinterpreted to be a bignum in binary format.
[ show source ]
# File lib/net/ssh/transport/ossl/buffer.rb, line 32
32: def read_bignum
33: data = read_string
34: return unless data
35: OpenSSL::BN.new( data, 2 )
36: end
Read a key from the buffer. The key will start with a string describing its type. The remainder of the key is defined by the type that was read.
[ show source ]
# File lib/net/ssh/transport/ossl/buffer.rb, line 41
41: def read_key
42: type = read_string
43: return ( type ? read_keyblob( type ) : nil )
44: end
Read a keyblob of the given type from the buffer, and return it as a key. Only RSA and DSA keys are supported.
[ show source ]
# File lib/net/ssh/transport/ossl/buffer.rb, line 48
48: def read_keyblob( type )
49: case type
50: when "ssh-dss"
51: key = OpenSSL::PKey::DSA.new
52: key.p = read_bignum
53: key.q = read_bignum
54: key.g = read_bignum
55: key.pub_key = read_bignum
56:
57: when "ssh-rsa"
58: key = OpenSSL::PKey::RSA.new
59: key.e = read_bignum
60: key.n = read_bignum
61:
62: else
63: raise NotImplementedError, "unsupported key type '#{type}'"
64: end
65:
66: return key
67: end