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 methods
Signs the given data.
[ show source ]
# File lib/net/ssh/util/openssl.rb, line 126
126: def ssh_do_sign( data )
127: sig = sign( OpenSSL::Digest::DSS1.new, data)
128: a1sig = OpenSSL::ASN1.decode( sig )
129:
130: sig_r = a1sig.value[0].value.to_s(2)
131: sig_s = a1sig.value[1].value.to_s(2)
132:
133: if sig_r.length > 20 || sig_s.length > 20
134: raise OpenSSL::PKey::DSAError, "bad sig size"
135: end
136:
137: sig_r = "\0" * ( 20 - sig_r.length ) + sig_r if sig_r.length < 20
138: sig_s = "\0" * ( 20 - sig_s.length ) + sig_s if sig_s.length < 20
139:
140: return sig_r + sig_s
141: end
Verifies the given signature matches the given data.
[ show source ]
# File lib/net/ssh/util/openssl.rb, line 115
115: def ssh_do_verify( sig, data )
116: sig_r = sig[0,20].unpack("H*")[0].to_i(16)
117: sig_s = sig[20,20].unpack("H*")[0].to_i(16)
118: a1sig = OpenSSL::ASN1::Sequence([
119: OpenSSL::ASN1::Integer(sig_r),
120: OpenSSL::ASN1::Integer(sig_s)
121: ])
122: return verify(OpenSSL::Digest::DSS1.new, a1sig.to_der, data)
123: end
Returns "ssh-dss", which is the description of this key type used by the SSH2 protocol.
[ show source ]
# File lib/net/ssh/util/openssl.rb, line 100
100: def ssh_type
101: "ssh-dss"
102: end
Converts the key to a blob, according to the SSH2 protocol.
[ show source ]
# File lib/net/ssh/util/openssl.rb, line 105
105: def to_blob
106: buffer = Net::SSH::Util::WriterBuffer.new
107: buffer.write_bignum( p )
108: buffer.write_bignum( q )
109: buffer.write_bignum( g )
110: buffer.write_bignum( pub_key )
111: return buffer.to_s
112: end