pkcs11uri.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef _PKCS11URI_H_
  5. #define _PKCS11URI_H_ 1
  6. #include "seccomon.h"
  7. /* Path attributes defined in RFC7512. */
  8. #define PK11URI_PATTR_TOKEN "token"
  9. #define PK11URI_PATTR_MANUFACTURER "manufacturer"
  10. #define PK11URI_PATTR_SERIAL "serial"
  11. #define PK11URI_PATTR_MODEL "model"
  12. #define PK11URI_PATTR_LIBRARY_MANUFACTURER "library-manufacturer"
  13. #define PK11URI_PATTR_LIBRARY_DESCRIPTION "library-description"
  14. #define PK11URI_PATTR_LIBRARY_VERSION "library-version"
  15. #define PK11URI_PATTR_OBJECT "object"
  16. #define PK11URI_PATTR_TYPE "type"
  17. #define PK11URI_PATTR_ID "id"
  18. #define PK11URI_PATTR_SLOT_MANUFACTURER "slot-manufacturer"
  19. #define PK11URI_PATTR_SLOT_DESCRIPTION "slot-description"
  20. #define PK11URI_PATTR_SLOT_ID "slot-id"
  21. /* Query attributes defined in RFC7512. */
  22. #define PK11URI_QATTR_PIN_SOURCE "pin-source"
  23. #define PK11URI_QATTR_PIN_VALUE "pin-value"
  24. #define PK11URI_QATTR_MODULE_NAME "module-name"
  25. #define PK11URI_QATTR_MODULE_PATH "module-path"
  26. SEC_BEGIN_PROTOS
  27. /* A PK11URI object is an immutable structure that holds path and
  28. * query attributes of a PKCS#11 URI. */
  29. struct PK11URIStr;
  30. typedef struct PK11URIStr PK11URI;
  31. struct PK11URIAttributeStr {
  32. const char *name;
  33. const char *value;
  34. };
  35. typedef struct PK11URIAttributeStr PK11URIAttribute;
  36. /* Create a new PK11URI object from a set of attributes. */
  37. extern PK11URI *PK11URI_CreateURI(const PK11URIAttribute *pattrs,
  38. size_t num_pattrs,
  39. const PK11URIAttribute *qattrs,
  40. size_t num_qattrs);
  41. /* Parse PKCS#11 URI and return a new PK11URI object. */
  42. extern PK11URI *PK11URI_ParseURI(const char *string);
  43. /* Format a PK11URI object to a string. */
  44. extern char *PK11URI_FormatURI(PLArenaPool *arena, PK11URI *uri);
  45. /* Destroy a PK11URI object. */
  46. extern void PK11URI_DestroyURI(PK11URI *uri);
  47. /* Retrieve a path attribute with the given name. */
  48. extern const char *PK11URI_GetPathAttribute(PK11URI *uri, const char *name);
  49. /* Retrieve a query attribute with the given name. */
  50. extern const char *PK11URI_GetQueryAttribute(PK11URI *uri, const char *name);
  51. SEC_END_PROTOS
  52. #endif /* _PKCS11URI_H_ */