diff options
author | Stef Walter <stefw@gnome.org> | 2012-11-07 11:14:49 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2012-11-09 12:15:39 +0100 |
commit | 6f7ee2da70cf39b7e8ef2f2482a77b88fa60ed53 (patch) | |
tree | cf330b564d798e0dce9c761207a22cd01c6ebd81 /pkcs11/gkm | |
parent | 0023ffdf3fa02785ec1982b851a372f138297452 (diff) | |
download | gnome-keyring-6f7ee2da70cf39b7e8ef2f2482a77b88fa60ed53.tar.gz |
egg-asn1x: More complete coverage for ASN.1 tests
* Remove or change code that doesn't get executed in normal
operation.
* Fix a few bugs discovered during the testing.
Diffstat (limited to 'pkcs11/gkm')
-rw-r--r-- | pkcs11/gkm/gkm-data-der.c | 9 | ||||
-rw-r--r-- | pkcs11/gkm/tests/test-data-der.c | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/pkcs11/gkm/gkm-data-der.c b/pkcs11/gkm/gkm-data-der.c index 6130d098..8df1b5df 100644 --- a/pkcs11/gkm/gkm-data-der.c +++ b/pkcs11/gkm/gkm-data-der.c @@ -967,7 +967,8 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password, { GNode *asn1_params = NULL; gcry_cipher_hd_t cih; - guchar salt[8]; + guchar *salt; + gsize n_salt; gcry_error_t gcry; guchar *key, *iv; gsize n_key; @@ -986,7 +987,9 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password, /* Randomize some input for the password based secret */ iterations = g_random_int_range (1000, 4096); - gcry_create_nonce (salt, sizeof (salt)); + n_salt = 8; + salt = g_malloc (n_salt); + gcry_create_nonce (salt, n_salt); /* Allocate space for the key and iv */ n_key = gcry_cipher_get_algo_keylen (GCRY_CIPHER_3DES); @@ -1001,7 +1004,7 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password, /* Now write out the parameters */ asn1_params = egg_asn1x_create (pkix_asn1_tab, "pkcs-12-PbeParams"); g_return_val_if_fail (asn1_params, NULL); - egg_asn1x_set_string_as_raw (egg_asn1x_node (asn1_params, "salt", NULL), salt, sizeof (salt), NULL); + egg_asn1x_set_string_as_raw (egg_asn1x_node (asn1_params, "salt", NULL), salt, n_salt, g_free); egg_asn1x_set_integer_as_ulong (egg_asn1x_node (asn1_params, "iterations", NULL), iterations); egg_asn1x_set_any_from (egg_asn1x_node (asn, "encryptionAlgorithm", "parameters", NULL), asn1_params); diff --git a/pkcs11/gkm/tests/test-data-der.c b/pkcs11/gkm/tests/test-data-der.c index 03407392..61c55fc7 100644 --- a/pkcs11/gkm/tests/test-data-der.c +++ b/pkcs11/gkm/tests/test-data-der.c @@ -373,7 +373,7 @@ find_extension (GNode *asn, if (strcmp (exoid, oid) == 0) { g_free (exoid); node = egg_asn1x_node (asn, "tbsCertificate", "extensions", index, "extnValue", NULL); - value = egg_asn1x_get_any_raw (node, NULL); + value = egg_asn1x_get_string_as_bytes (node); g_assert (value); return value; } @@ -392,7 +392,7 @@ test_read_basic_constraints (Test *test, gconstpointer unused) gint path_len; GkmDataResult res; - extension = egg_asn1x_get_any_raw (egg_asn1x_node (test->certificate, "tbsCertificate", "extensions", 1, "extnValue", NULL), NULL); + extension = egg_asn1x_get_string_as_bytes (egg_asn1x_node (test->certificate, "tbsCertificate", "extensions", 1, "extnValue", NULL)); g_assert (extension != NULL); res = gkm_data_der_read_basic_constraints (extension, &is_ca, &path_len); |