rename PublicKey::Base#raw to #rfc4253

This commit is contained in:
Ben Toews 2019-02-21 12:04:21 -07:00
Родитель f7468f4f5e
Коммит ce06217fed
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E9C423BE17EFEE70
9 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@ -16,10 +16,10 @@ module SSHData
def fingerprint(md5: false) def fingerprint(md5: false)
if md5 if md5
# colon separated, hex encoded md5 digest # colon separated, hex encoded md5 digest
OpenSSL::Digest::MD5.digest(raw).unpack("H2" * 16).join(":") OpenSSL::Digest::MD5.digest(rfc4253).unpack("H2" * 16).join(":")
else else
# base64 encoded sha256 digest with b64 padding stripped # base64 encoded sha256 digest with b64 padding stripped
Base64.strict_encode64(OpenSSL::Digest::SHA256.digest(raw))[0...-1] Base64.strict_encode64(OpenSSL::Digest::SHA256.digest(rfc4253))[0...-1]
end end
end end
@ -33,10 +33,10 @@ module SSHData
raise "implement me" raise "implement me"
end end
# Raw encoding of public key. # RFC4253 binary encoding of public key.
# #
# Returns a binary String. # Returns a binary String.
def raw def rfc4253
raise "implement me" raise "implement me"
end end
@ -46,7 +46,7 @@ module SSHData
# #
# Returns a String key. # Returns a String key.
def openssh(comment: nil) def openssh(comment: nil)
[algo, Base64.strict_encode64(raw), comment].compact.join(" ") [algo, Base64.strict_encode64(rfc4253), comment].compact.join(" ")
end end
# Is this public key equal to another public key? # Is this public key equal to another public key?

Просмотреть файл

@ -80,10 +80,10 @@ module SSHData
openssl.verify(OpenSSL::Digest::SHA1.new, openssl_sig, signed_data) openssl.verify(OpenSSL::Digest::SHA1.new, openssl_sig, signed_data)
end end
# Raw encoding of public key. # RFC4253 binary encoding of public key.
# #
# Returns a binary String. # Returns a binary String.
def raw def rfc4253
Encoding.encode_fields( Encoding.encode_fields(
[:string, algo], [:string, algo],
[:mpint, p], [:mpint, p],

Просмотреть файл

@ -100,10 +100,10 @@ module SSHData
openssl.verify(digest.new, openssl_sig, signed_data) openssl.verify(digest.new, openssl_sig, signed_data)
end end
# Raw encoding of public key. # RFC4253 binary encoding of public key.
# #
# Returns a binary String. # Returns a binary String.
def raw def rfc4253
Encoding.encode_fields( Encoding.encode_fields(
[:string, algo], [:string, algo],
[:string, curve], [:string, curve],

Просмотреть файл

@ -46,10 +46,10 @@ module SSHData
end end
end end
# Raw encoding of public key. # RFC4253 binary encoding of public key.
# #
# Returns a binary String. # Returns a binary String.
def raw def rfc4253
Encoding.encode_fields( Encoding.encode_fields(
[:string, algo], [:string, algo],
[:string, pk], [:string, pk],

Просмотреть файл

@ -32,10 +32,10 @@ module SSHData
openssl.verify(OpenSSL::Digest::SHA1.new, raw_sig, signed_data) openssl.verify(OpenSSL::Digest::SHA1.new, raw_sig, signed_data)
end end
# Raw encoding of public key. # RFC4253 binary encoding of public key.
# #
# Returns a binary String. # Returns a binary String.
def raw def rfc4253
Encoding.encode_fields( Encoding.encode_fields(
[:string, algo], [:string, algo],
[:mpint, e], [:mpint, e],

Просмотреть файл

@ -87,7 +87,7 @@ describe SSHData::PublicKey::DSA do
end end
it "can be rencoded" do it "can be rencoded" do
expect(openssh_key.raw).to eq(fixture("dsa_leaf_for_rsa_ca.pub", binary: true)) expect(openssh_key.rfc4253).to eq(fixture("dsa_leaf_for_rsa_ca.pub", binary: true))
end end
it "can verify certificate signatures" do it "can verify certificate signatures" do

Просмотреть файл

@ -8,7 +8,7 @@ describe SSHData::PublicKey::ECDSA do
end end
it "can be rencoded" do it "can be rencoded" do
expect(openssh_key.raw).to eq(fixture("ecdsa_leaf_for_rsa_ca.pub", binary: true)) expect(openssh_key.rfc4253).to eq(fixture("ecdsa_leaf_for_rsa_ca.pub", binary: true))
end end
it "can verify certificate signatures" do it "can verify certificate signatures" do

Просмотреть файл

@ -54,7 +54,7 @@ describe SSHData::PublicKey::ED25519 do
end end
it "can be rencoded" do it "can be rencoded" do
expect(openssh_key.raw).to eq(fixture("ed25519_leaf_for_rsa_ca.pub", binary: true)) expect(openssh_key.rfc4253).to eq(fixture("ed25519_leaf_for_rsa_ca.pub", binary: true))
end end
it "can verify certificate signatures" do it "can verify certificate signatures" do

Просмотреть файл

@ -60,7 +60,7 @@ describe SSHData::PublicKey::RSA do
end end
it "can be rencoded" do it "can be rencoded" do
expect(openssh_key.raw).to eq(fixture("rsa_leaf_for_rsa_ca.pub", binary: true)) expect(openssh_key.rfc4253).to eq(fixture("rsa_leaf_for_rsa_ca.pub", binary: true))
end end
it "can verify certificate signatures" do it "can verify certificate signatures" do