idnits 2.17.1 draft-pechanec-pkcs11uri-19.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 1 instance of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (January 15, 2015) is 3360 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'RFCXXXX' is mentioned on line 775, but not defined -- Obsolete informational reference (is this intentional?): RFC 4395 (Obsoleted by RFC 7595) Summary: 0 errors (**), 0 flaws (~~), 3 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group J. Pechanec 3 Internet-Draft D. Moffat 4 Intended status: Standards Track Oracle Corporation 5 Expires: July 19, 2015 January 15, 2015 7 The PKCS#11 URI Scheme 8 draft-pechanec-pkcs11uri-19 10 Abstract 12 This memo specifies a PKCS#11 Uniform Resource Identifier (URI) 13 Scheme for identifying PKCS#11 objects stored in PKCS#11 tokens, and 14 also for identifying PKCS#11 tokens, slots or libraries. The URI is 15 based on how PKCS#11 objects, tokens, slots, and libraries are 16 identified in the PKCS#11 Cryptographic Token Interface Standard. 18 Status of This Memo 20 This Internet-Draft is submitted in full conformance with the 21 provisions of BCP 78 and BCP 79. 23 Internet-Drafts are working documents of the Internet Engineering 24 Task Force (IETF). Note that other groups may also distribute 25 working documents as Internet-Drafts. The list of current Internet- 26 Drafts is at http://datatracker.ietf.org/drafts/current/. 28 Internet-Drafts are draft documents valid for a maximum of six months 29 and may be updated, replaced, or obsoleted by other documents at any 30 time. It is inappropriate to use Internet-Drafts as reference 31 material or to cite them other than as "work in progress." 33 This Internet-Draft will expire on July 19, 2015. 35 Copyright Notice 37 Copyright (c) 2015 IETF Trust and the persons identified as the 38 document authors. All rights reserved. 40 This document is subject to BCP 78 and the IETF Trust's Legal 41 Provisions Relating to IETF Documents 42 (http://trustee.ietf.org/license-info) in effect on the date of 43 publication of this document. Please review these documents 44 carefully, as they describe your rights and restrictions with respect 45 to this document. Code Components extracted from this document must 46 include Simplified BSD License text as described in Section 4.e of 47 the Trust Legal Provisions and are provided without warranty as 48 described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 53 2. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 3 54 3. PKCS#11 URI Scheme Definition . . . . . . . . . . . . . . . . 4 55 3.1. PKCS#11 URI Scheme Name . . . . . . . . . . . . . . . . . 4 56 3.2. PKCS#11 URI Scheme Status . . . . . . . . . . . . . . . . 4 57 3.3. PKCS#11 URI Scheme Syntax . . . . . . . . . . . . . . . . 4 58 3.4. PKCS#11 URI Scheme Query Attribute Semantics . . . . . . 9 59 3.5. PKCS#11 URI Matching Guidelines . . . . . . . . . . . . . 10 60 3.6. PKCS#11 URI Comparison . . . . . . . . . . . . . . . . . 12 61 3.7. Generating PKCS#11 URIs . . . . . . . . . . . . . . . . . 13 62 4. Examples of PKCS#11 URIs . . . . . . . . . . . . . . . . . . 13 63 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 64 5.1. URI Scheme Registration . . . . . . . . . . . . . . . . . 16 65 6. Internationalization Considerations . . . . . . . . . . . . . 17 66 7. Security Considerations . . . . . . . . . . . . . . . . . . . 17 67 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 68 8.1. Normative References . . . . . . . . . . . . . . . . . . 18 69 8.2. Informative References . . . . . . . . . . . . . . . . . 18 70 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 19 72 1. Introduction 74 The PKCS #11: Cryptographic Token Interface Standard [PKCS11] 75 specifies an API, called Cryptoki, for devices which hold 76 cryptographic information and perform cryptographic functions. 77 Cryptoki, pronounced crypto-key and short for cryptographic token 78 interface, follows a simple object-based approach, addressing the 79 goals of technology independence (any kind of device may be used) and 80 resource sharing (multiple applications may access multiple devices), 81 presenting applications with a common, logical view of the device - a 82 cryptographic token. 84 It is desirable for applications or libraries that work with PKCS#11 85 tokens to accept a common identifier that consumers could use to 86 identify an existing PKCS#11 storage object in a PKCS#11 token, an 87 existing token itself, a slot, or an existing Cryptoki library (also 88 called a producer, module, or provider). The set of storage object 89 types that can be stored in a PKCS#11 token includes a certificate, a 90 public, private or secret key, and a data object. These objects can 91 be uniquely identifiable via the PKCS#11 URI scheme defined in this 92 document. The set of attributes describing a storage object can 93 contain an object label, its type, and its ID. The set of attributes 94 that identifies a PKCS#11 token can contain a token label, 95 manufacturer name, serial number, and token model. Attributes that 96 can identify a slot are a slot ID, description, and manufacturer. 97 Attributes that can identify a Cryptoki library are a library 98 manufacturer, description, and version. Library attributes may be 99 necessary to use if more than one Cryptoki library provides a token 100 and/or PKCS#11 objects of the same name. A set of query attributes 101 is provided as well. 103 The PKCS#11 URI cannot identify other objects defined in the 104 specification [PKCS11] aside from storage objects. For example, 105 objects not identifiable by a PKCS#11 URI include a hardware feature 106 and mechanism. Note that a Cryptoki library does not have to provide 107 for storage objects at all. The URI can still be used to identify a 108 specific PKCS#11 token, slot or an API producer in such a case. 110 A subset of existing PKCS#11 structure members and object attributes 111 was chosen to uniquely identify a PKCS#11 storage object, token, 112 slot, or library in a configuration file, on a command line, or in a 113 configuration property of something else. Should there be a need for 114 a more complex information exchange on PKCS#11 entities a different 115 means of data marshalling should be chosen accordingly. 117 A PKCS#11 URI is not intended to be used to create new PKCS#11 118 objects in tokens, or to create PKCS#11 tokens. It is solely to be 119 used to identify and work with existing storage objects, tokens, and 120 slots through the PKCS#11 API, or identify Cryptoki libraries 121 themselves. 123 The URI scheme defined in this document is designed specifically with 124 a mapping to the PKCS#11 API in mind. The URI uses the scheme, path 125 and query components defined in the Uniform Resource Identifier 126 (URI): Generic Syntax [RFC3986] document. The URI does not use the 127 hierarchical element for a naming authority in the path since the 128 authority part could not be mapped to PKCS#11 API elements. The URI 129 does not use the fragment component. 131 If an application has no access to a producer or producers of the 132 PKCS#11 API the query component module attributes can be used. 133 However, the PKCS#11 URI consumer can always decide to provide its 134 own adequate user interface to locate and load PKCS#11 API producers. 136 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 137 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 138 document are to be interpreted as described in [RFC2119]. 140 2. Contributors 142 Stef Walter, Nikos Mavrogiannopoulos, Nico Williams, Dan Winship, and 143 Jaroslav Imrich contributed to the development of this document. 145 3. PKCS#11 URI Scheme Definition 147 In accordance with [RFC4395], this section provides the information 148 required to register the PKCS#11 URI scheme. 150 3.1. PKCS#11 URI Scheme Name 152 pkcs11 154 3.2. PKCS#11 URI Scheme Status 156 Permanent. 158 3.3. PKCS#11 URI Scheme Syntax 160 The PKCS#11 URI is a sequence of attribute value pairs separated by a 161 semicolon that form a one level path component, optionally followed 162 by a query. In accordance with Section 2.5 of [RFC3986], the data 163 SHOULD first be encoded as octets according to the UTF-8 character 164 encoding [RFC3629]; then only those octets that do not correspond to 165 characters in the unreserved set or to permitted characters from the 166 reserved set should be percent-encoded. This specification suggests 167 one allowable exception to that rule for the "id" attribute, as 168 stated later in this section. Note that if a URI does carry 169 characters outside of the US-ASCII character set a conversion to an 170 Internationalized Resource Identifier (IRI) defined in [RFC3987] may 171 be considered. When working with UTF-8 strings with characters 172 outside the US-ASCII character sets, see important caveats in 173 Section 3.5 and Section 6. 175 Grammar rules "unreserved" and "pct-encoded" in the PKCS#11 URI 176 specification below are imported from [RFC3986]. As a special case, 177 note that according to Appendix A of [RFC3986], a space must be 178 percent-encoded. 180 The PKCS#11 specification imposes various limitations on the value of 181 attributes, be it a more restrictive character set for the "serial" 182 attribute or fixed sized buffers for almost all the others, including 183 "token", "manufacturer", and "model" attributes. However, the 184 PKCS#11 URI notation does not impose such limitations aside from 185 removing generic and PKCS#11 URI delimiters from a permitted 186 character set. We believe that being too restrictive on the 187 attribute values could limit the PKCS#11 URI usefulness. What is 188 more, possible future changes to the PKCS#11 specification should not 189 affect existing attributes. 191 A PKCS#11 URI takes the form (for explanation of Augmented BNF, see 192 [RFC5234]): 194 pk11-URI = "pkcs11:" pk11-path [ "?" pk11-query ] 195 ; Path component and its attributes. Path may be empty. 196 pk11-path = [ pk11-pattr *(";" pk11-pattr) ] 197 pk11-pattr = pk11-token / pk11-manuf / pk11-serial / 198 pk11-model / pk11-lib-manuf / 199 pk11-lib-ver / pk11-lib-desc / 200 pk11-object / pk11-type / pk11-id / 201 pk11-slot-desc / pk11-slot-manuf / 202 pk11-slot-id / pk11-v-pattr 203 ; Query component and its attributes. Query may be empty. 204 pk11-qattr = pk11-pin-source / pk11-pin-value / 205 pk11-module-name / pk11-module-path / 206 pk11-v-qattr 207 pk11-query = [ pk11-qattr *("&" pk11-qattr) ] 208 ; RFC 3986 section 2.2 mandates all potentially reserved characters 209 ; that do not conflict with actual delimiters of the URI do not have 210 ; to be percent-encoded. 211 pk11-res-avail = ":" / "[" / "]" / "@" / "!" / "$" / 212 "'" / "(" / ")" / "*" / "+" / "," / "=" 213 pk11-path-res-avail = pk11-res-avail / "&" 214 ; "/" and "?" in the query component MAY be unencoded but "&" MUST 215 ; be encoded since it functions as a delimiter within the component. 216 pk11-query-res-avail = pk11-res-avail / "/" / "?" / "|" 217 pk11-pchar = unreserved / pk11-path-res-avail / pct-encoded 218 pk11-qchar = unreserved / pk11-query-res-avail / pct-encoded 219 pk11-token = "token" "=" *pk11-pchar 220 pk11-manuf = "manufacturer" "=" *pk11-pchar 221 pk11-serial = "serial" "=" *pk11-pchar 222 pk11-model = "model" "=" *pk11-pchar 223 pk11-lib-manuf = "library-manufacturer" "=" *pk11-pchar 224 pk11-lib-desc = "library-description" "=" *pk11-pchar 225 pk11-lib-ver = "library-version" "=" 1*DIGIT [ "." 1*DIGIT ] 226 pk11-object = "object" "=" *pk11-pchar 227 pk11-type = "type" "=" ( "public" / "private" / "cert" / 228 "secret-key" / "data" ) 229 pk11-id = "id" "=" *pk11-pchar 230 pk11-slot-manuf = "slot-manufacturer" "=" *pk11-pchar 231 pk11-slot-desc = "slot-description" "=" *pk11-pchar 232 pk11-slot-id = "slot-id" "=" 1*DIGIT 233 pk11-pin-source = "pin-source" "=" *pk11-qchar 234 pk11-pin-value = "pin-value" "=" *pk11-qchar 235 pk11-module-name = "module-name" "=" *pk11-qchar 236 pk11-module-path = "module-path" "=" *pk11-qchar 237 pk11-v-attr-nm-char = ALPHA / DIGIT / "-" / "_" 238 ; Permitted value of a vendor specific attribute is based on 239 ; whether the attribute is used in the path or in the query. 240 pk11-v-pattr = 1*pk11-v-attr-nm-char "=" *pk11-pchar 241 pk11-v-qattr = 1*pk11-v-attr-nm-char "=" *pk11-qchar 242 The URI path component contains attributes that identify a resource 243 in a one level hierarchy provided by Cryptoki producers. The query 244 component can contain a few attributes that may be needed to retrieve 245 the resource identified by the URI path. Attributes in the path 246 component are delimited by ';' character, attributes in the query 247 component use '&' as a delimiter. 249 Both path and query components may contain vendor specific 250 attributes. Such attribute names MUST NOT clash with existing 251 attribute names. Note that in accordance with [BCP178], previously 252 used convention of starting vendor attributes with an "x-" prefix is 253 now depricated. 255 The general '/' delimiter MUST be percent-encoded in the path 256 component so that generic URI parsers never split the path component 257 into multiple segments. It MAY be unencoded in the query component. 258 Delimiter '?' MUST be percent-encoded in the path component since 259 the PKCS#11 URI uses a query component. Delimiter '#' MUST be always 260 percent-encoded so that generic URI parsers do not treat a hash as a 261 beginning of a fragment identifier component. All other generic 262 delimiters MAY be used unencoded (':', '[', ']', and '@') in the 263 PKCS#11 URI. 265 The following table presents mapping between the PKCS#11 URI path 266 component attributes and the PKCS#11 API structure members and object 267 attributes. Given that PKCS#11 URI users may be quite ignorant about 268 the PKCS#11 specification the mapping is a product of a necessary 269 compromise between how precisely are the URI attribute names mapped 270 to the names in the specification and the ease of use and 271 understanding of the URI scheme. 273 +----------------------+---------------------+----------------------+ 274 | URI component path | Attribute | Attribute | 275 | attribute name | represents | corresponds in the | 276 | | | PKCS#11 | 277 | | | specification to | 278 +----------------------+---------------------+----------------------+ 279 | | | | 280 +----------------------+---------------------+----------------------+ 281 | id | key identifier for | "CKA_ID" object | 282 | | object | attribute | 283 +----------------------+---------------------+----------------------+ 284 | library-description | character-string | "libraryDescription" | 285 | | description of the | member of CK_INFO | 286 | | library | structure. It is an | 287 | | | UTF-8 string. | 288 +----------------------+---------------------+----------------------+ 289 | library-manufacturer | ID of the Cryptoki | "manufacturerID" | 290 | | library | member of the | 291 | | manufacturer | CK_INFO structure. | 292 | | | It is an UTF-8 | 293 | | | string. | 294 +----------------------+---------------------+----------------------+ 295 | library-version | Cryptoki library | "libraryVersion" | 296 | | version number | member of CK_INFO | 297 | | | structure | 298 +----------------------+---------------------+----------------------+ 299 | manufacturer | ID of the token | "manufacturerID" | 300 | | manufacturer | member of | 301 | | | CK_TOKEN_INFO | 302 | | | structure. It is an | 303 | | | UTF-8 string. | 304 +----------------------+---------------------+----------------------+ 305 | model | token model | "model" member of | 306 | | | CK_TOKEN_INFO | 307 | | | structure. It is an | 308 | | | UTF-8 string. | 309 +----------------------+---------------------+----------------------+ 310 | object | description (name) | "CKA_LABEL" object | 311 | | of the object | attribute. It is an | 312 | | | UTF-8 string. | 313 +----------------------+---------------------+----------------------+ 314 | serial | character-string | "serialNumber" | 315 | | serial number of | member of | 316 | | the token | CK_TOKEN_INFO | 317 | | | structure | 318 +----------------------+---------------------+----------------------+ 319 | slot-description | slot description | "slotDescription" | 320 | | | member of | 321 | | | CK_SLOT_INFO | 322 | | | structure. It is an | 323 | | | UTF-8 string. | 324 +----------------------+---------------------+----------------------+ 325 | slot-id | Cryptoki-assigned | decimal number of | 326 | | value that | "CK_SLOT_ID" type | 327 | | identifies a slot | | 328 +----------------------+---------------------+----------------------+ 329 | slot-manufacturer | ID of the slot | "manufacturerID" | 330 | | manufacturer | member of | 331 | | | CK_SLOT_INFO | 332 | | | structure. It is an | 333 | | | UTF-8 string. | 334 +----------------------+---------------------+----------------------+ 335 | token | application-defined | "label" member of | 336 | | label, assigned | the CK_TOKEN_INFO | 337 | | during token | structure. It is an | 338 | | initialization | UTF-8 string. | 339 +----------------------+---------------------+----------------------+ 340 | type | object class (type) | "CKA_CLASS" object | 341 | | | attribute | 342 +----------------------+---------------------+----------------------+ 344 Table 1: Mapping between URI path component attributes and PKCS#11 345 specification names 347 The query component attribute "pin-source" specifies where the 348 application or library should find the normal user's token PIN, the 349 "pin-value" attribute provides the normal user's PIN value directly, 350 if needed, and the "module-name" and "module-path" attributes modify 351 default settings for accessing PKCS#11 providers. For the definition 352 of a "normal user", see [PKCS11]. 354 The ABNF rules above is a best effort definition and this paragraph 355 specifies additional constraints. The PKCS#11 URI MUST NOT contain 356 duplicate attributes of the same name in the URI path component. It 357 means that each attribute may be present at most once in the PKCS#11 358 URI path. Aside from the query attributes defined in this document, 359 duplicate (vendor) attributes MAY be present in the URI query 360 component and it is up to the URI consumer to decide on how to deal 361 with such duplicates. 363 The whole value of the "id" attribute SHOULD be percent-encoded since 364 it is supposed to be handled as arbitrary binary data. 366 The "library-version" attribute represents the major and minor 367 version number of the library and its format is "M.N". Both numbers 368 are one byte in size, see the "libraryVersion" member of the CK_INFO 369 structure in [PKCS11] for more information. Value "M" for the 370 attribute MUST be interpreted as "M" for the major and "0" for the 371 minor version of the library. If the attribute is present the major 372 version number is REQUIRED. Both "M" and "N" MUST be decimal 373 numbers. 375 Slot ID is a Cryptoki-assigned number that is not guaranteed stable 376 across PKCS#11 module initializations. However, there are certain 377 libraries and modules which provide stable slot identifiers. For 378 these cases, when the slot description and manufacturer ID is not 379 sufficient to uniquely identify a specific reader, the slot ID MAY be 380 used to increase the precision of the token identification. In other 381 scenarios, using the slot IDs is likely to cause usability issues. 383 An empty PKCS#11 URI path attribute that does allow for an empty 384 value matches a corresponding structure member or an object attribute 385 with an empty value. Note that according to the PKCS#11 386 specification [PKCS11], empty character values in a PKCS#11 API 387 producer must be padded with spaces and should not be NULL 388 terminated. 390 3.4. PKCS#11 URI Scheme Query Attribute Semantics 392 An application MAY always ask for a PIN by any means it decides to. 393 What is more, in order not to limit PKCS#11 URI portability the "pin- 394 source" attribute value format and interpretation is left to be 395 implementation specific. However, the following rules SHOULD be 396 followed in descending order for the value of the "pin-source" 397 attribute: 399 o if the value represents a local absolute path the implementation 400 SHOULD use it as a PIN file containing the PIN value 402 o if the value contains "|" the 403 implementation SHOULD read the PIN from the output of an 404 application specified with absolute path "". Note that character "|" representing a pipe does not have 406 to be percent encoded in the query component of the PKCS#11 URI. 408 o if the value represents a URI it SHOULD be treated as an object 409 containing the PIN. Such a URI may be "file:", "https:", another 410 PKCS#11 URI, or something else. 412 o interpret the value as needed in an implementation dependent way 414 If a URI contains both "pin-source" and "pin-value" query attributes 415 the URI SHOULD be refused as invalid. 417 Use of the "pin-value" attribute may have security related 418 consequences. Section 7 should be consulted before this attribute is 419 ever used. Standard percent encoding rules SHOULD be followed for 420 the attribute value. 422 A consumer of PKCS#11 URIs MAY modify default settings for accessing 423 a PKCS#11 provider or providers by accepting query component 424 attributes "module-name" and "module-path"." 426 Processing the URI query module attributes SHOULD follow these rules: 428 o attribute "module-name" SHOULD contain a case-insensitive PKCS#11 429 module name (not path nor filename) without system specific 430 affixes. Such affix could be an ".so" or ".DLL" suffix, or a 431 "lib" prefix, for example. Not using system specific affixes is 432 expected to increase portability of PKCS#11 URIs among different 433 systems. A URI consumer searching for PKCS#11 modules SHOULD use 434 a system or application specific locations to find modules based 435 on the name provided in the attribute. 437 o attribute "module-path" SHOULD contain a system specific absolute 438 path to the PKCS#11 module, or a system specific absolute path to 439 the directory of where PKCS#11 modules are located. For security 440 reasons, a URI with a relative path in this attribute SHOULD be 441 rejected. 443 o the URI consumer MAY refuse to accept either of the attributes, or 444 both. If use of an attribute present in the URI string is not 445 accepted a warning message SHOULD be presented to the provider of 446 the URI. 448 o if either of the module attributes is present, only those modules 449 found matching these query attributes SHOULD be used to search for 450 an entity represented by the URI. 452 o use of the module attributes does not suppress matching of any 453 other URI path component attributes present in a URI. 455 o semantics of using both attributes in the same URI string is 456 implementation specific but such use SHOULD be avoided. Attribute 457 "module-name" is preferred to "module-path" due to its system 458 independent nature but the latter may be more suitable for 459 development and debugging. 461 o a URI MUST NOT contain multiple module attributes of the same 462 name. 464 Use of the module attributes may have security related consequences. 465 Section 7 should be consulted before these attributes are ever used. 467 A word "module" was chosen over word "library" in these query 468 attribute names to avoid confusion with semantically different 469 library attributes used in the URI path component. 471 3.5. PKCS#11 URI Matching Guidelines 473 The PKCS#11 URI can identify PKCS#11 storage objects, tokens, slots, 474 or Cryptoki libraries. Note that since a URI may identify four 475 different types of entities the context within which the URI is used 476 may be needed to determine the type. For example, a URI with only 477 library attributes may either represent all objects in all tokens in 478 all Cryptoki libraries identified by the URI, all tokens in those 479 libraries, or just the libraries. 481 The following guidelines can help a PKCS#11 URI consumer (eg. an 482 application accepting PKCS#11 URIs) to match the URI with the desired 483 resource. 485 o the consumer MUST know whether the URI is to identify PKCS#11 486 storage object(s), token(s), slot(s), or Cryptoki producer(s). 488 o if the consumer is willing to accept query component module 489 attributes only those PKCS#11 providers matching these attributes 490 SHOULD be worked with. See Section 3.4 for more information. 492 o an unrecognized attribute in the URI path component, including a 493 vendor specific attribute, SHOULD result in an empty set of 494 matched resources. The consumer SHOULD consider whether an error 495 message presented to the user is appropriate in such a case. 497 o an unrecognized attribute in the URI query SHOULD be ignored. The 498 consumer SHOULD consider whether a warning message presented to 499 the user is appropriate in such a case. 501 o an attribute not present in the URI path but known to a consumer 502 matches everything. Each additional attribute present in the URI 503 path further restricts the selection. 505 o a logical extension of the above is that an empty URI path matches 506 everything. For example, if used to identify storage objects it 507 matches all accessible objects in all tokens provided by all 508 PKCS#11 API producers found in the system. 510 o note that use of PIN attributes may change the set of storage 511 objects visible to the consumer. 513 o in addition to query component attributes defined in this 514 document, vendor specific query attributes may contain further 515 information about how to perform the selection or other related 516 information. 518 As noted in Section 6, the PKCS#11 specification is not clear about 519 how to normalize UTF-8 encoded Unicode characters [RFC3629]. For 520 that reason, it is RECOMMENDED not to use characters outside the US- 521 ASCII character set for labels and names. However, those who 522 discover a need to use such characters should be cautious, 523 conservative, and expend extra effort to be sure they know what they 524 are doing and that failure to do so may create both operational and 525 security risks. It means that when matching UTF-8 string based 526 attributes (see Table 1) with characters outside the US-ASCII 527 repertoire, normalizing all UTF-8 strings before string comparison 528 may be the only safe approach. For example, for objects (keys) it 529 means that PKCS#11 attribute search template would only contain 530 attributes that are not UTF-8 strings and another pass through 531 returned objects is then needed for UTF-8 string comparison after the 532 normalization is applied. 534 3.6. PKCS#11 URI Comparison 536 Comparison of two URIs is a way of determining whether the URIs are 537 equivalent without comparing the actual resource the URIs point to. 538 The comparison of URIs aims to minimize false negatives while 539 strictly avoiding false positives. When working with UTF-8 strings 540 with characters outside the US-ASCII character sets, see important 541 caveats in Section 3.5 and Section 6. 543 Two PKCS#11 URIs are said to be equal if URIs as character strings 544 are identical as specified in Section 6.2.1 of [RFC3986], or if both 545 following rules are fulfilled: 547 o set of attributes present in the URI is equal. Note that the 548 ordering of attributes in the URI string is not significant for 549 the mechanism of comparison. 551 o values of respective attributes are equal based on rules specified 552 below 554 The rules for comparing values of respective attributes are: 556 o values of path component attributes "library-description", 557 "library-manufacturer", "manufacturer", "model", "object", 558 "serial", "slot-description", "slot-manufacturer", "token", 559 "type", and query component attribute "module-name" MUST be 560 compared using a simple string comparison as specified in 561 Section 6.2.1 of [RFC3986] after the case and the percent-encoding 562 normalization are both applied as specified in Section 6.2.2 of 563 [RFC3986]. 565 o value of attribute "id" MUST be compared using the simple string 566 comparison after all bytes are percent-encoded using uppercase 567 letters for digits A-F. 569 o value of attribute "library-version" MUST be processed as a 570 specific scheme-based normalization permitted by Section 6.2.3 of 571 [RFC3986]. The value MUST be split into a major and minor version 572 with character '.' (dot) serving as a delimiter. Library version 573 "M" MUST be treated as "M" for the major version and "0" for the 574 minor version. Resulting minor and major version numbers MUST be 575 then separately compared numerically. 577 o value of attribute "slot-id" MUST be processed as a specific 578 scheme-based normalization permitted by Section 6.2.3 of [RFC3986] 579 and compared numerically. 581 o value of "pin-source", if deemed containing the filename with the 582 PIN value, MUST be compared using the simple string comparison 583 after the full syntax based normalization as specified in 584 Section 6.2.2 of [RFC3986] is applied. If value of the "pin- 585 source" attribute is believed to be overloaded the case and 586 percent-encoding normalization SHOULD be applied before the values 587 are compared but the exact mechanism of comparison is left to the 588 application. 590 o value of attribute "module-path" MUST be compared using the simple 591 string comparison after the full syntax based normalization as 592 specified in Section 6.2.2 of [RFC3986] is applied. 594 o when comparing vendor specific attributes the case and percent- 595 encoding normalization as specified in Section 6.2.2 of [RFC3986] 596 SHOULD be applied before the values are compared but the exact 597 mechanism of such a comparison is left to the application. 599 3.7. Generating PKCS#11 URIs 601 When generating URIs for PKCS#11 resources the exact set of 602 attributes used in a URI is inherently context specific. A PKCS#11 603 URI template [RFC6570] support MAY be provided by a URI generating 604 application to list URIs to access the same resource(s) again if the 605 template captured the necessary context. 607 4. Examples of PKCS#11 URIs 609 This section contains some examples of how PKCS#11 token objects, 610 tokens, slots, and libraries can be identified using the PKCS#11 URI 611 scheme. Note that in some of the following examples, newlines and 612 spaces were inserted for better readability. As specified in 613 Appendix C of [RFC3986], whitespace SHOULD be ignored when extracting 614 the URI. Also note that all spaces as part of the URI are percent- 615 encoded, as specified in Appendix A of [RFC3986]. 617 An empty PKCS#11 URI might be useful to PKCS#11 consumers. See 618 Section 3.5 for more information on semantics of such a URI. 620 pkcs11: 622 One of the simplest and most useful forms might be a PKCS#11 URI that 623 specifies only an object label and its type. The default token is 624 used so the URI does not specify it. Note that when specifying 625 public objects, a token PIN may not be required. 627 pkcs11:object=my-pubkey;type=public 629 When a private key is specified either the "pin-source" attribute, 630 "pin-value, or an application specific method would be usually used. 631 Note that '/' is not percent-encoded in the "pin-source" attribute 632 value since this attribute is part of the query component, not the 633 path, and thus is separated by '?' from the rest of the URI. 635 pkcs11:object=my-key;type=private?pin-source=/etc/token 637 The following example identifies a certificate in the software token. 638 Note an empty value for the attribute "serial" which matches only 639 empty "serialNumber" member of the "CK_TOKEN_INFO" structure. Also 640 note that the "id" attribute value is entirely percent-encoded, as 641 recommended. While ',' is in the reserved set it does not have to be 642 percent-encoded since it does not conflict with any sub-delimiters 643 used. The '#' character as in "The Software PKCS#11 Softtoken" MUST 644 be percent-encoded. 646 pkcs11:token=The%20Software%20PKCS%2311%20Softtoken; 647 manufacturer=Snake%20Oil,%20Inc.; 648 model=1.0; 649 object=my-certificate; 650 type=cert; 651 id=%69%95%3E%5C%F4%BD%EC%91; 652 serial= 653 ?pin-source=/etc/token_pin 655 The next example covers how to use the "module-name" query attribute. 656 Considering that the module is located in /usr/lib/libmypkcs11.so.1 657 file, the attribute value is "mypkcs11", meaning only the module name 658 without the full path, and without the platform specific "lib" prefix 659 and ".so.1" suffix. 661 pkcs11:object=my-sign-key; 662 type=private 663 ?module-name=mypkcs11 665 The following example covers how to use the "module-path" query 666 attribute. The attribute may be useful if a user needs to provide 667 the key via a PKCS#11 module stored on a removable media, for 668 example. Getting the PIN to access the private key here is left to 669 be application specific. 671 pkcs11:object=my-sign-key; 672 type=private 673 ?module-path=/mnt/libmypkcs11.so.1 675 In the context where a token is expected the token can be identified 676 without specifying any PKCS#11 objects. A PIN might still be needed 677 in the context of listing all objects in the token, for example. 678 Section 7 should be consulted before the "pin-value" attribute is 679 ever used. 681 pkcs11:token=Software%20PKCS%2311%20softtoken; 682 manufacturer=Snake%20Oil,%20Inc. 683 ?pin-value=the-pin 685 In the context where a slot is expected the slot can be identified 686 without specifying any PKCS#11 objects in any token it may be 687 inserted in it. 689 pkcs11:slot-description=Sun%20Metaslot 691 The Cryptoki library alone can be also identified without specifying 692 a PKCS#11 token or object. 694 pkcs11:library-manufacturer=Snake%20Oil,%20Inc.; 695 library-description=Soft%20Token%20Library; 696 library-version=1.23 698 The following example shows an attribute value with a semicolon. In 699 such case it MUST be percent-encoded. The token attribute value MUST 700 be read as "My token; created by Joe". Lower case letters MAY be 701 used in percent-encoding as shown below in the "id" attribute value 702 but note that Sections 2.1 and 6.2.2.1 of [RFC3986] read that all 703 percent-encoded characters SHOULD use the uppercase hexadecimal 704 digits. More specifically, if the URI string was to be compared the 705 algorithm defined in Section 3.6 explicitly requires percent-encoding 706 to use the uppercase digits A-F in the "id" attribute values. And as 707 explained in Section 3.3, library version "3" MUST be interpreted as 708 "3" for the major and "0" for the minor version of the library. 710 pkcs11:token=My%20token%25%20created%20by%20Joe; 711 library-version=3; 712 id=%01%02%03%Ba%dd%Ca%fe%04%05%06 714 If there is any need to include literal "%;" substring, for example, 715 both characters MUST be escaped. The token value MUST be read as "A 716 name with a substring %;". 718 pkcs11:token=A%20name%20with%20a%20substring%20%25%3B; 719 object=my-certificate; 720 type=cert 722 The next example includes a small A with acute in the token name. It 723 MUST be encoded in octets according to the UTF-8 character encoding 724 and then percent-encoded. Given that a small A with acute is U+225 725 unicode code point, the UTF-8 encoding is 195 161 in decimal, and 726 that is "%C3%A1" in percent-encoding. 728 pkcs11:token=Name%20with%20a%20small%20A%20with%20acute:%20%C3%A1; 729 object=my-certificate; 730 type=cert 732 Both the path and query components MAY contain vendor specific 733 attributes. Attributes in the query component MUST be delimited by 734 '&'. 736 pkcs11:token=my-token; 737 object=my-certificate; 738 type=cert; 739 vendor-aaa=value-a 740 ?pin-source=/etc/token_pin 741 &vendor-bbb=value-b 743 5. IANA Considerations 745 5.1. URI Scheme Registration 747 This document moves the "pkcs11" URI scheme from the provisional to 748 permanent URI scheme registry. The registration request complies 749 with [RFC4395]. 751 URI scheme name: pkcs11 753 URI scheme status: permanent 755 URI scheme syntax: defined in Section 3.3 of [RFCXXXX] 757 URI scheme semantics: defined in Section 1 of [RFCXXXX] 759 Encoding considerations: see Section 3.3 and Section 6 of 760 [RFCXXXX] 761 Applications/protocols that use this URI scheme name: for general 762 information, see Section 1 of [RFCXXXX]. List of known consumers 763 of the PKCS#11 URI include GnuTLS, Gnome, p11-kit, Oracle 764 Solaris 11 and higher, OpenSC, OpenConnect, and FreeIPA. 766 Interoperability considerations: see Section 6 of [RFCXXXX] 768 Security considerations: see Section 7 of [RFCXXXX] 770 Contact: Jan Pechanec , Darren Moffat 771 773 Author/Change Controller: IESG 775 References: [RFCXXXX] 777 6. Internationalization Considerations 779 The PKCS#11 specification does not specify a canonical form for 780 strings of characters of the CK_UTF8CHAR type. This presents the 781 usual false negative and false positive (aliasing) concerns that 782 arise when dealing with unnormalized strings. Because all PKCS#11 783 items are local and local security is assumed, these concerns are 784 mainly about usability and interoperability. 786 In order to improve the user experience, it is RECOMMENDED that 787 applications that create PKCS#11 objects or label tokens do not use 788 characters outside the US-ASCII character set for the labels. If 789 that is not possible, labels SHOULD be normalized to Normalization 790 Form C (NFC) [UAX15]. For the same reason PKCS#11 libraries, slots 791 (token readers), and tokens SHOULD use US-ASCII characters only for 792 their names and if that is not possible, they SHOULD normalize their 793 names to NFC. When listing PKCS#11 libraries, slots, tokens, and/or 794 objects, an application SHOULD normalize their names to NFC if 795 characters outside of the US-ASCII character set are expected. When 796 matching PKCS#11 URIs to libraries, slots, tokens, and/or objects, 797 applications MAY use form-insensitive Unicode string comparison for 798 matching, as those might pre-date these recommendations. See also 799 Section 3.5. 801 7. Security Considerations 803 There are general security considerations for URI schemes discussed 804 in Section 7 of [RFC3986]. 806 From those security considerations, Section 7.1 of [RFC3986] applies 807 since there is no guarantee that the same PKCS#11 URI will always 808 identify the same object, token, slot, or a library in the future. 810 Section 7.2 of [RFC3986] applies since by accepting query component 811 attributes "module-name" or "module-path" the consumer potentially 812 allows loading of arbitrary code into a process. 814 Section 7.5 of [RFC3986] applies since the PKCS#11 URI may be used in 815 world readable command line arguments to run applications, stored in 816 public configuration files, or otherwise used in clear text. For 817 that reason the "pin-value" attribute should only be used if the URI 818 string itself is protected with the same level of security as the 819 token PIN itself otherwise is. 821 The PKCS#11 specification does not provide means to authenticate 822 devices to users; it only allows to authenticate users to tokens. 823 Instead, local and physical security are demanded: the user must be 824 in possession of their tokens, and system into whose slots the users' 825 tokens are inserted must be secure. As a result, the usual security 826 considerations regarding normalization do not arise. For the same 827 reason, confusable script issues also do not arise. Nonetheless, if 828 use of characters outside the US-ASCII character set is required, it 829 is best to normalize to NFC all strings appearing in PKCS#11 API 830 elements. See also Section 6. 832 8. References 834 8.1. Normative References 836 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 837 Requirement Levels", RFC 2119, STD 14, March 1997. 839 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 840 10646", RFC 3629, STD 63, November 2003. 842 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 843 Resource Identifier (URI): Generic Syntax", RFC 3986, STD 844 66, January 2005. 846 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 847 Specifications: ABNF", RFC 5234, STD 68, January 2008. 849 8.2. Informative References 851 [BCP178] Saint-Andre, P., Crocker, D., and M. Nottingham, 852 "Deprecating the "X-" Prefix and Similar Constructs in 853 Application Protocols", RFC 6648, BCP 178, June 2012. 855 [PKCS11] RSA Laboratories, "PKCS #11: Cryptographic Token Interface 856 Standard v2.20", June 2004. 858 [RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource 859 Identifiers (IRIs)", RFC 3987, January 2005. 861 [RFC4395] Hansen, T., Hardie, T., and L. Masinter, "Guidelines and 862 Registration Procedures for New URI Schemes", RFC 4395, 863 February 2006. 865 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 866 and D. Orchard, "URI Template", RFC 6570, March 2012. 868 [UAX15] Davis, M., Ed., Whistler, K., Ed., and Unicode Consortium, 869 "Unicode Standard Annex #15 - Unicode Normalization Forms, 870 Version Unicode 7.0.0", June 2014. 872 Authors' Addresses 874 Jan Pechanec 875 Oracle Corporation 876 4180 Network Circle 877 Santa Clara CA 95054 878 USA 880 Email: Jan.Pechanec@Oracle.COM 881 URI: http://www.oracle.com 883 Darren J. Moffat 884 Oracle Corporation 885 Oracle Parkway 886 Thames Valley Park 887 Reading RG6 1RA 888 UK 890 Email: Darren.Moffat@Oracle.COM 891 URI: http://www.oracle.com