From ad9c2d54114975f098ab49383088191c2d9dfa52 Mon Sep 17 00:00:00 2001 From: Iger Date: Mon, 3 Jul 2017 22:01:39 +0300 Subject: [PATCH] - Test ECDSA fingerprints --- .../sshj/keyprovider/OpenSSHKeyFileTest.java | 22 ++++++++++++++++++- .../keytypes/test_ecdsa_nistp384.pub | 1 + .../keytypes/test_ecdsa_nistp521.pub | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/keytypes/test_ecdsa_nistp384.pub create mode 100644 src/test/resources/keytypes/test_ecdsa_nistp521.pub diff --git a/src/test/java/net/schmizz/sshj/keyprovider/OpenSSHKeyFileTest.java b/src/test/java/net/schmizz/sshj/keyprovider/OpenSSHKeyFileTest.java index 67e06411..18cb3dc6 100644 --- a/src/test/java/net/schmizz/sshj/keyprovider/OpenSSHKeyFileTest.java +++ b/src/test/java/net/schmizz/sshj/keyprovider/OpenSSHKeyFileTest.java @@ -146,7 +146,7 @@ public class OpenSSHKeyFileTest { } @Test - public void shouldHaveCorrectFingerprintForECDSA() throws IOException, GeneralSecurityException { + public void shouldHaveCorrectFingerprintForECDSA256() throws IOException, GeneralSecurityException { OpenSSHKeyFile keyFile = new OpenSSHKeyFile(); keyFile.init(new File("src/test/resources/keytypes/test_ecdsa_nistp256")); String expected = "256 MD5:53:ae:db:ed:8f:2d:02:d4:d5:6c:24:bc:a4:66:88:79 root@itgcpkerberosstack-cbgateway-0-20151117031915 (ECDSA)\n"; @@ -155,6 +155,26 @@ public class OpenSSHKeyFileTest { assertThat(expected, containsString(sshjFingerprintSshjKey)); } + @Test + public void shouldHaveCorrectFingerprintForECDSA384() throws IOException, GeneralSecurityException { + OpenSSHKeyFile keyFile = new OpenSSHKeyFile(); + keyFile.init(new File("src/test/resources/keytypes/test_ecdsa_nistp384")); + String expected = "384 MD5:ee:9b:82:d1:47:01:16:1b:27:da:f5:27:fd:b2:eb:e2"; + PublicKey aPublic = keyFile.getPublic(); + String sshjFingerprintSshjKey = net.schmizz.sshj.common.SecurityUtils.getFingerprint(aPublic); + assertThat(expected, containsString(sshjFingerprintSshjKey)); + } + + @Test + public void shouldHaveCorrectFingerprintForECDSA521() throws IOException, GeneralSecurityException { + OpenSSHKeyFile keyFile = new OpenSSHKeyFile(); + keyFile.init(new File("src/test/resources/keytypes/test_ecdsa_nistp521")); + String expected = "521 MD5:22:e2:f4:3c:61:ae:e9:85:a1:4d:d9:6c:13:aa:eb:00"; + PublicKey aPublic = keyFile.getPublic(); + String sshjFingerprintSshjKey = net.schmizz.sshj.common.SecurityUtils.getFingerprint(aPublic); + assertThat(expected, containsString(sshjFingerprintSshjKey)); + } + @Test public void shouldHaveCorrectFingerprintForED25519() throws IOException { OpenSSHKeyV1KeyFile keyFile = new OpenSSHKeyV1KeyFile(); diff --git a/src/test/resources/keytypes/test_ecdsa_nistp384.pub b/src/test/resources/keytypes/test_ecdsa_nistp384.pub new file mode 100644 index 00000000..55e81bfc --- /dev/null +++ b/src/test/resources/keytypes/test_ecdsa_nistp384.pub @@ -0,0 +1 @@ +ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBGk0vVkVNYPm6YMwd8G+HtKSFQ6g5CiUPHhuOh7IJQbv521UQ+0A4t82XocxRL4OBkzNZoU76N5PzUDQ0xXWoIXl6w84oPRJ9nHs6iZkJquPLiQR4lkoEGh7Mgh6MdefXw== diff --git a/src/test/resources/keytypes/test_ecdsa_nistp521.pub b/src/test/resources/keytypes/test_ecdsa_nistp521.pub new file mode 100644 index 00000000..3a4a628c --- /dev/null +++ b/src/test/resources/keytypes/test_ecdsa_nistp521.pub @@ -0,0 +1 @@ +ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAHIN0C3k19elYzS8He+vCmZvmaFuzv4akhLBzixbahNDJ+T4MRAtdAyzbyvS275seDct/m/6Ci2Oivm+8l94KfKkQBRJbc8RWuUczzDFgaAu+R65tuLeZaCF6Z/ScaPw2lEdFWN0Vp6bet/J7XGk0muhvXUqVWc/IXhfqJ/YAniRo/WHA==