Class: Orthrus::SSH::DSAPublicKey
- Includes:
- DSA
- Defined in:
- lib/orthrus/ssh/dsa.rb
Instance Attribute Summary
Attributes inherited from Key
Class Method Summary collapse
Instance Method Summary collapse
-
#verify(sig, data) ⇒ Object
Adapted from net-ssh Verifies the given signature matches the given data.
Methods included from DSA
#initialize, #public_identity, #type
Methods inherited from Key
#==, #dsa?, #fingerprint, #initialize, #inspect, #rsa?
Class Method Details
.parse(data) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/orthrus/ssh/dsa.rb', line 52 def self.parse(data) raw = Utils.decode64 data b = Buffer.new raw type = b.read_string unless type == "ssh-dss" raise "Unvalid key data" end k = OpenSSL::PKey::DSA.new k.p = b.read_bignum k.q = b.read_bignum k.g = b.read_bignum k.pub_key = b.read_bignum new k end |
Instance Method Details
#verify(sig, data) ⇒ Object
Adapted from net-ssh Verifies the given signature matches the given data.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/orthrus/ssh/dsa.rb', line 75 def verify(sig, data) sig_r = sig[0,20].unpack("H*")[0].to_i(16) sig_s = sig[20,20].unpack("H*")[0].to_i(16) a1sig = OpenSSL::ASN1::Sequence([ OpenSSL::ASN1::Integer(sig_r), OpenSSL::ASN1::Integer(sig_s) ]) super a1sig.to_der, data end |