[gnome-keyring/wip/dueno/ecdsa-support: 5/10] Extend ssh-store testsuite and add ECDSA test keys
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring/wip/dueno/ecdsa-support: 5/10] Extend ssh-store testsuite and add ECDSA test keys
- Date: Fri, 13 Oct 2017 07:23:04 +0000 (UTC)
commit 44c4205701dda8c24f9ab78a3b8f09ab600d1a11
Author: Jakub Jelen <jjelen redhat com>
Date: Tue Aug 8 18:51:23 2017 +0200
Extend ssh-store testsuite and add ECDSA test keys
https://bugzilla.gnome.org/show_bug.cgi?id=641082
pkcs11/ssh-store/fixtures/id_ecdsa_384 | 6 ++
pkcs11/ssh-store/fixtures/id_ecdsa_384.pub | 1 +
pkcs11/ssh-store/fixtures/id_ecdsa_521 | 7 ++
pkcs11/ssh-store/fixtures/id_ecdsa_521.pub | 1 +
pkcs11/ssh-store/fixtures/id_ecdsa_encrypted | 8 ++
pkcs11/ssh-store/fixtures/id_ecdsa_encrypted.pub | 1 +
pkcs11/ssh-store/fixtures/id_ecdsa_plain | 5 +
pkcs11/ssh-store/fixtures/id_ecdsa_plain.pub | 1 +
pkcs11/ssh-store/fixtures/id_ecdsa_test.pub | 1 +
pkcs11/ssh-store/test-private-key.c | 88 +++++++++++++++++++---
pkcs11/ssh-store/test-ssh-openssh.c | 11 ++-
11 files changed, 118 insertions(+), 12 deletions(-)
---
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_384 b/pkcs11/ssh-store/fixtures/id_ecdsa_384
new file mode 100644
index 0000000..7d12859
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_384
@@ -0,0 +1,6 @@
+-----BEGIN EC PRIVATE KEY-----
+MIGkAgEBBDBAcQcqfgI1Oc9lkcuvD7tQUVmjI2w1E122EO7olpF560alvAk9/hhu
+eTZpAgl3HRugBwYFK4EEACKhZANiAARoa4Enyu7wC6QYrwPrOkhTljfmen/pF2x7
+Lf+SlCpAX5w69KAXcbNPiDncXpckecfQusf/KA9KAMFQXa/eQmXkyZOjhiWkFKTz
+4TklDF2ehBhE83riZFl+JAlaQOcFka0=
+-----END EC PRIVATE KEY-----
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_384.pub b/pkcs11/ssh-store/fixtures/id_ecdsa_384.pub
new file mode 100644
index 0000000..0ca36a4
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_384.pub
@@ -0,0 +1 @@
+ecdsa-sha2-nistp384
AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBGhrgSfK7vALpBivA+s6SFOWN+Z6f+kXbHst/5KUKkBfnDr0oBdxs0+IOdxelyR5x9C6x/8oD0oAwVBdr95CZeTJk6OGJaQUpPPhOSUMXZ6EGETzeuJkWX4kCVpA5wWRrQ==
A public key comment
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_521 b/pkcs11/ssh-store/fixtures/id_ecdsa_521
new file mode 100644
index 0000000..32f2251
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_521
@@ -0,0 +1,7 @@
+-----BEGIN EC PRIVATE KEY-----
+MIHcAgEBBEIBLLaP4NDe6/pO69bC8xRzKcRKZ/HFebSnl6IYerSBv1uXSuIwhK5s
+6xhFUfecUCrImZYaDwFoeB8pa5D66siqWsygBwYFK4EEACOhgYkDgYYABAEuCDfR
+6i7TTI99PeX85cbIhzaO3ho/s9QIdAIeut5ybrTUTgDepo3A+PxHLgAwIxMgtkB6
+0HVSE+NL47ewKUWSOAAQP16XBWjpJHtTZrsy3he+aUw5728tCjI4/TPqF6ANdRw0
+FjAj7Q0SQvTQl9CqBW68beETcBXK9y8YtO+pHnVmYA==
+-----END EC PRIVATE KEY-----
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_521.pub b/pkcs11/ssh-store/fixtures/id_ecdsa_521.pub
new file mode 100644
index 0000000..e57832d
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_521.pub
@@ -0,0 +1 @@
+ecdsa-sha2-nistp521
AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAEuCDfR6i7TTI99PeX85cbIhzaO3ho/s9QIdAIeut5ybrTUTgDepo3A+PxHLgAwIxMgtkB60HVSE+NL47ewKUWSOAAQP16XBWjpJHtTZrsy3he+aUw5728tCjI4/TPqF6ANdRw0FjAj7Q0SQvTQl9CqBW68beETcBXK9y8YtO+pHnVmYA==
A public key comment
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted b/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted
new file mode 100644
index 0000000..3955d0f
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted
@@ -0,0 +1,8 @@
+-----BEGIN EC PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: AES-128-CBC,739A7A7A93FC8D8932F08886D4E00A28
+
+R993QL3hLEDT9eav5CGOEAfpp87WXwwfUQBDX6tQLT9AfKawIx9ywWEVDP858YvH
+7DVftJjfMEJPTprMunH/b+lzG20C5UkXFJSV6Mjb1vfYh55tMn5BkzUswzMtHiXw
+C8T+HqpuKI5jTGDbW9m5A0VvFHvWgktj6BYCprpldtI=
+-----END EC PRIVATE KEY-----
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted.pub
b/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted.pub
new file mode 100644
index 0000000..d589462
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted.pub
@@ -0,0 +1 @@
+ecdsa-sha2-nistp256
AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNgFMnVkKhrkaU7FhRLHKstw6YrXHZ5o0hnoKu32Zup0JCegz9GGARlSDf8shWYNi+jGHJ+cIkgvmi92x2QNiAo=
A public key comment
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_plain b/pkcs11/ssh-store/fixtures/id_ecdsa_plain
new file mode 100644
index 0000000..6423c0d
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_plain
@@ -0,0 +1,5 @@
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIMYWoyDjg5vGlG5DLo6EmnzXK4OGfnA+2GrL9p3xfvu+oAoGCCqGSM49
+AwEHoUQDQgAEqOtZpbYB2DmsI3PDGXRArS3XLf4GhOQr4VxXJHIv7L8Ow2dWlc79
+nR2GSnS2QsXGRVkBOAPH5ZdfvVLrI1zLnA==
+-----END EC PRIVATE KEY-----
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_plain.pub b/pkcs11/ssh-store/fixtures/id_ecdsa_plain.pub
new file mode 100644
index 0000000..7d4b2d4
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_plain.pub
@@ -0,0 +1 @@
+ecdsa-sha2-nistp256
AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKjrWaW2Adg5rCNzwxl0QK0t1y3+BoTkK+FcVyRyL+y/DsNnVpXO/Z0dhkp0tkLFxkVZATgDx+WXX71S6yNcy5w=
A public key comment
diff --git a/pkcs11/ssh-store/fixtures/id_ecdsa_test.pub b/pkcs11/ssh-store/fixtures/id_ecdsa_test.pub
new file mode 100644
index 0000000..7d4b2d4
--- /dev/null
+++ b/pkcs11/ssh-store/fixtures/id_ecdsa_test.pub
@@ -0,0 +1 @@
+ecdsa-sha2-nistp256
AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKjrWaW2Adg5rCNzwxl0QK0t1y3+BoTkK+FcVyRyL+y/DsNnVpXO/Z0dhkp0tkLFxkVZATgDx+WXX71S6yNcy5w=
A public key comment
diff --git a/pkcs11/ssh-store/test-private-key.c b/pkcs11/ssh-store/test-private-key.c
index ba9ebd6..f580c5e 100644
--- a/pkcs11/ssh-store/test-private-key.c
+++ b/pkcs11/ssh-store/test-private-key.c
@@ -37,7 +37,9 @@
typedef struct {
GkmModule *module;
GkmSession *session;
- GkmSshPrivateKey *key;
+ GkmSshPrivateKey *rsakey;
+ GkmSshPrivateKey *dsakey;
+ GkmSshPrivateKey *ecdsakey;
} Test;
static void
@@ -63,24 +65,57 @@ setup (Test *test,
setup_basic (test, unused);
- test->key = gkm_ssh_private_key_new (test->module, "my-unique");
- g_assert (GKM_IS_SSH_PRIVATE_KEY (test->key));
+ /* RSA */
+ test->rsakey = gkm_ssh_private_key_new (test->module, "my-unique");
+ g_assert (GKM_IS_SSH_PRIVATE_KEY (test->rsakey));
- ret = gkm_ssh_private_key_parse (test->key, SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_encrypted.pub",
- SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_encrypted", NULL);
+ ret = gkm_ssh_private_key_parse (test->rsakey, SRCDIR
"/pkcs11/ssh-store/fixtures/id_rsa_encrypted.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_rsa_encrypted", NULL);
g_assert (ret == TRUE);
+
+ /* DSA */
+ test->dsakey = gkm_ssh_private_key_new (test->module, "my-unique");
+ g_assert (GKM_IS_SSH_PRIVATE_KEY (test->dsakey));
+
+ ret = gkm_ssh_private_key_parse (test->dsakey, SRCDIR
"/pkcs11/ssh-store/fixtures/id_dsa_encrypted.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_encrypted", NULL);
+
+ /* ECDSA */
+ test->ecdsakey = gkm_ssh_private_key_new (test->module, "my-unique");
+ g_assert (GKM_IS_SSH_PRIVATE_KEY (test->ecdsakey));
+
+ ret = gkm_ssh_private_key_parse (test->ecdsakey, SRCDIR
"/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted", NULL);
}
static void
teardown (Test *test,
gconstpointer unused)
{
- g_object_unref (test->key);
+ g_object_unref (test->rsakey);
+ g_object_unref (test->dsakey);
+ g_object_unref (test->ecdsakey);
teardown_basic (test, unused);
}
static void
-test_parse_plain (Test *test, gconstpointer unused)
+test_parse_plain_rsa (Test *test, gconstpointer unused)
+{
+ GkmSshPrivateKey *key;
+ gboolean ret;
+
+ key = gkm_ssh_private_key_new (test->module, "my-unique");
+ g_assert (GKM_IS_SSH_PRIVATE_KEY (key));
+
+ ret = gkm_ssh_private_key_parse (key, SRCDIR "/pkcs11/ssh-store/fixtures/id_rsa_plain.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_rsa_plain", NULL);
+ g_assert (ret == TRUE);
+
+ g_object_unref (key);
+}
+
+static void
+test_parse_plain_dsa (Test *test, gconstpointer unused)
{
GkmSshPrivateKey *key;
gboolean ret;
@@ -96,13 +131,44 @@ test_parse_plain (Test *test, gconstpointer unused)
}
static void
+test_parse_plain_ecdsa (Test *test, gconstpointer unused)
+{
+ GkmSshPrivateKey *key;
+ gboolean ret;
+
+ key = gkm_ssh_private_key_new (test->module, "my-unique");
+ g_assert (GKM_IS_SSH_PRIVATE_KEY (key));
+
+ ret = gkm_ssh_private_key_parse (key, SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_plain.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_plain", NULL);
+ g_assert (ret == TRUE);
+
+ g_object_unref (key);
+}
+
+static void
test_unlock (Test *test,
gconstpointer unused)
{
GkmCredential *cred;
CK_RV rv;
- rv = gkm_credential_create (test->module, NULL, GKM_OBJECT (test->key),
+ /* RSA */
+ rv = gkm_credential_create (test->module, NULL, GKM_OBJECT (test->rsakey),
+ (guchar*)"password", 8, &cred);
+ g_assert (rv == CKR_OK);
+
+ g_object_unref (cred);
+
+ /* DSA */
+ rv = gkm_credential_create (test->module, NULL, GKM_OBJECT (test->dsakey),
+ (guchar*)"password", 8, &cred);
+ g_assert (rv == CKR_OK);
+
+ g_object_unref (cred);
+
+ /* ECDSA */
+ rv = gkm_credential_create (test->module, NULL, GKM_OBJECT (test->ecdsakey),
(guchar*)"password", 8, &cred);
g_assert (rv == CKR_OK);
@@ -116,7 +182,7 @@ test_internal_sha1_compat (Test *test,
gpointer data;
gsize n_data;
- data = gkm_object_get_attribute_data (GKM_OBJECT (test->key), test->session,
+ data = gkm_object_get_attribute_data (GKM_OBJECT (test->dsakey), test->session,
CKA_GNOME_INTERNAL_SHA1, &n_data);
egg_assert_cmpmem (data, n_data, ==,
"\x33\x37\x31\x31\x64\x33\x33\x65\x61\x34\x31\x31\x33\x61\x35\x64\x32\x35\x38\x37\x63\x36\x66\x32\x35\x66\x39\x35\x35\x36\x39\x66\x65\x65\x38\x31\x38\x35\x39\x34",
40);
@@ -131,7 +197,9 @@ main (int argc, char **argv)
#endif
g_test_init (&argc, &argv, NULL);
- g_test_add ("/ssh-store/private-key/parse_plain", Test, NULL, setup_basic, test_parse_plain,
teardown_basic);
+ g_test_add ("/ssh-store/private-key/parse_plain_rsa", Test, NULL, setup_basic, test_parse_plain_rsa,
teardown_basic);
+ g_test_add ("/ssh-store/private-key/parse_plain_dsa", Test, NULL, setup_basic, test_parse_plain_dsa,
teardown_basic);
+ g_test_add ("/ssh-store/private-key/parse_plain_ecdsa", Test, NULL, setup_basic,
test_parse_plain_ecdsa, teardown_basic);
g_test_add ("/ssh-store/private-key/unlock", Test, NULL, setup, test_unlock, teardown);
g_test_add ("/ssh-store/private-key/internal-sha1-compat", Test, NULL, setup,
test_internal_sha1_compat, teardown);
diff --git a/pkcs11/ssh-store/test-ssh-openssh.c b/pkcs11/ssh-store/test-ssh-openssh.c
index e1c4fb7..31ed74f 100644
--- a/pkcs11/ssh-store/test-ssh-openssh.c
+++ b/pkcs11/ssh-store/test-ssh-openssh.c
@@ -39,12 +39,19 @@ static const gchar *PRIVATE_FILES[] = {
SRCDIR "/pkcs11/ssh-store/fixtures/id_rsa_encrypted",
SRCDIR "/pkcs11/ssh-store/fixtures/id_rsa_plain",
SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_encrypted",
- SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_plain"
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_plain",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_encrypted",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_plain",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_384",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_521"
};
static const gchar *PUBLIC_FILES[] = {
SRCDIR "/pkcs11/ssh-store/fixtures/id_rsa_test.pub",
- SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_test.pub"
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_dsa_test.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_test.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_384.pub",
+ SRCDIR "/pkcs11/ssh-store/fixtures/id_ecdsa_521.pub"
};
#define COMMENT "A public key comment"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]