1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#ifndef _PKCS11URI_H_
6#define _PKCS11URI_H_ 1
7
8#include "seccomon.h"
9
10/* Path attributes defined in RFC7512. */
11#define PK11URI_PATTR_TOKEN "token"
12#define PK11URI_PATTR_MANUFACTURER "manufacturer"
13#define PK11URI_PATTR_SERIAL "serial"
14#define PK11URI_PATTR_MODEL "model"
15#define PK11URI_PATTR_LIBRARY_MANUFACTURER "library-manufacturer"
16#define PK11URI_PATTR_LIBRARY_DESCRIPTION "library-description"
17#define PK11URI_PATTR_LIBRARY_VERSION "library-version"
18#define PK11URI_PATTR_OBJECT "object"
19#define PK11URI_PATTR_TYPE "type"
20#define PK11URI_PATTR_ID "id"
21#define PK11URI_PATTR_SLOT_MANUFACTURER "slot-manufacturer"
22#define PK11URI_PATTR_SLOT_DESCRIPTION "slot-description"
23#define PK11URI_PATTR_SLOT_ID "slot-id"
24
25/* Query attributes defined in RFC7512. */
26#define PK11URI_QATTR_PIN_SOURCE "pin-source"
27#define PK11URI_QATTR_PIN_VALUE "pin-value"
28#define PK11URI_QATTR_MODULE_NAME "module-name"
29#define PK11URI_QATTR_MODULE_PATH "module-path"
30
31SEC_BEGIN_PROTOS
32
33/* A PK11URI object is an immutable structure that holds path and
34 * query attributes of a PKCS#11 URI. */
35struct PK11URIStr;
36typedef struct PK11URIStr PK11URI;
37
38struct PK11URIAttributeStr {
39 const char *name;
40 const char *value;
41};
42typedef struct PK11URIAttributeStr PK11URIAttribute;
43
44/* Create a new PK11URI object from a set of attributes. */
45extern PK11URI *PK11URI_CreateURI(const PK11URIAttribute *pattrs,
46 size_t num_pattrs,
47 const PK11URIAttribute *qattrs,
48 size_t num_qattrs);
49
50/* Parse PKCS#11 URI and return a new PK11URI object. */
51extern PK11URI *PK11URI_ParseURI(const char *string);
52
53/* Format a PK11URI object to a string. */
54extern char *PK11URI_FormatURI(PLArenaPool *arena, PK11URI *uri);
55
56/* Destroy a PK11URI object. */
57extern void PK11URI_DestroyURI(PK11URI *uri);
58
59/* Retrieve a path attribute with the given name. This function can be used only
60 * when we can assume that the attribute value is a string (such as "label" or
61 * "type"). If it can be a binary blob (such as "id"), use
62 * PK11URI_GetPathAttributeItem.
63 */
64extern const char *PK11URI_GetPathAttribute(PK11URI *uri, const char *name);
65
66/* Retrieve a query attribute with the given name. This function can be used
67 * only when we can assume that the attribute value is a string (such as
68 * "module-name"). If it can be a binary blob, use
69 * PK11URI_GetQueryAttributeItem.*/
70extern const char *PK11URI_GetQueryAttribute(PK11URI *uri, const char *name);
71
72/* Retrieve a path attribute with the given name as a SECItem. */
73extern const SECItem *PK11URI_GetPathAttributeItem(PK11URI *uri, const char *name);
74
75/* Retrieve a query attribute with the given name as a SECItem. */
76extern const SECItem *PK11URI_GetQueryAttributeItem(PK11URI *uri, const char *name);
77
78SEC_END_PROTOS
79
80#endif /* _PKCS11URI_H_ */
81

source code of include/nss/pkcs11uri.h