class SSHData::PublicKey::Base
Attributes
Public Class Methods
# File lib/ssh_data/public_key/base.rb, line 6 def initialize(**kwargs) @algo = kwargs[:algo] end
Public Instance Methods
Is this public key equal to another public key?
other - Another SSHData::PublicKey::Base
instance to compare with.
Returns boolean.
# File lib/ssh_data/public_key/base.rb, line 66 def ==(other) other.class == self.class end
Calculate the fingerprint of this public key.
md5: - Bool of whether to generate an MD5 fingerprint instead of the
default SHA256.
Returns a String fingerprint.
# File lib/ssh_data/public_key/base.rb, line 16 def fingerprint(md5: false) if md5 # colon separated, hex encoded md5 digest OpenSSL::Digest::MD5.digest(rfc4253).unpack("H2" * 16).join(":") else # base64 encoded sha256 digest with b64 padding stripped Base64.strict_encode64(OpenSSL::Digest::SHA256.digest(rfc4253))[0...-1] end end
OpenSSH public key in authorized_keys format (see sshd(8) manual page).
comment - Optional String comment to append.
Returns a String key.
# File lib/ssh_data/public_key/base.rb, line 57 def openssh(comment: nil) [algo, Base64.strict_encode64(rfc4253), comment].compact.join(" ") end
RFC4253 binary encoding of the public key.
Returns a binary String.
# File lib/ssh_data/public_key/base.rb, line 48 def rfc4253 raise "implement me" end
Make an SSH signature.
signed_data - The String message over which to calculated the signature.
Returns a binary String signature.
# File lib/ssh_data/public_key/base.rb, line 31 def sign(signed_data) raise "implement me" end
Verify an SSH signature.
signed_data - The String message that the signature was calculated over. signature - The binary String signature with SSH encoding.
Returns boolean.
# File lib/ssh_data/public_key/base.rb, line 41 def verify(signed_data, signature) raise "implement me" end