Commit 44c42057 authored by Jakub Jelen's avatar Jakub Jelen Committed by Daiki Ueno

Extend ssh-store testsuite and add ECDSA test keys

https://bugzilla.gnome.org/show_bug.cgi?id=641082
parent 45c1250d
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDBAcQcqfgI1Oc9lkcuvD7tQUVmjI2w1E122EO7olpF560alvAk9/hhu
eTZpAgl3HRugBwYFK4EEACKhZANiAARoa4Enyu7wC6QYrwPrOkhTljfmen/pF2x7
Lf+SlCpAX5w69KAXcbNPiDncXpckecfQusf/KA9KAMFQXa/eQmXkyZOjhiWkFKTz
4TklDF2ehBhE83riZFl+JAlaQOcFka0=
-----END EC PRIVATE KEY-----
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBGhrgSfK7vALpBivA+s6SFOWN+Z6f+kXbHst/5KUKkBfnDr0oBdxs0+IOdxelyR5x9C6x/8oD0oAwVBdr95CZeTJk6OGJaQUpPPhOSUMXZ6EGETzeuJkWX4kCVpA5wWRrQ== A public key comment
-----BEGIN EC PRIVATE KEY-----
MIHcAgEBBEIBLLaP4NDe6/pO69bC8xRzKcRKZ/HFebSnl6IYerSBv1uXSuIwhK5s
6xhFUfecUCrImZYaDwFoeB8pa5D66siqWsygBwYFK4EEACOhgYkDgYYABAEuCDfR
6i7TTI99PeX85cbIhzaO3ho/s9QIdAIeut5ybrTUTgDepo3A+PxHLgAwIxMgtkB6
0HVSE+NL47ewKUWSOAAQP16XBWjpJHtTZrsy3he+aUw5728tCjI4/TPqF6ANdRw0
FjAj7Q0SQvTQl9CqBW68beETcBXK9y8YtO+pHnVmYA==
-----END EC PRIVATE KEY-----
ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAEuCDfR6i7TTI99PeX85cbIhzaO3ho/s9QIdAIeut5ybrTUTgDepo3A+PxHLgAwIxMgtkB60HVSE+NL47ewKUWSOAAQP16XBWjpJHtTZrsy3he+aUw5728tCjI4/TPqF6ANdRw0FjAj7Q0SQvTQl9CqBW68beETcBXK9y8YtO+pHnVmYA== A public key comment
-----BEGIN EC PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,739A7A7A93FC8D8932F08886D4E00A28
R993QL3hLEDT9eav5CGOEAfpp87WXwwfUQBDX6tQLT9AfKawIx9ywWEVDP858YvH
7DVftJjfMEJPTprMunH/b+lzG20C5UkXFJSV6Mjb1vfYh55tMn5BkzUswzMtHiXw
C8T+HqpuKI5jTGDbW9m5A0VvFHvWgktj6BYCprpldtI=
-----END EC PRIVATE KEY-----
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNgFMnVkKhrkaU7FhRLHKstw6YrXHZ5o0hnoKu32Zup0JCegz9GGARlSDf8shWYNi+jGHJ+cIkgvmi92x2QNiAo= A public key comment
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIMYWoyDjg5vGlG5DLo6EmnzXK4OGfnA+2GrL9p3xfvu+oAoGCCqGSM49
AwEHoUQDQgAEqOtZpbYB2DmsI3PDGXRArS3XLf4GhOQr4VxXJHIv7L8Ow2dWlc79
nR2GSnS2QsXGRVkBOAPH5ZdfvVLrI1zLnA==
-----END EC PRIVATE KEY-----
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKjrWaW2Adg5rCNzwxl0QK0t1y3+BoTkK+FcVyRyL+y/DsNnVpXO/Z0dhkp0tkLFxkVZATgDx+WXX71S6yNcy5w= A public key comment
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKjrWaW2Adg5rCNzwxl0QK0t1y3+BoTkK+FcVyRyL+y/DsNnVpXO/Z0dhkp0tkLFxkVZATgDx+WXX71S6yNcy5w= A public key comment
......@@ -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;
......@@ -95,6 +130,22 @@ test_parse_plain (Test *test, gconstpointer unused)
g_object_unref (key);
}
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)
......@@ -102,7 +153,22 @@ test_unlock (Test *test,
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);
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment