diff options
author | Stef Walter <stefw@redhat.com> | 2014-11-14 06:13:10 +0100 |
---|---|---|
committer | Stef Walter <stefw@redhat.com> | 2014-11-14 06:13:10 +0100 |
commit | b65e3148a8ea2d54b17a8be617bbdcb026c49fcd (patch) | |
tree | f37da17e9ec6561672b120f37edf928aa17824ca /p11-kit | |
parent | 7c2270eaaaf0e60e204cb81dd017bc89394f4f59 (diff) | |
download | p11-kit-b65e3148a8ea2d54b17a8be617bbdcb026c49fcd.tar.gz |
uri: Accept 'type' in additon to 'object-type' in PKCS#11 URIs
This was a later change to the PKCS#11 specification drafts
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/test-uri.c | 27 | ||||
-rw-r--r-- | p11-kit/uri.c | 5 |
2 files changed, 30 insertions, 2 deletions
diff --git a/p11-kit/test-uri.c b/p11-kit/test-uri.c index 9b5b293..673ef4a 100644 --- a/p11-kit/test-uri.c +++ b/p11-kit/test-uri.c @@ -159,6 +159,32 @@ test_uri_parse_with_label_and_klass (void) } static void +test_uri_parse_with_label_and_new_klass (void) +{ + CK_ATTRIBUTE_PTR attr; + P11KitUri *uri; + int ret; + + uri = p11_kit_uri_new (); + assert_ptr_not_null (uri); + + ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label;type=cert", P11_KIT_URI_FOR_ANY, uri); + assert_num_eq (P11_KIT_URI_OK, ret); + + attr = p11_kit_uri_get_attribute (uri, CKA_LABEL); + assert_ptr_not_null (attr); + assert (attr->ulValueLen == strlen ("Test Label")); + assert (memcmp (attr->pValue, "Test Label", attr->ulValueLen) == 0); + + attr = p11_kit_uri_get_attribute (uri, CKA_CLASS); + assert_ptr_not_null (attr); + assert (attr->ulValueLen == sizeof (CK_OBJECT_CLASS)); + assert (*((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_CERTIFICATE); + + p11_kit_uri_free (uri); +} + +static void test_uri_parse_with_empty_label (void) { CK_ATTRIBUTE_PTR attr; @@ -1273,6 +1299,7 @@ main (int argc, p11_test (test_uri_parse_with_empty_label, "/uri/test_uri_parse_with_empty_label"); p11_test (test_uri_parse_with_empty_id, "/uri/test_uri_parse_with_empty_id"); p11_test (test_uri_parse_with_label_and_klass, "/uri/test_uri_parse_with_label_and_klass"); + p11_test (test_uri_parse_with_label_and_new_klass, "/uri/parse-with-label-and-new-class"); p11_test (test_uri_parse_with_id, "/uri/test_uri_parse_with_id"); p11_test (test_uri_parse_with_bad_string_encoding, "/uri/test_uri_parse_with_bad_string_encoding"); p11_test (test_uri_parse_with_bad_hex_encoding, "/uri/test_uri_parse_with_bad_hex_encoding"); diff --git a/p11-kit/uri.c b/p11-kit/uri.c index a60974c..970f125 100644 --- a/p11-kit/uri.c +++ b/p11-kit/uri.c @@ -62,7 +62,7 @@ * <code><literallayout> * pkcs11:token=The\%20Software\%20PKCS\#11\%20softtoken; * manufacturer=Snake\%20Oil,\%20Inc.;serial=;object=my-certificate; - * model=1.0;object-type=cert;id=\%69\%95\%3e\%5c\%f4\%bd\%ec\%91 + * model=1.0;type=cert;id=\%69\%95\%3e\%5c\%f4\%bd\%ec\%91 * </literallayout></code> * * You can use p11_kit_uri_parse() to parse such a URI, and p11_kit_uri_format() @@ -902,7 +902,8 @@ parse_class_attribute (const char *name, const char *start, const char *end, assert (start <= end); if (strcmp ("objecttype", name) != 0 && - strcmp ("object-type", name) != 0) + strcmp ("object-type", name) != 0 && + strcmp ("type", name) != 0) return 0; value = key_decode (start, end); |