summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-03-31 12:41:43 +0200
committerStef Walter <stefw@collabora.co.uk>2011-03-31 12:41:43 +0200
commit479cbd55ee5739d3cd2566379575451dbecf4c54 (patch)
treeec6730dfbd1855dc6193fe2b5df2d09e208200a3
parent6132cd99c39739ef5360e41e92f22d287007577e (diff)
Documentation and API cleanup.
* Rename source directory * More consistent with return values from URI functions. * Allow formatting URI to take a uri type.
-rw-r--r--.gitignore17
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac17
-rw-r--r--doc/Makefile.am80
-rw-r--r--doc/p11-kit-docs.sgml24
-rw-r--r--doc/p11-kit-overrides.txt0
-rw-r--r--doc/p11-kit-sections.txt40
-rw-r--r--doc/version.xml.in1
-rw-r--r--gtk-doc.make230
-rw-r--r--p11-kit/Makefile.am (renamed from module/Makefile.am)1
-rw-r--r--p11-kit/conf.c (renamed from module/conf.c)0
-rw-r--r--p11-kit/conf.h (renamed from module/conf.h)0
-rw-r--r--p11-kit/hash.c (renamed from module/hash.c)1
-rw-r--r--p11-kit/hash.h (renamed from module/hash.h)0
-rw-r--r--p11-kit/p11-kit-lib.c (renamed from module/p11-kit-lib.c)103
-rw-r--r--p11-kit/p11-kit-messages.c (renamed from module/p11-kit-messages.c)16
-rw-r--r--p11-kit/p11-kit-private.h (renamed from module/p11-kit-private.h)0
-rw-r--r--p11-kit/p11-kit-proxy.c (renamed from module/p11-kit-proxy.c)0
-rw-r--r--p11-kit/p11-kit-uri.c (renamed from module/p11-kit-uri.c)360
-rw-r--r--p11-kit/p11-kit-uri.h (renamed from module/p11-kit-uri.h)25
-rw-r--r--p11-kit/p11-kit.h (renamed from module/p11-kit.h)0
-rw-r--r--p11-kit/p11-kit.pc17
-rw-r--r--p11-kit/p11-kit.pc.in (renamed from module/p11-kit.pc.in)0
-rw-r--r--p11-kit/pkcs11.h (renamed from module/pkcs11.h)0
-rw-r--r--p11-kit/util.c (renamed from module/util.c)0
-rw-r--r--p11-kit/util.h (renamed from module/util.h)0
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/uri-test.c82
28 files changed, 857 insertions, 171 deletions
diff --git a/.gitignore b/.gitignore
index 7549859..f2047de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
*.gcov
*~
*.html
+*.stamp
.deps
.libs
@@ -38,6 +39,22 @@ missing
stamp-h1
temp.txt
+/doc/html
+/doc/p11-kit-decl-list.txt
+/doc/p11-kit-decl.txt
+/doc/p11-kit-undeclared.txt
+/doc/p11-kit-undocumented.txt
+/doc/p11-kit-unused.txt
+/doc/p11-kit.args
+/doc/p11-kit.hierarchy
+/doc/p11-kit.interfaces
+/doc/p11-kit.prerequisites
+/doc/p11-kit.signals
+/doc/p11-kit.types
+/doc/tmpl/
+/doc/version.xml
+/doc/xml/
+
/module/p11-kit.pc
/po/POTFILES
diff --git a/Makefile.am b/Makefile.am
index e8f0c0c..811b752 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,9 @@
-SUBDIRS = module tests doc po
+SUBDIRS = \
+ p11-kit \
+ tests \
+ doc \
+ po
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 9f63f66..a10790b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_CONFIG_MACRO_DIR([m4])
AC_INIT([p11-kit],[0.1],[http://bugzilla.example.com])
-AC_CONFIG_SRCDIR([module/p11-kit-lib.c])
+AC_CONFIG_SRCDIR([p11-kit/p11-kit-lib.c])
AC_CONFIG_HEADERS([config.h])
dnl Other initialization
@@ -31,6 +31,8 @@ AC_CHECK_LIB(dl, dlopen,,
dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_MEMBERS([struct dirent.d_type],,,[#include <dirent.h>])
+GTK_DOC_CHECK([1.15])
+
# --------------------------------------------------------------------
# PKCS#11 Directories
@@ -134,11 +136,12 @@ fi
# ---------------------------------------------------------------------
AC_CONFIG_FILES([Makefile
- module/Makefile
- module/p11-kit.pc
- po/Makefile.in
- tests/Makefile
- doc/Makefile
- ])
+ doc/Makefile
+ doc/version.xml
+ po/Makefile.in
+ p11-kit/Makefile
+ p11-kit/p11-kit.pc
+ tests/Makefile
+])
AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 52c269b..b18d86a 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,22 +1,72 @@
+abs_top_builddir = @abs_top_builddir@
-# p11-kit-glue.xml
+# We require automake 1.6 at least.
+AUTOMAKE_OPTIONS = 1.6
-PARTS = \
- p11-kit-config.xml \
- p11-kit-multiple-problem.xml
+# The name of the module, e.g. 'glib'.
+DOC_MODULE=p11-kit
-BOOK = \
- p11-kit.xml
+# The top-level SGML file. You can change this if you want to.
+DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
-DOCUMENTS = \
- html/p11-kit.html
+# The directory containing the source code. Relative to $(srcdir).
+# gtk-doc will search all .c & .h files beneath here for inline comments
+# documenting the functions and macros.
+# e.g. DOC_SOURCE_DIR=../../../gtk
+DOC_SOURCE_DIR=../p11-kit
-all-local: $(DOCUMENTS)
+# Extra options to pass to gtkdoc-scangobj. Not normally needed.
+SCANGOBJ_OPTIONS= --version
-html/p11-kit.html: $(BOOK) $(PARTS)
- xmlto --skip-validation -vv html-nochunks -o html/ p11-kit.xml
+# Extra options to supply to gtkdoc-scan.
+# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
+SCAN_OPTIONS= --rebuild-types
-EXTRA_DIST = \
- $(BOOK) \
- $(PARTS) \
- docbook-params.xsl
+# Extra options to supply to gtkdoc-mkdb.
+# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
+MKDB_OPTIONS=--sgml-mode --output-format=xml
+
+# Extra options to supply to gtkdoc-mktmpl
+# e.g. MKTMPL_OPTIONS=--only-section-tmpl
+MKTMPL_OPTIONS=
+
+# Extra options to supply to gtkdoc-fixref. Not normally needed.
+# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
+FIXXREF_OPTIONS=
+
+# Used for dependencies. The docs will be rebuilt if any of these change.
+# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
+# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
+HFILE_GLOB=$(top_srcdir)/p11-kit/p11-kit-*.h
+CFILE_GLOB=$(top_srcdir)/p11-kit/p11-kit-*.c
+
+# Header files to ignore when scanning.
+# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
+IGNORE_HFILES= p11-kit-private.h pkcs11.h hash.h conf.h util.h
+
+# Images to copy into HTML directory.
+# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
+HTML_IMAGES=
+
+# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
+# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
+content_files=p11-kit-config.xml p11-kit-multiple-problem.xml
+
+# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
+# These files must be listed here *and* in content_files
+# e.g. expand_content_files=running.sgml
+expand_content_files=
+
+# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
+# Only needed if you are using gtkdoc-scangobj to dynamically query widget
+# signals and properties.
+# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
+# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
+INCLUDES=
+GTKDOC_LIBS=
+
+# This includes the standard gtk-doc make rules, copied by gtkdocize.
+include $(top_srcdir)/gtk-doc.make
+
+EXTRA_DIST += \
+ version.xml.in
diff --git a/doc/p11-kit-docs.sgml b/doc/p11-kit-docs.sgml
new file mode 100644
index 0000000..03fd582
--- /dev/null
+++ b/doc/p11-kit-docs.sgml
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
+[
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
+<book id="index">
+ <bookinfo>
+ <title>P11-Kit Manual</title>
+ <releaseinfo>for p11-kit &version;</releaseinfo>
+ </bookinfo>
+
+ <chapter>
+ <title>Reference</title>
+ <xi:include href="xml/p11-kit.xml"/>
+ <xi:include href="xml/p11-kit-uri.xml"/>
+ <xi:include href="xml/p11-kit-util.xml"/>
+ <index id="api-index-full">
+ <title>API Index</title>
+ <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
+ </index>
+ </chapter>
+</book>
diff --git a/doc/p11-kit-overrides.txt b/doc/p11-kit-overrides.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/doc/p11-kit-overrides.txt
diff --git a/doc/p11-kit-sections.txt b/doc/p11-kit-sections.txt
new file mode 100644
index 0000000..fbe7452
--- /dev/null
+++ b/doc/p11-kit-sections.txt
@@ -0,0 +1,40 @@
+<SECTION>
+<FILE>p11-kit-uri</FILE>
+P11_KIT_URI_SCHEME
+P11_KIT_URI_SCHEME_LEN
+P11KitUriType
+P11KitUriResult
+P11KitUri
+p11_kit_uri_new
+p11_kit_uri_get_module_info
+p11_kit_uri_match_module_info
+p11_kit_uri_get_token_info
+p11_kit_uri_match_token_info
+p11_kit_uri_get_attribute_types
+p11_kit_uri_get_attribute
+p11_kit_uri_set_attribute
+p11_kit_uri_clear_attribute
+p11_kit_uri_match_attributes
+p11_kit_uri_set_unrecognized
+p11_kit_uri_any_unrecognized
+p11_kit_uri_format
+p11_kit_uri_parse
+p11_kit_uri_free
+</SECTION>
+
+<SECTION>
+<FILE>p11-kit</FILE>
+p11_kit_initialize_registered
+p11_kit_finalize_registered
+p11_kit_registered_modules
+p11_kit_registered_module_to_name
+p11_kit_registered_name_to_module
+p11_kit_registered_option
+p11_kit_initialize_module
+p11_kit_finalize_module
+</SECTION>
+
+<SECTION>
+<FILE>p11-kit-util</FILE>
+p11_kit_strerror
+</SECTION> \ No newline at end of file
diff --git a/doc/version.xml.in b/doc/version.xml.in
new file mode 100644
index 0000000..27323da
--- /dev/null
+++ b/doc/version.xml.in
@@ -0,0 +1 @@
+@VERSION@ \ No newline at end of file
diff --git a/gtk-doc.make b/gtk-doc.make
new file mode 100644
index 0000000..a97578b
--- /dev/null
+++ b/gtk-doc.make
@@ -0,0 +1,230 @@
+# -*- mode: makefile -*-
+
+####################################
+# Everything below here is generic #
+####################################
+
+if GTK_DOC_USE_LIBTOOL
+GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
+GTKDOC_RUN = $(LIBTOOL) --mode=execute
+else
+GTKDOC_CC = $(CC) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+GTKDOC_LD = $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
+GTKDOC_RUN =
+endif
+
+# We set GPATH here; this gives us semantics for GNU make
+# which are more like other make's VPATH, when it comes to
+# whether a source that is a target of one rule is then
+# searched for in VPATH/GPATH.
+#
+GPATH = $(srcdir)
+
+TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
+
+EXTRA_DIST = \
+ $(content_files) \
+ $(HTML_IMAGES) \
+ $(DOC_MAIN_SGML_FILE) \
+ $(DOC_MODULE)-sections.txt \
+ $(DOC_MODULE)-overrides.txt
+
+DOC_STAMPS=scan-build.stamp tmpl-build.stamp sgml-build.stamp html-build.stamp \
+ pdf-build.stamp \
+ $(srcdir)/tmpl.stamp $(srcdir)/sgml.stamp $(srcdir)/html.stamp \
+ $(srcdir)/pdf.stamp
+
+SCANOBJ_FILES = \
+ $(DOC_MODULE).args \
+ $(DOC_MODULE).hierarchy \
+ $(DOC_MODULE).interfaces \
+ $(DOC_MODULE).prerequisites \
+ $(DOC_MODULE).signals
+
+REPORT_FILES = \
+ $(DOC_MODULE)-undocumented.txt \
+ $(DOC_MODULE)-undeclared.txt \
+ $(DOC_MODULE)-unused.txt
+
+CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS)
+
+if ENABLE_GTK_DOC
+if GTK_DOC_BUILD_HTML
+HTML_BUILD_STAMP=html-build.stamp
+else
+HTML_BUILD_STAMP=
+endif
+if GTK_DOC_BUILD_PDF
+PDF_BUILD_STAMP=pdf-build.stamp
+else
+PDF_BUILD_STAMP=
+endif
+
+all-local: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
+else
+all-local:
+endif
+
+docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
+
+$(REPORT_FILES): sgml-build.stamp
+
+#### scan ####
+
+scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB)
+ @echo 'gtk-doc: Scanning header files'
+ @-chmod -R u+w $(srcdir)
+ @_source_dir='' ; for i in $(DOC_SOURCE_DIR) ; do \
+ _source_dir="$${_source_dir} --source-dir=$$i" ; \
+ done ; \
+ cd $(srcdir) && \
+ gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES)
+ @if grep -l '^..*$$' $(srcdir)/$(DOC_MODULE).types > /dev/null 2>&1 ; then \
+ CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" gtkdoc-scangobj $(SCANGOBJ_OPTIONS) --module=$(DOC_MODULE) --output-dir=$(srcdir) ; \
+ else \
+ cd $(srcdir) ; \
+ for i in $(SCANOBJ_FILES) ; do \
+ test -f $$i || touch $$i ; \
+ done \
+ fi
+ @touch scan-build.stamp
+
+$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
+ @true
+
+#### templates ####
+
+tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt
+ @echo 'gtk-doc: Rebuilding template files'
+ @-chmod -R u+w $(srcdir)
+ @cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE) $(MKTMPL_OPTIONS)
+ @touch tmpl-build.stamp
+
+tmpl.stamp: tmpl-build.stamp
+ @true
+
+$(srcdir)/tmpl/*.sgml:
+ @true
+
+#### xml ####
+
+sgml-build.stamp: tmpl.stamp $(DOC_MODULE)-sections.txt $(srcdir)/tmpl/*.sgml $(expand_content_files)
+ @echo 'gtk-doc: Building XML'
+ @-chmod -R u+w $(srcdir)
+ @_source_dir='' ; for i in $(DOC_SOURCE_DIR) ; do \
+ _source_dir="$${_source_dir} --source-dir=$$i" ; \
+ done ; \
+ cd $(srcdir) && \
+ gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS)
+ @touch sgml-build.stamp
+
+sgml.stamp: sgml-build.stamp
+ @true
+
+#### html ####
+
+html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
+ @echo 'gtk-doc: Building HTML'
+ @-chmod -R u+w $(srcdir)
+ @rm -rf $(srcdir)/html
+ @mkdir $(srcdir)/html
+ @mkhtml_options=""; \
+ gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
+ if test "$(?)" = "0"; then \
+ mkhtml_options=--path="$(srcdir)"; \
+ fi; \
+ cd $(srcdir)/html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
+ @test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
+ @echo 'gtk-doc: Fixing cross-references'
+ @cd $(srcdir) && gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) | grep -v "no link for.*CK-.*CAPS" || true
+ @touch html-build.stamp
+
+#### pdf ####
+
+pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
+ @echo 'gtk-doc: Building PDF'
+ @-chmod -R u+w $(srcdir)
+ @rm -rf $(srcdir)/$(DOC_MODULE).pdf
+ @mkpdf_imgdirs=""; \
+ if test "x$(HTML_IMAGES)" != "x"; then \
+ for img in $(HTML_IMAGES); do \
+ part=`dirname $$img`; \
+ echo $$mkpdf_imgdirs | grep >/dev/null "\-\-imgdir=$$part "; \
+ if test $$? != 0; then \
+ mkpdf_imgdirs="$$mkpdf_imgdirs --imgdir=$$part"; \
+ fi; \
+ done; \
+ fi; \
+ cd $(srcdir) && gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_imgdirs $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS)
+ @touch pdf-build.stamp
+
+##############
+
+clean-local:
+ rm -f *~ *.bak
+ rm -rf .libs
+
+distclean-local:
+ cd $(srcdir) && \
+ rm -rf xml $(REPORT_FILES) $(DOC_MODULE).pdf \
+ $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
+
+maintainer-clean-local: clean
+ cd $(srcdir) && rm -rf xml html
+
+install-data-local:
+ @installfiles=`echo $(srcdir)/html/*`; \
+ if test "$$installfiles" = '$(srcdir)/html/*'; \
+ then echo '-- Nothing to install' ; \
+ else \
+ if test -n "$(DOC_MODULE_VERSION)"; then \
+ installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
+ else \
+ installdir="$(DESTDIR)$(TARGET_DIR)"; \
+ fi; \
+ $(mkinstalldirs) $${installdir} ; \
+ for i in $$installfiles; do \
+ echo '-- Installing '$$i ; \
+ $(INSTALL_DATA) $$i $${installdir}; \
+ done; \
+ if test -n "$(DOC_MODULE_VERSION)"; then \
+ mv -f $${installdir}/$(DOC_MODULE).devhelp2 \
+ $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \
+ mv -f $${installdir}/$(DOC_MODULE).devhelp \
+ $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp; \
+ fi; \
+ $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \
+ fi
+
+uninstall-local:
+ @if test -n "$(DOC_MODULE_VERSION)"; then \
+ installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
+ else \
+ installdir="$(DESTDIR)$(TARGET_DIR)"; \
+ fi; \
+ rm -rf $${installdir}
+
+#
+# Require gtk-doc when making dist
+#
+if ENABLE_GTK_DOC
+dist-check-gtkdoc:
+else
+dist-check-gtkdoc:
+ @echo "*** gtk-doc must be installed and enabled in order to make dist"
+ @false
+endif
+
+dist-hook: dist-check-gtkdoc dist-hook-local
+ mkdir $(distdir)/tmpl
+ mkdir $(distdir)/html
+ -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
+ cp $(srcdir)/html/* $(distdir)/html
+ -cp $(srcdir)/$(DOC_MODULE).pdf $(distdir)/
+ -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
+ -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
+ cd $(distdir) && rm -f $(DISTCLEANFILES)
+ $(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html
+
+.PHONY : dist-hook-local docs
diff --git a/module/Makefile.am b/p11-kit/Makefile.am
index b4339a8..989f482 100644
--- a/module/Makefile.am
+++ b/p11-kit/Makefile.am
@@ -1,5 +1,4 @@
-
incdir = $(includedir)/p11-kit
inc_HEADERS = \
diff --git a/module/conf.c b/p11-kit/conf.c
index 6c83407..6c83407 100644
--- a/module/conf.c
+++ b/p11-kit/conf.c
diff --git a/module/conf.h b/p11-kit/conf.h
index 84138d2..84138d2 100644
--- a/module/conf.h
+++ b/p11-kit/conf.h
diff --git a/module/hash.c b/p11-kit/hash.c
index 30efced..836e717 100644
--- a/module/hash.c
+++ b/p11-kit/hash.c
@@ -450,4 +450,3 @@ hash_direct_equal (const void *ptr_one, const void *ptr_two)
{
return ptr_one == ptr_two;
}
-
diff --git a/module/hash.h b/p11-kit/hash.h
index eb3c496..eb3c496 100644
--- a/module/hash.h
+++ b/p11-kit/hash.h
diff --git a/module/p11-kit-lib.c b/p11-kit/p11-kit-lib.c
index 33b768f..f57f3d1 100644
--- a/module/p11-kit-lib.c
+++ b/p11-kit/p11-kit-lib.c
@@ -56,6 +56,42 @@
#include <string.h>
#include <unistd.h>
+/**
+ * SECTION:p11-kit
+ * @title: Modules
+ * @short_description: Module loading and initializing
+ *
+ * PKCS\#11 modules are used by crypto libraries and applications to access
+ * crypto objects (like keys and certificates) and to perform crypto operations.
+ *
+ * In order for applications to behave consistently with regard to the user's
+ * installed PKCS\#11 modules, each module must be registered so that applications
+ * or libraries know that they should load it.
+ *
+ * The functions here provide support for initializing registered modules. The
+ * p11_kit_initialize_registered() function should be used to load and initialize
+ * the registered modules. When done, the p11_kit_finalize_registered() function
+ * should be used to release those modules and associated resources.
+ *
+ * In addition p11_kit_registered_option() can be used to access other parts
+ * of the module configuration.
+ *
+ * When multiple consumers of a module (such as libraries or applications) are
+ * in the same process, coordination of the initialization and finalization
+ * of PKCS\#11 modules is required. The functions here automatically provide
+ * initialization reference counting to make this work.
+ *
+ * If a consumer wishes to load an arbitrary PKCS\#11 module that's not
+ * registered, that module should be initialized with p11_kit_initialize_module()
+ * and finalized with p11_kit_finalize_module(). The module's own
+ * <code>C_Initialize</code> and <code>C_Finalize</code> methods should not
+ * be called directly.
+ *
+ * Modules are represented by a pointer to their <code>CK_FUNCTION_LIST</code>
+ * entry points. This means that callers can load modules elsewhere, using
+ * dlopen() for example, and then still use these methods on them.
+ */
+
typedef struct _Module {
char *name;
hash_t *config;
@@ -735,7 +771,7 @@ _p11_kit_initialize_registered_unlocked_reentrant (void)
/**
* p11_kit_initialize_registered:
*
- * Initialize all the registered PKCS#11 modules.
+ * Initialize all the registered PKCS\#11 modules.
*
* If this is the first time this function is called multiple times
* consecutively within a single process, then it merely increments an
@@ -805,7 +841,7 @@ _p11_kit_finalize_registered_unlocked_reentrant (void)
/**
* p11_kit_finalize_registered:
*
- * Finalize all the registered PKCS#11 modules. These should have been
+ * Finalize all the registered PKCS\#11 modules. These should have been
* initialized with p11_kit_initialize_registered().
*
* If p11_kit_initialize_registered() has been called more than once in this
@@ -855,11 +891,11 @@ _p11_kit_registered_modules_unlocked (void)
/**
* p11_kit_registered_modules:
*
- * Get a list of all the registered PKCS#11 modules. This list will be valid
+ * Get a list of all the registered PKCS\#11 modules. This list will be valid
* once the p11_kit_initialize_registered() function has been called.
*
- * The returned value is a %NULL terminated array of %CK_FUNCTION_LIST_PTR
- * pointers.
+ * The returned value is a <code>NULL</code> terminated array of
+ * <code>CK_FUNCTION_LIST_PTR</code> pointers.
*
* Returns: A list of all the registered modules. Use the free() function to
* free the list.
@@ -882,13 +918,14 @@ p11_kit_registered_modules (void)
* p11_kit_registered_module_to_name:
* @funcs: pointer to a registered module
*
- * Get the name of a registered PKCS#11 module.
+ * Get the name of a registered PKCS\#11 module.
*
* You can use p11_kit_registered_modules() to get a list of all the registered
* modules. This name is specified by the registered module configuration.
*
- * Returns: A newly allocated string containing the module name, or %NULL
- * if no such registered module exists. Use free() to free this string.
+ * Returns: A newly allocated string containing the module name, or
+ * <code>NULL</code> if no such registered module exists. Use free() to
+ * free this string.
*/
char*
p11_kit_registered_module_to_name (CK_FUNCTION_LIST_PTR funcs)
@@ -914,10 +951,11 @@ p11_kit_registered_module_to_name (CK_FUNCTION_LIST_PTR funcs)
* p11_kit_registered_name_to_module:
* @name: name of a registered module
*
- * Lookup a registered PKCS#11 module by its name. This name is specified by
+ * Lookup a registered PKCS\#11 module by its name. This name is specified by
* the registered module configuration.
*
- * Returns: a pointer to a PKCS#11 module, or %NULL if this name was not found.
+ * Returns: a pointer to a PKCS\#11 module, or <code>NULL</code> if this name was
+ * not found.
*/
CK_FUNCTION_LIST_PTR
p11_kit_registered_name_to_module (const char *name)
@@ -943,25 +981,36 @@ p11_kit_registered_name_to_module (const char *name)
* @funcs: a pointer to a registered module
* @field: the name of the option to lookup.
*
- * Lookup a configured option for a registered PKCS#11 module.
+ * Lookup a configured option for a registered PKCS\#11 module. If a
+ * <code>NULL</code> funcs argument is specified, then this will lookup
+ * the configuration option in the global config file.
*
- * Returns: A newly allocated string containing the option value, or %NULL
- * if the registered module or the option were not found. Use free() to free
- * the returned string.
+ * Returns: A newly allocated string containing the option value, or
+ * <code>NULL</code> if the registered module or the option were not found.
+ * Use free() to free the returned string.
*/
char*
p11_kit_registered_option (CK_FUNCTION_LIST_PTR funcs, const char *field)
{
Module *module;
char *option = NULL;
+ hash_t *config;
- if (!funcs || !field)
+ if (!field)
return NULL;
_p11_lock ();
- module = gl.modules ? hash_get (gl.modules, funcs) : NULL;
- if (module && module->config) {
+ if (funcs == NULL) {
+ config = gl.config;
+
+ } else {
+ module = gl.modules ? hash_get (gl.modules, funcs) : NULL;
+ if (module)
+ config = module->config;
+ }
+
+ if (config) {
option = hash_get (module->config, field);
if (option)
option = strdup (option);
@@ -976,32 +1025,32 @@ p11_kit_registered_option (CK_FUNCTION_LIST_PTR funcs, const char *field)
* p11_kit_initialize_module:
* @funcs: loaded module to initialize.
*
- * Initialize an arbitrary PKCS#11 module. Normally using the
+ * Initialize an arbitrary PKCS\#11 module. Normally using the
* p11_kit_initialize_registered() is preferred.
*
* Using this function to initialize modules allows coordination between
* multiple users of the same module in a single process. It should be called
* on modules that have been loaded (with dlopen() for example) but not yet
* initialized. The caller should not yet have called the module's
- * %C_Initialize method. This function will call %C_Initialize as necessary.
+ * <code>C_Initialize</code> method. This function will call
+ * <code>C_Initialize</code> as necessary.
*
* Subsequent calls to this function for the same module will result in an
* initialization count being incremented for the module. It is safe (although
* usually unnecessary) to use this function on registered modules.
*
* The module must be finalized with p11_kit_finalize_module() instead of
- * calling its %C_Finalize method directly.
+ * calling its <code>C_Finalize</code> method directly.
*
- * This function does not accept a %CK_C_INITIALIZE_ARGS argument. Custom
- * initialization arguments cannot be supported when multiple consumers load
- * the same module.
+ * This function does not accept a <code>CK_C_INITIALIZE_ARGS</code> argument.
+ * Custom initialization arguments cannot be supported when multiple consumers
+ * load the same module.
*
* Returns: CKR_OK if the initialization was successful.
*/
CK_RV
p11_kit_initialize_module (CK_FUNCTION_LIST_PTR funcs)
{
- CK_C_INITIALIZE_ARGS args;
Module *module;
Module *allocated = NULL;
CK_RV rv = CKR_OK;
@@ -1040,14 +1089,14 @@ p11_kit_initialize_module (CK_FUNCTION_LIST_PTR funcs)
* p11_kit_finalize_module:
* @funcs: loaded module to finalize.
*
- * Finalize an arbitrary PKCS#11 module. The module must have been initialized
+ * Finalize an arbitrary PKCS\#11 module. The module must have been initialized
* using p11_kit_initialize_module(). In most cases callers will want to use
* p11_kit_finalize_registered() instead of this function.
*
* Using this function to finalize modules allows coordination between
* multiple users of the same module in a single process. The caller should
- * call the module's %C_Finalize method. This function will call
- * %C_Finalize as necessary.
+ * call the module's <code>C_Finalize</code> method. This function will call
+ * <code>C_Finalize</code> as necessary.
*
* If the module was initialized more than once, then this function will
* decrement an initialization count for the module. When the count reaches zero
diff --git a/module/p11-kit-messages.c b/p11-kit/p11-kit-messages.c
index 3a71a96..0920a37 100644
--- a/module/p11-kit-messages.c
+++ b/p11-kit/p11-kit-messages.c
@@ -37,6 +37,14 @@
#include "pkcs11.h"
#include "p11-kit.h"
+/**
+ * SECTION:p11-kit-util
+ * @title: Utilities
+ * @short_description: Message Utilities
+ *
+ * Utility functions for working with PKCS\#11.
+ */
+
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(x) dgettext(PACKAGE_NAME, x)
@@ -45,13 +53,13 @@
#endif
/**
- * gck_message_from_rv:
- * @rv: The PKCS#11 return value to get a message for.
+ * p11_kit_strerror:
+ * @rv: The PKCS\#11 return value to get a message for.
*
- * Get a message for a PKCS#11 return value or error code. Do not
+ * Get a message for a PKCS\#11 return value or error code. Do not
* pass CKR_OK or other such non errors to this function.
*
- * Return value: The user readable message.
+ * Returns: The user readable and localized message.
**/
const char*
p11_kit_strerror (CK_RV rv)
diff --git a/module/p11-kit-private.h b/p11-kit/p11-kit-private.h
index 5fbe1eb..5fbe1eb 100644
--- a/module/p11-kit-private.h
+++ b/p11-kit/p11-kit-private.h
diff --git a/module/p11-kit-proxy.c b/p11-kit/p11-kit-proxy.c
index fd28a19..fd28a19 100644
--- a/module/p11-kit-proxy.c
+++ b/p11-kit/p11-kit-proxy.c
diff --git a/module/p11-kit-uri.c b/p11-kit/p11-kit-uri.c
index 6830896..5004ba1 100644
--- a/module/p11-kit-uri.c
+++ b/p11-kit/p11-kit-uri.c
@@ -44,6 +44,78 @@
#include <stdio.h>
#include <string.h>
+/**
+ * SECTION:p11-kit-uri
+ * @title: URIs
+ * @short_description: Parsing and formatting PKCS\#11 URIs
+ *
+ * PKCS\#11 URIs can be used in configuration files or applications to represent
+ * PKCS\#11 modules, tokens or objects. An example of a URI might be:
+ *
+ * <code><literallayout>
+ * pkcs11:token=The\%20Software\%20PKCS\#11\%20softtoken;
+ * manufacturer=Snake\%20Oil,\%20Inc.;serial=;object=my-certificate;
+ * model=1.0;objecttype=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()
+ * to build one. URIs are represented by the #P11KitUri structure. You can match
+ * a parsed URI against PKCS\#11 tokens with p11_kit_uri_match_token_info()
+ * or attributes with p11_kit_uri_match_attributes().
+ *
+ * Since URIs can represent different sorts of things, when parsing or formatting
+ * a URI a 'context' can be used to indicate which sort of URI is expected.
+ *
+ * URIs have an <code>unrecognized</code> flag. This flag is set during parsing
+ * if any parts of the URI are not recognized. This may be because the part is
+ * from a newer version of the PKCS\#11 spec or because that part was not valid
+ * inside of the desired context used when parsing.
+ */
+
+/**
+ * P11KitUri:
+ *
+ * A structure representing a PKCS\#11 URI. There are no public fields
+ * visible in this structure. Use the various accessor functions.
+ */
+
+/**
+ * P11KitUriType:
+ * @P11_KIT_URI_IS_MODULE: The URI represents one or more modules
+ * @P11_KIT_URI_IS_TOKEN: The URI represents one or more tokens
+ * @P11_KIT_URI_IS_OBJECT: The URI represents one or more objects
+ * @P11_KIT_URI_IS_ANY: The URI can represent anything
+ *
+ * A PKCS\#11 URI can represent different kinds of things. This flag is used by
+ * p11_kit_uri_parse() to denote in what context the URI will be used.
+ */
+
+/**
+ * P11KitUriResult:
+ * @P11_KIT_URI_OK: Success
+ * @P11_KIT_URI_NO_MEMORY: Memory allocation failed
+ * @P11_KIT_URI_BAD_SCHEME: The URI had a bad scheme
+ * @P11_KIT_URI_BAD_ENCODING: The URI had a bad encoding
+ * @P11_KIT_URI_BAD_SYNTAX: The URI had a bad syntax
+ * @P11_KIT_URI_BAD_VERSION: The URI contained a bad version number
+ * @P11_KIT_URI_NOT_FOUND: A requested part of the URI was not found
+ *
+ * Error codes returned by various functions. The functions each clearly state
+ * which error codes they are capable of returning.
+ */
+
+/**
+ * P11_KIT_URI_SCHEME:
+ *
+ * String of URI scheme for PKCS\#11 URIs.
+ */
+
+/**
+ * P11_KIT_URI_SCHEME_LEN:
+ *
+ * Length of %P11_KIT_URI_SCHEME.
+ */
+
enum {
CLASS_IDX,
LABEL_IDX,
@@ -202,10 +274,19 @@ match_struct_version (CK_VERSION_PTR inuri, CK_VERSION_PTR real)
/**
* p11_kit_uri_get_module_info:
+ * @uri: the URI
+ *
+ * Get the <code>CK_INFO</code> structure associated with this URI.
*
- * Get the %CK_INFO structure associated with this URI.
+ * If this is a parsed URI, then the fields corresponding to library parts of
+ * the URI will be filled in. Any library URI parts that were missing will have
+ * their fields filled with zeros.
*
- * Returns: A pointer to the %CK_INFO structure.
+ * If the caller wishes to setup information for building a URI, then relevant
+ * fields should be filled in. Fields that should not appear as parts in the
+ * resulting URI should be filled with zeros.
+ *
+ * Returns: A pointer to the <code>CK_INFO</code> structure.
*/
CK_INFO_PTR
p11_kit_uri_get_module_info (P11KitUri *uri)
@@ -216,11 +297,13 @@ p11_kit_uri_get_module_info (P11KitUri *uri)
/**
* p11_kit_uri_match_module_info:
+ * @uri: the URI
+ * @info: the structure to match against the URI
*
- * Match a %CK_INFO structure against the library parts of this URI.
+ * Match a <code>CK_INFO</code> structure against the library parts of this URI.
*
- * Only the fields of the %CK_INFO structure that are valid for use in a
- * URI will be matched. A URI part that was not specified in the URI will
+ * Only the fields of the <code>CK_INFO</code> structure that are valid for use
+ * in a URI will be matched. A URI part that was not specified in the URI will
* match any value in the structure. If during the URI parsing any unrecognized
* parts were encountered then this match will fail.
*
@@ -245,6 +328,22 @@ p11_kit_uri_match_module_info (P11KitUri *uri, CK_INFO_PTR info)
&info->libraryVersion));
}
+/**
+ * p11_kit_uri_get_token_info:
+ * @uri: the URI
+ *
+ * Get the <code>CK_TOKEN_INFO</code> structure associated with this URI.
+ *
+ * If this is a parsed URI, then the fields corresponding to token parts of
+ * the URI will be filled in. Any token URI parts that were missing will have
+ * their fields filled with zeros.
+ *
+ * If the caller wishes to setup information for building a URI, then relevant
+ * fields should be filled in. Fields that should not appear as parts in the
+ * resulting URI should be filled with zeros.
+ *
+ * Returns: A pointer to the <code>CK_INFO</code> structure.
+ */
CK_TOKEN_INFO_PTR
p11_kit_uri_get_token_info (P11KitUri *uri)
{
@@ -254,13 +353,16 @@ p11_kit_uri_get_token_info (P11KitUri *uri)
/**
* p11_kit_uri_match_token_info:
+ * @uri: the URI
+ * @token_info: the structure to match against the URI
*
- * Match a %CK_TOKEN_INFO structure against the token parts of this URI.
+ * Match a <code>CK_TOKEN_INFO</code> structure against the token parts of this
+ * URI.
*
- * Only the fields of the %CK_TOKEN_INFO structure that are valid for use in a
- * URI will be matched. A URI part that was not specified in the URI will
- * match any value in the structure. If during the URI parsing any unrecognized
- * parts were encountered then this match will fail.
+ * Only the fields of the <code>CK_TOKEN_INFO</code> structure that are valid
+ * for use in a URI will be matched. A URI part that was not specified in the
+ * URI will match any value in the structure. If during the URI parsing any
+ * unrecognized parts were encountered then this match will fail.
*
* Returns: 1 if the URI matches, 0 if not.
*/
@@ -287,6 +389,16 @@ p11_kit_uri_match_token_info (P11KitUri *uri, CK_TOKEN_INFO_PTR token_info)
sizeof (token_info->serialNumber)));
}
+/**
+ * p11_kit_uri_get_attribute_types:
+ * @uri: The URI
+ * @n_types: A location at which to return the number of types returned
+ *
+ * Get the types of the attributes present in this URI.
+ *
+ * Returns: A newly allocated array of <code>CK_ATTRIBUTE_TYPE</code>. This
+ * should be freed with free() when done.
+ */
CK_ATTRIBUTE_TYPE*
p11_kit_uri_get_attribute_types (P11KitUri *uri, int *n_types)
{
@@ -309,14 +421,24 @@ p11_kit_uri_get_attribute_types (P11KitUri *uri, int *n_types)
return result;
}
+/**
+ * p11_kit_uri_get_attribute:
+ * @uri: The URI
+ * @attr_type: The attribute type
+ *
+ * Get a pointer to an attribute present in this URI.
+ *
+ * Returns: A pointer to the attribute, or <code>NULL</code> if not present.
+ * The attribute is owned by the URI and should not be freed.
+ */
CK_ATTRIBUTE_PTR
-p11_kit_uri_get_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE type)
+p11_kit_uri_get_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE attr_type)
{
int idx;
assert (uri);
- idx = attribute_to_idx (type);
+ idx = attribute_to_idx (attr_type);
if (idx < 0)
return NULL;
@@ -326,6 +448,19 @@ p11_kit_uri_get_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE type)
return &uri->attrs[idx];
}
+/**
+ * p11_kit_uri_set_attribute:
+ * @uri: The URI
+ * @attr: The attribute to set
+ *
+ * Set an attribute on the URI.
+ *
+ * Only attributes that map to parts in a PKCS\#11 URI will be accepted.
+ *
+ * Returns: %P11_KIT_URI_OK if the attribute was successfully set.
+ * %P11_KIT_URI_NOT_FOUND if the attribute was not valid for a URI.
+ * %P11_KIT_URI_NO_MEMORY if allocation failed.
+ */
int
p11_kit_uri_set_attribute (P11KitUri *uri, CK_ATTRIBUTE_PTR attr)
{
@@ -358,14 +493,26 @@ p11_kit_uri_set_attribute (P11KitUri *uri, CK_ATTRIBUTE_PTR attr)
return P11_KIT_URI_OK;
}
+/**
+ * p11_kit_uri_clear_attribute:
+ * @uri: The URI
+ * @attr_type: The type of the attribute to clear
+ *
+ * Clear an attribute on the URI.
+ *
+ * Only attributes that map to parts in a PKCS\#11 URI will be accepted.
+ *
+ * Returns: %P11_KIT_URI_OK if the attribute was successfully cleared.
+ * %P11_KIT_URI_NOT_FOUND if the attribute was not valid for a URI.
+ */
int
-p11_kit_uri_clear_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE type)
+p11_kit_uri_clear_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE attr_type)
{
int idx;
assert (uri);
- idx = attribute_to_idx (type);
+ idx = attribute_to_idx (attr_type);
if (idx < 0)
return P11_KIT_URI_NOT_FOUND;
assert (idx < NUM_ATTRS);
@@ -373,7 +520,7 @@ p11_kit_uri_clear_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE type)
free (uri->attrs[idx].pValue);
uri->attrs[idx].pValue = NULL;
uri->attrs[idx].ulValueLen = (CK_ULONG)-1;
- return 0;
+ return P11_KIT_URI_OK;
}
static int
@@ -395,6 +542,9 @@ match_attributes (CK_ATTRIBUTE_PTR one, CK_ATTRIBUTE_PTR two)
/**
* p11_kit_uri_match_attributes:
+ * @uri: The URI
+ * @attrs: The attributes to match
+ * @n_attrs: The number of attributes
*
* Match a attributes against the object parts of this URI.
*
@@ -433,6 +583,17 @@ p11_kit_uri_match_attributes (P11KitUri *uri, CK_ATTRIBUTE_PTR attrs,
return 1;
}
+/**
+ * p11_kit_uri_set_unrecognized:
+ * @uri: The URI
+ * @unrecognized: The new unregognized flag value
+ *
+ * Set the unrecognized flag on this URI.
+ *
+ * The unrecognized flag is automatically set to 1 when during parsing any part
+ * of the URI is unrecognized. If the unrecognized flag is set to 1, then
+ * matching against this URI will always fail.
+ */
void
p11_kit_uri_set_unrecognized (P11KitUri *uri, int unrecognized)
{
@@ -440,6 +601,18 @@ p11_kit_uri_set_unrecognized (P11KitUri *uri, int unrecognized)
uri->unrecognized = unrecognized;
}
+/**
+ * p11_kit_uri_any_unrecognized:
+ * @uri: The URI
+ *
+ * Get the unrecognized flag for this URI.
+ *
+ * The unrecognized flag is automatically set to 1 when during parsing any part
+ * of the URI is unrecognized. If the unrecognized flag is set to 1, then
+ * matching against this URI will always fail.
+ *
+ * Returns: 1 if unrecognized flag is set, 0 otherwise.
+ */
int
p11_kit_uri_any_unrecognized (P11KitUri *uri)
{
@@ -447,6 +620,16 @@ p11_kit_uri_any_unrecognized (P11KitUri *uri)
return uri->unrecognized;
}
+/**
+ * p11_kit_uri_new:
+ *
+ * Create a new blank PKCS\#11 URI.
+ *
+ * The new URI is in the right state to parse a string into. All relevant fields
+ * are zeroed out. Formatting this URI will produce a valid but empty URI.
+ *
+ * Returns: A newly allocated URI. This should be freed with p11_kit_uri_free().
+ */
P11KitUri*
p11_kit_uri_new (void)
{
@@ -608,8 +791,28 @@ format_struct_version (char **string, size_t *length, int *is_first,
return format_raw_string (string, length, is_first, name, buffer);
}
+/**
+ * p11_kit_uri_format:
+ * @uri: The URI.
+ * @uri_type: The type of URI that should be produced.
+ * @string: Location to store a newly allocated string.
+ *
+ * Format a PKCS\#11 URI into a string.
+ *
+ * Fields which are zeroed out will not be included in the resulting string.
+ * Attributes which are not present will also not be included.
+ *
+ * The uri_type of URI specified limits the different parts of the resulting
+ * URI. To format a URI containing all possible information use
+ * %P11_KIT_URI_IS_ANY
+ *
+ * The resulting string should be freed with free().
+ *
+ * Returns: %P11_KIT_URI_OK if the URI was formatted successfully.
+ * %P11_KIT_URI_NO_MEMORY if memory allocation failed.
+ */
int
-p11_kit_uri_format (P11KitUri *uri, char **string)
+p11_kit_uri_format (P11KitUri *uri, P11KitUriType uri_type, char **string)
{
char *result = NULL;
size_t length = 0;
@@ -619,46 +822,56 @@ p11_kit_uri_format (P11KitUri *uri, char **string)
if (!result)
return P11_KIT_URI_NO_MEMORY;
- length = P11_KIT_URI_PREFIX_LEN;
- memcpy (result, P11_KIT_URI_PREFIX, length);
+ length = P11_KIT_URI_SCHEME_LEN;
+ memcpy (result, P11_KIT_URI_SCHEME, length);
result[length] = 0;
- if (!format_struct_string (&result, &length, &is_first, "library-description",
- uri->module.libraryDescription,
- sizeof (uri->module.libraryDescription)) ||
- !format_struct_string (&result, &length, &is_first, "library-manufacturer",
- uri->module.manufacturerID,
- sizeof (uri->module.manufacturerID)) ||
- !format_struct_string (&result, &length, &is_first, "model",
- uri->token.model,
- sizeof (uri->token.model)) ||
- !format_struct_string (&result, &length, &is_first, "manufacturer",
- uri->token.manufacturerID,
- sizeof (uri->token.manufacturerID)) ||
- !format_struct_string (&result, &length, &is_first, "serial",
- uri->token.serialNumber,
- sizeof (uri->token.serialNumber)) ||
- !format_struct_string (&result, &length, &is_first, "token",
- uri->token.label,
- sizeof (uri->token.label)) ||
- !format_struct_version (&result, &length, &is_first, "library-version",
- &uri->module.libraryVersion)) {
- free (result);
- return P11_KIT_URI_NO_MEMORY;
+ if (uri_type & P11_KIT_URI_IS_MODULE) {
+ if (!format_struct_string (&result, &length, &is_first, "library-description",
+ uri->module.libraryDescription,
+ sizeof (uri->module.libraryDescription)) ||
+ !format_struct_version (&result, &length, &is_first, "library-version",
+ &uri->module.libraryVersion) ||
+ !format_struct_string (&result, &length, &is_first, "library-manufacturer",
+ uri->module.manufacturerID,
+ sizeof (uri->module.manufacturerID))) {
+ free (result);
+ return P11_KIT_URI_NO_MEMORY;
+ }
}
- if (!format_attribute_string (&result, &length, &is_first, "id",
- &uri->attrs[ID_IDX]) ||
- !format_attribute_string (&result, &length, &is_first, "object",
- &uri->attrs[LABEL_IDX])) {
- free (result);
- return P11_KIT_URI_NO_MEMORY;
+ if (uri_type & P11_KIT_URI_IS_TOKEN) {
+ if (!format_struct_string (&result, &length, &is_first, "model",
+ uri->token.model,
+ sizeof (uri->token.model)) ||
+ !format_struct_string (&result, &length, &is_first, "manufacturer",
+ uri->token.manufacturerID,
+ sizeof (uri->token.manufacturerID)) ||
+ !format_struct_string (&result, &length, &is_first, "serial",
+ uri->token.serialNumber,
+ sizeof (uri->token.serialNumber)) ||
+ !format_struct_string (&result, &length, &is_first, "token",
+ uri->token.label,
+ sizeof (uri->token.label))) {
+ free (result);
+ return P11_KIT_URI_NO_MEMORY;
+ }
}
- if (!format_attribute_class (&result, &length, &is_first, "objecttype",
- &uri->attrs[CLASS_IDX])) {
- free (result);
- return P11_KIT_URI_NO_MEMORY;
+ if (uri_type & P11_KIT_URI_IS_OBJECT) {
+ if (!format_attribute_string (&result, &length, &is_first, "id",
+ &uri->attrs[ID_IDX]) ||
+ !format_attribute_string (&result, &length, &is_first, "object",
+ &uri->attrs[LABEL_IDX])) {
+ free (result);
+ return P11_KIT_URI_NO_MEMORY;
+ }
+
+ if (!format_attribute_class (&result, &length, &is_first, "objecttype",
+ &uri->attrs[CLASS_IDX])) {
+ free (result);
+ return P11_KIT_URI_NO_MEMORY;
+ }
}
*string = result;
@@ -866,8 +1079,33 @@ parse_module_info (const char *name, const char *start, const char *end,
return parse_struct_info (where, length, start, end, uri);
}
+/**
+ * p11_kit_uri_parse:
+ * @string: The string to parse
+ * @uri_type: The type of URI that is expected
+ * @uri: The blank URI to parse the values into
+ *
+ * Parse a PKCS\#11 URI string.
+ *
+ * PKCS\#11 URIs can represent tokens, objects or modules. The uri_type argument
+ * allows the caller to specify what type of URI is expected and the sorts of
+ * objects the URI should match. %P11_KIT_URI_IS_ANY can be used to parse a URI
+ * for any context. It's then up to the caller to make sense of the way that
+ * it is used.
+ *
+ * If the PKCS\#11 URI contains unrecognized URI parts or parts not applicable
+ * to the specified context, then the unrecognized flag will be set. This will
+ * prevent the URI from matching using the various match functions.
+ *
+ * Returns: %P11_KIT_URI_OK if the URI was parsed successfully.
+ * %P11_KIT_URI_BAD_SCHEME if this was not a PKCS\#11 URI.
+ * %P11_KIT_URI_BAD_SYNTAX if the URI syntax was bad.
+ * %P11_KIT_URI_NO_MEMORY if memory allocation failed.
+ * %P11_KIT_URI_BAD_VERSION if a version number was bad.
+ * %P11_KIT_URI_BAD_ENCODING if the URI encoding was invalid.
+ */
int
-p11_kit_uri_parse (const char *string, P11KitUriContext context,
+p11_kit_uri_parse (const char *string, P11KitUriType uri_type,
P11KitUri *uri)
{
const char *spos, *epos;
@@ -878,10 +1116,10 @@ p11_kit_uri_parse (const char *string, P11KitUriContext context,
assert (string);
assert (uri);
- if (strncmp (string, P11_KIT_URI_PREFIX, P11_KIT_URI_PREFIX_LEN) != 0)
- return P11_KIT_URI_BAD_PREFIX;
+ if (strncmp (string, P11_KIT_URI_SCHEME, P11_KIT_URI_SCHEME_LEN) != 0)
+ return P11_KIT_URI_BAD_SCHEME;
- string += P11_KIT_URI_PREFIX_LEN;
+ string += P11_KIT_URI_SCHEME_LEN;
/* Clear everything out */
memset (&uri->module, 0, sizeof (uri->module));
@@ -913,13 +1151,13 @@ p11_kit_uri_parse (const char *string, P11KitUriContext context,
epos++;
ret = 0;
- if (context & P11_KIT_URI_PARSE_OBJECT)
+ if (uri_type & P11_KIT_URI_IS_OBJECT)
ret = parse_string_attribute (key, epos, spos, uri);
- if (ret == 0 && context & P11_KIT_URI_PARSE_OBJECT)
+ if (ret == 0 && uri_type & P11_KIT_URI_IS_OBJECT)
ret = parse_class_attribute (key, epos, spos, uri);
- if (ret == 0 && context & P11_KIT_URI_PARSE_TOKEN)
+ if (ret == 0 && uri_type & P11_KIT_URI_IS_TOKEN)
ret = parse_token_info (key, epos, spos, uri);
- if (ret == 0 && context & P11_KIT_URI_PARSE_MODULE)
+ if (ret == 0 && uri_type & P11_KIT_URI_IS_MODULE)
ret = parse_module_info (key, epos, spos, uri);
free (key);
@@ -936,6 +1174,12 @@ p11_kit_uri_parse (const char *string, P11KitUriContext context,
return P11_KIT_URI_OK;
}
+/**
+ * p11_kit_uri_free:
+ * @uri: The URI
+ *
+ * Free a PKCS\#11 URI.
+ */
void
p11_kit_uri_free (P11KitUri *uri)
{
diff --git a/module/p11-kit-uri.h b/p11-kit/p11-kit-uri.h
index 209f3d6..a3e52ed 100644
--- a/module/p11-kit-uri.h
+++ b/p11-kit/p11-kit-uri.h
@@ -37,25 +37,25 @@
#ifndef __P11_KIT_URI_H__
#define __P11_KIT_URI_H__
-#define P11_KIT_URI_PREFIX "pkcs11:"
-#define P11_KIT_URI_PREFIX_LEN 7
+#define P11_KIT_URI_SCHEME "pkcs11:"
+#define P11_KIT_URI_SCHEME_LEN 7
typedef enum {
P11_KIT_URI_OK = 0,
P11_KIT_URI_NO_MEMORY = -1,
- P11_KIT_URI_BAD_PREFIX = -2,
+ P11_KIT_URI_BAD_SCHEME = -2,
P11_KIT_URI_BAD_ENCODING = -3,
P11_KIT_URI_BAD_SYNTAX = -4,
P11_KIT_URI_BAD_VERSION = -5,
P11_KIT_URI_NOT_FOUND = -6,
-} P11KitUriParseStatus;
+} P11KitUriResult;
typedef enum {
- P11_KIT_URI_PARSE_MODULE = (1 << 1),
- P11_KIT_URI_PARSE_TOKEN = (1 << 2) | P11_KIT_URI_PARSE_MODULE,
- P11_KIT_URI_PARSE_OBJECT = (1 << 3) | P11_KIT_URI_PARSE_TOKEN,
- P11_KIT_URI_PARSE_ANY = 0xFFFFFFFF,
-} P11KitUriContext;
+ P11_KIT_URI_IS_MODULE = (1 << 1),
+ P11_KIT_URI_IS_TOKEN = (1 << 2) | P11_KIT_URI_IS_MODULE,
+ P11_KIT_URI_IS_OBJECT = (1 << 3) | P11_KIT_URI_IS_TOKEN,
+ P11_KIT_URI_IS_ANY = 0x0000FFFF,
+} P11KitUriType;
typedef struct _P11KitUri P11KitUri;
@@ -73,13 +73,13 @@ CK_ATTRIBUTE_TYPE* p11_kit_uri_get_attribute_types (P11KitUri *uri,
int *n_types);
CK_ATTRIBUTE_PTR p11_kit_uri_get_attribute (P11KitUri *uri,
- CK_ATTRIBUTE_TYPE type);
+ CK_ATTRIBUTE_TYPE attr_type);
int p11_kit_uri_set_attribute (P11KitUri *uri,
CK_ATTRIBUTE_PTR attr);
int p11_kit_uri_clear_attribute (P11KitUri *uri,
- CK_ATTRIBUTE_TYPE type);
+ CK_ATTRIBUTE_TYPE attr_type);
int p11_kit_uri_match_attributes (P11KitUri *uri,
CK_ATTRIBUTE_PTR attrs,
@@ -93,10 +93,11 @@ int p11_kit_uri_any_unrecognized (P11KitUri *uri);
P11KitUri* p11_kit_uri_new (void);
int p11_kit_uri_format (P11KitUri *uri,
+ P11KitUriType uri_type,
char **string);
int p11_kit_uri_parse (const char *string,
- P11KitUriContext context,
+ P11KitUriType uri_type,
P11KitUri *uri);
void p11_kit_uri_free (P11KitUri *uri);
diff --git a/module/p11-kit.h b/p11-kit/p11-kit.h
index b035f56..b035f56 100644
--- a/module/p11-kit.h
+++ b/p11-kit/p11-kit.h
diff --git a/p11-kit/p11-kit.pc b/p11-kit/p11-kit.pc
new file mode 100644
index 0000000..ce763cc
--- /dev/null
+++ b/p11-kit/p11-kit.pc
@@ -0,0 +1,17 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+datarootdir=${prefix}/share
+datadir=${datarootdir}
+sysconfdir=/etc
+p11_system_conf=/etc/pkcs11/pkcs11.conf
+p11_system_modules=/etc/pkcs11/modules
+p11_user_conf=~/.pkcs11/pkcs11.conf
+p11_user_modules=~/.pkcs11/modules
+
+Name: p11-kit
+Description: Library and proxy module for properly loading and sharing PKCS#11 modules.
+Version: 0.1
+Libs: -L${libdir} -lp11-kit
+Cflags: -I${includedir}/p11-kit
diff --git a/module/p11-kit.pc.in b/p11-kit/p11-kit.pc.in
index d80167e..d80167e 100644
--- a/module/p11-kit.pc.in
+++ b/p11-kit/p11-kit.pc.in
diff --git a/module/pkcs11.h b/p11-kit/pkcs11.h
index b8be30f..b8be30f 100644
--- a/module/pkcs11.h
+++ b/p11-kit/pkcs11.h
diff --git a/module/util.c b/p11-kit/util.c
index 516e70b..516e70b 100644
--- a/module/util.c
+++ b/p11-kit/util.c
diff --git a/module/util.h b/p11-kit/util.h
index 73f06ec..73f06ec 100644
--- a/module/util.h
+++ b/p11-kit/util.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 92dba16..3719a64 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
INCLUDES = \
-I$(top_srcdir) \
- -I$(top_srcdir)/module \
+ -I$(top_srcdir)/p11-kit \
-Icutest \
-DSRCDIR=\"$(srcdir)\"
@@ -11,13 +11,13 @@ noinst_PROGRAMS = \
uri-test
hash_test_LDADD = \
- $(top_builddir)/module/libp11-kit-testable.la
+ $(top_builddir)/p11-kit/libp11-kit-testable.la
conf_test_LDADD = \
- $(top_builddir)/module/libp11-kit-testable.la
+ $(top_builddir)/p11-kit/libp11-kit-testable.la
uri_test_LDADD = \
- $(top_builddir)/module/libp11-kit-testable.la
+ $(top_builddir)/p11-kit/libp11-kit-testable.la
check-am:
./hash-test
diff --git a/tests/uri-test.c b/tests/uri-test.c
index 40e301a..631d39f 100644
--- a/tests/uri-test.c
+++ b/tests/uri-test.c
@@ -79,7 +79,7 @@ test_uri_parse (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, is_module_empty (uri));
@@ -98,8 +98,8 @@ test_uri_parse_bad_scheme (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("http:\\example.com\test", P11_KIT_URI_PARSE_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_PREFIX, ret);
+ ret = p11_kit_uri_parse ("http:\\example.com\test", P11_KIT_URI_IS_ANY, uri);
+ CuAssertIntEquals (tc, P11_KIT_URI_BAD_SCHEME, ret);
p11_kit_uri_free (uri);
}
@@ -114,7 +114,7 @@ test_uri_parse_with_label (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, is_module_empty (uri));
@@ -138,7 +138,7 @@ test_uri_parse_with_label_and_klass (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label;objecttype=cert", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label;objecttype=cert", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
@@ -164,7 +164,7 @@ test_uri_parse_with_id (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:id=%54%45%53%54%00", P11_KIT_URI_PARSE_OBJECT, uri);
+ ret = p11_kit_uri_parse ("pkcs11:id=%54%45%53%54%00", P11_KIT_URI_IS_OBJECT, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
/* Note that there's a NULL in the attribute (end) */
@@ -186,7 +186,7 @@ test_uri_parse_with_bad_string_encoding (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:object=Test%", P11_KIT_URI_PARSE_OBJECT, uri);
+ ret = p11_kit_uri_parse ("pkcs11:object=Test%", P11_KIT_URI_IS_OBJECT, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
@@ -201,7 +201,7 @@ test_uri_parse_with_bad_hex_encoding (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:object=T%xxest", P11_KIT_URI_PARSE_OBJECT, uri);
+ ret = p11_kit_uri_parse ("pkcs11:object=T%xxest", P11_KIT_URI_IS_OBJECT, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
@@ -232,7 +232,7 @@ test_uri_parse_with_token (CuTest *tc)
CuAssertPtrNotNull (tc, uri);
ret = p11_kit_uri_parse ("pkcs11:token=Token%20Label;serial=3333;model=Deluxe;manufacturer=Me",
- P11_KIT_URI_PARSE_TOKEN, uri);
+ P11_KIT_URI_IS_TOKEN, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
token = p11_kit_uri_get_token_info (uri);
@@ -253,7 +253,7 @@ test_uri_parse_with_token_bad_encoding (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:token=Token%", P11_KIT_URI_PARSE_TOKEN, uri);
+ ret = p11_kit_uri_parse ("pkcs11:token=Token%", P11_KIT_URI_IS_TOKEN, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
@@ -268,7 +268,7 @@ test_uri_parse_with_bad_syntax (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:token", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:token", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_SYNTAX, ret);
p11_kit_uri_free (uri);
@@ -285,7 +285,7 @@ test_uri_parse_with_library (CuTest *tc)
CuAssertPtrNotNull (tc, uri);
ret = p11_kit_uri_parse ("pkcs11:library-description=The%20Library;library-manufacturer=Me",
- P11_KIT_URI_PARSE_MODULE, uri);
+ P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
@@ -305,7 +305,7 @@ test_uri_parse_with_library_bad_encoding (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:library-description=Library%", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-description=Library%", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
@@ -321,7 +321,7 @@ test_uri_build_empty (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertStrEquals (tc, "pkcs11:", string);
free (string);
@@ -355,14 +355,14 @@ test_uri_build_with_token_info (CuTest *tc)
set_space_string (token->manufacturerID, sizeof (token->manufacturerID), "Me");
set_space_string (token->model, sizeof (token->model), "Deluxe");
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertPtrNotNull (tc, string);
check = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, check);
- ret = p11_kit_uri_parse (string, P11_KIT_URI_PARSE_TOKEN, check);
+ ret = p11_kit_uri_parse (string, P11_KIT_URI_IS_TOKEN, check);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
p11_kit_uri_match_token_info (check, p11_kit_uri_get_token_info (uri));
@@ -392,7 +392,7 @@ test_uri_build_with_token_null_info (CuTest *tc)
token = p11_kit_uri_get_token_info (uri);
set_space_string (token->label, sizeof (token->label), "The Label");
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "token=The%20Label") != NULL);
@@ -417,7 +417,7 @@ test_uri_build_with_token_empty_info (CuTest *tc)
set_space_string (token->label, sizeof (token->label), "");
set_space_string (token->serialNumber, sizeof (token->serialNumber), "");
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "token=") != NULL);
@@ -457,13 +457,13 @@ test_uri_build_with_attributes (CuTest *tc)
at.ulValueLen = sizeof (klass);
ret = p11_kit_uri_set_attribute (uri, &at);
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
check = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, check);
- ret = p11_kit_uri_parse (string, P11_KIT_URI_PARSE_ANY, check);
+ ret = p11_kit_uri_parse (string, P11_KIT_URI_IS_ANY, check);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (check, CKA_LABEL);
@@ -501,7 +501,7 @@ test_uri_parse_private_key (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:objecttype=private", P11_KIT_URI_PARSE_OBJECT, uri);
+ ret = p11_kit_uri_parse ("pkcs11:objecttype=private", P11_KIT_URI_IS_OBJECT, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
@@ -522,7 +522,7 @@ test_uri_parse_secret_key (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:objecttype=secretkey", P11_KIT_URI_PARSE_OBJECT, uri);
+ ret = p11_kit_uri_parse ("pkcs11:objecttype=secretkey", P11_KIT_URI_IS_OBJECT, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
@@ -543,33 +543,33 @@ test_uri_parse_library_version (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:library-version=2.101", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=2.101", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
CuAssertIntEquals (tc, 2, info->libraryVersion.major);
CuAssertIntEquals (tc, 101, info->libraryVersion.minor);
- ret = p11_kit_uri_parse ("pkcs11:library-version=23", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=23", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
CuAssertIntEquals (tc, 23, info->libraryVersion.major);
CuAssertIntEquals (tc, 0, info->libraryVersion.minor);
- ret = p11_kit_uri_parse ("pkcs11:library-version=23.", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=23.", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
- ret = p11_kit_uri_parse ("pkcs11:library-version=a.a", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=a.a", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
- ret = p11_kit_uri_parse ("pkcs11:library-version=.23", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=.23", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
- ret = p11_kit_uri_parse ("pkcs11:library-version=1000", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=1000", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
- ret = p11_kit_uri_parse ("pkcs11:library-version=2.1000", P11_KIT_URI_PARSE_MODULE, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-version=2.1000", P11_KIT_URI_IS_MODULE, uri);
CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
p11_kit_uri_free (uri);
@@ -585,7 +585,7 @@ test_uri_parse_parse_unknown_objecttype (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:objecttype=unknown", P11_KIT_URI_PARSE_OBJECT, uri);
+ ret = p11_kit_uri_parse ("pkcs11:objecttype=unknown", P11_KIT_URI_IS_OBJECT, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
@@ -603,7 +603,7 @@ test_uri_parse_unrecognized (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:x-blah=some-value", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:x-blah=some-value", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
ret = p11_kit_uri_any_unrecognized (uri);
@@ -622,7 +622,7 @@ test_uri_parse_too_long_is_unrecognized (CuTest *tc)
CuAssertPtrNotNull (tc, uri);
ret = p11_kit_uri_parse ("pkcs11:model=a-value-that-is-too-long-for-the-field-that-it-goes-with",
- P11_KIT_URI_PARSE_ANY, uri);
+ P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
ret = p11_kit_uri_any_unrecognized (uri);
@@ -651,7 +651,7 @@ test_uri_build_objecttype_cert (CuTest *tc)
attr.ulValueLen = sizeof (klass);
p11_kit_uri_set_attribute (uri, &attr);
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "objecttype=cert") != NULL);
@@ -677,7 +677,7 @@ test_uri_build_objecttype_private (CuTest *tc)
attr.ulValueLen = sizeof (klass);
p11_kit_uri_set_attribute (uri, &attr);
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "objecttype=private") != NULL);
@@ -703,7 +703,7 @@ test_uri_build_objecttype_public (CuTest *tc)
attr.ulValueLen = sizeof (klass);
p11_kit_uri_set_attribute (uri, &attr);
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "objecttype=public") != NULL);
@@ -729,7 +729,7 @@ test_uri_build_objecttype_secret (CuTest *tc)
attr.ulValueLen = sizeof (klass);
p11_kit_uri_set_attribute (uri, &attr);
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "objecttype=secretkey") != NULL);
@@ -751,7 +751,7 @@ test_uri_build_with_library (CuTest *tc)
info = p11_kit_uri_get_module_info (uri);
set_space_string (info->libraryDescription, sizeof (info->libraryDescription), "The Description");
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "library-description=The%20Description") != NULL);
@@ -774,7 +774,7 @@ test_uri_build_library_version (CuTest *tc)
info->libraryVersion.major = 2;
info->libraryVersion.minor = 10;
- ret = p11_kit_uri_format (uri, &string);
+ ret = p11_kit_uri_format (uri, P11_KIT_URI_IS_ANY, &string);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
CuAssertTrue (tc, strstr (string, "library-version=2.10") != NULL);
@@ -817,7 +817,7 @@ test_uri_match_token (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:model=Giselle", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:model=Giselle", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
set_space_string (token.label, sizeof (token.label), "A label");
@@ -854,7 +854,7 @@ test_uri_match_module (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:library-description=Quiet", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:library-description=Quiet", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
set_space_string (info.libraryDescription, sizeof (info.libraryDescription), "Quiet");
@@ -909,7 +909,7 @@ test_uri_match_attributes (CuTest *tc)
uri = p11_kit_uri_new ();
CuAssertPtrNotNull (tc, uri);
- ret = p11_kit_uri_parse ("pkcs11:object=Fancy;id=Blah;objecttype=data", P11_KIT_URI_PARSE_ANY, uri);
+ ret = p11_kit_uri_parse ("pkcs11:object=Fancy;id=Blah;objecttype=data", P11_KIT_URI_IS_ANY, uri);
CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
ret = p11_kit_uri_match_attributes (uri, attrs, 4);