7575 end
7676 end
7777
78+ context "when parsing an ecdsa key string" do
79+ it "should parse it and have the right values for each attribute" do
80+ key_string = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyN" +
81+ "TYAAAAIbmlzdHAyNTYAAABBBC4gXA5naQtjcKu90NJ7A4jQ1U" +
82+ "gxYGdnndJyr4PSZJ59qJUzkoH3VgdTlseXbIZHwO4k2gNcFpa" +
83+ "Mq5gqVRobAwU="
84+ key = SSHScan ::Crypto ::PublicKey . new ( key_string )
85+ expect ( key ) . to be_kind_of SSHScan ::Crypto ::PublicKey
86+ expect ( key . valid? ) . to be true
87+ expect ( key . type ) . to eq ( "ecdsa-sha2-nistp256" )
88+ expect ( key . length ) . to be 520
89+ expect ( key . fingerprint_md5 ) . to eq ( "be:04:32:74:c6:63:fa:24:c3:c6:78:c2:cd:d2:3e:f4" )
90+ expect ( key . fingerprint_sha1 ) . to eq ( "00:67:e3:4d:78:2f:65:94:87:bf:54:5a:1e:92:af:67:0b:8d:b5:2c" )
91+ expect ( key . fingerprint_sha256 ) . to eq ( "EZe8ZoSwAzDOLR45H2PZ1aGGfnt59ZLrL5bwnjQwTUI=" )
92+ expect ( key . to_hash ) . to eq (
93+ {
94+ "ecdsa-sha2-nistp256" => {
95+ "fingerprints" => {
96+ "md5" => "be:04:32:74:c6:63:fa:24:c3:c6:78:c2:cd:d2:3e:f4" ,
97+ "sha1" => "00:67:e3:4d:78:2f:65:94:87:bf:54:5a:1e:92:af:67:0b:8d:b5:2c" ,
98+ "sha256" => "EZe8ZoSwAzDOLR45H2PZ1aGGfnt59ZLrL5bwnjQwTUI="
99+ } ,
100+ "length" => 520 ,
101+ "raw" => "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC4gXA5naQtjcKu90NJ7A4jQ1UgxYGdnndJyr4PSZJ59qJUzkoH3VgdTlseXbIZHwO4k2gNcFpaMq5gqVRobAwU=" ,
102+ }
103+ }
104+ )
105+ end
106+ end
107+
108+ context "when parsing an ed25519 key string" do
109+ it "should parse it and have the right values for each attribute" do
110+ key_string = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINO+ybidO9DGOb1dDwyVvGcrCD/wILFWTYtWUQZVxXwH"
111+ key = SSHScan ::Crypto ::PublicKey . new ( key_string )
112+ expect ( key ) . to be_kind_of SSHScan ::Crypto ::PublicKey
113+ expect ( key . valid? ) . to be true
114+ expect ( key . type ) . to eq ( "ed25519" )
115+ expect ( key . length ) . to be 256
116+ expect ( key . fingerprint_md5 ) . to eq ( "0f:db:50:54:15:22:b3:6f:31:7c:ee:22:23:77:bc:77" )
117+ expect ( key . fingerprint_sha1 ) . to eq ( "32:d1:e8:50:ae:1c:cb:11:c5:09:fa:02:6e:f4:e8:dc:11:11:4c:48" )
118+ expect ( key . fingerprint_sha256 ) . to eq ( "p+P78wR61KZ4UvQZpr84EqslnRkhZ7txT1bN8vA/oHU=" )
119+ expect ( key . to_hash ) . to eq (
120+ {
121+ "ed25519" => {
122+ "fingerprints" => {
123+ "md5" => "0f:db:50:54:15:22:b3:6f:31:7c:ee:22:23:77:bc:77" ,
124+ "sha1" => "32:d1:e8:50:ae:1c:cb:11:c5:09:fa:02:6e:f4:e8:dc:11:11:4c:48" ,
125+ "sha256" => "p+P78wR61KZ4UvQZpr84EqslnRkhZ7txT1bN8vA/oHU="
126+ } ,
127+ "length" => 256 ,
128+ "raw" => "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINO+ybidO9DGOb1dDwyVvGcrCD/wILFWTYtWUQZVxXwH" ,
129+ }
130+ }
131+ )
132+ end
133+ end
134+
78135end
0 commit comments