summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am1
-rw-r--r--common/Makefile.am31
-rw-r--r--common/tests/Makefile.am32
-rw-r--r--common/tests/test-lexer.c35
-rw-r--r--common/tool.c (renamed from tools/tool.c)76
-rw-r--r--common/tool.h (renamed from tools/tool.h)18
-rw-r--r--configure.ac2
-rw-r--r--doc/manual/Makefile.am1
-rw-r--r--gtk-doc.make2
-rw-r--r--p11-kit/Makefile.am20
-rw-r--r--p11-kit/list.c (renamed from tools/list.c)15
-rw-r--r--p11-kit/p11-kit.c102
-rw-r--r--tools/Makefile.am53
-rw-r--r--tools/tests/Makefile.am84
-rw-r--r--tools/tests/files/cacert3.derbin1885 -> 0 bytes
-rw-r--r--tools/tests/files/cacert3.pem42
-rw-r--r--tools/tests/test-tools.c216
-rw-r--r--tools/tests/test-tools.h260
-rw-r--r--trust/Makefile.am56
-rw-r--r--trust/asn1.c (renamed from common/asn1.c)0
-rw-r--r--trust/asn1.h (renamed from common/asn1.h)0
-rw-r--r--trust/base64.c (renamed from common/base64.c)0
-rw-r--r--trust/base64.h (renamed from common/base64.h)0
-rw-r--r--trust/basic.asn (renamed from common/basic.asn)0
-rw-r--r--trust/basic.asn.h (renamed from common/basic.asn.h)0
-rw-r--r--trust/extract-cer.c (renamed from tools/extract-x509.c)0
-rw-r--r--trust/extract-info.c (renamed from tools/extract-info.c)0
-rw-r--r--trust/extract-jks.c (renamed from tools/extract-jks.c)0
-rw-r--r--trust/extract-openssl.c (renamed from tools/extract-openssl.c)0
-rw-r--r--trust/extract-pem.c (renamed from tools/extract-pem.c)0
-rw-r--r--trust/extract.c (renamed from tools/extract.c)4
-rw-r--r--trust/extract.h (renamed from tools/extract.h)3
-rw-r--r--trust/oid.c (renamed from common/oid.c)0
-rw-r--r--trust/oid.h (renamed from common/oid.h)0
-rw-r--r--trust/openssl.asn (renamed from common/openssl.asn)0
-rw-r--r--trust/openssl.asn.h (renamed from common/openssl.asn.h)0
-rw-r--r--trust/pem.c (renamed from common/pem.c)0
-rw-r--r--trust/pem.h (renamed from common/pem.h)0
-rw-r--r--trust/pkix.asn (renamed from common/pkix.asn)0
-rw-r--r--trust/pkix.asn.h (renamed from common/pkix.asn.h)0
-rw-r--r--trust/save.c (renamed from tools/save.c)0
-rw-r--r--trust/save.h (renamed from tools/save.h)0
-rw-r--r--trust/tests/Makefile.am70
-rw-r--r--trust/tests/files/cacert3-distrust-all.pem (renamed from tools/tests/files/cacert3-distrust-all.pem)0
-rw-r--r--trust/tests/files/cacert3-distrusted-all.pem (renamed from tools/tests/files/cacert3-distrusted-all.pem)0
-rw-r--r--trust/tests/files/cacert3-not-trusted.pem (renamed from tools/tests/files/cacert3-not-trusted.pem)0
-rw-r--r--trust/tests/files/cacert3-trusted-alias.pem (renamed from tools/tests/files/cacert3-trusted-alias.pem)0
-rw-r--r--trust/tests/files/cacert3-trusted-keyid.pem (renamed from tools/tests/files/cacert3-trusted-keyid.pem)0
-rw-r--r--trust/tests/files/cacert3-trusted-multiple.pem (renamed from tools/tests/files/cacert3-trusted-multiple.pem)0
-rw-r--r--trust/tests/files/cacert3-trusted-server-alias.pem (renamed from tools/tests/files/cacert3-trusted-server-alias.pem)0
-rw-r--r--trust/tests/files/cacert3-twice.pem (renamed from tools/tests/files/cacert3-twice.pem)0
-rw-r--r--trust/tests/files/empty-file (renamed from tools/tests/files/empty-file)0
-rw-r--r--trust/tests/files/simple-string (renamed from tools/tests/files/simple-string)0
-rw-r--r--trust/tests/frob-cert.c (renamed from common/tests/frob-cert.c)0
-rw-r--r--trust/tests/frob-eku.c (renamed from common/tests/frob-eku.c)0
-rw-r--r--trust/tests/frob-ku.c (renamed from common/tests/frob-ku.c)0
-rw-r--r--trust/tests/frob-oid.c (renamed from common/tests/frob-oid.c)0
-rw-r--r--trust/tests/test-asn1.c (renamed from common/tests/test-asn1.c)0
-rw-r--r--trust/tests/test-base64.c (renamed from common/tests/test-base64.c)0
-rw-r--r--trust/tests/test-bundle.c (renamed from tools/tests/test-pem.c)5
-rw-r--r--trust/tests/test-cer.c (renamed from tools/tests/test-x509.c)5
-rw-r--r--trust/tests/test-extract.c (renamed from tools/tests/test-extract.c)5
-rw-r--r--trust/tests/test-oid.c (renamed from common/tests/test-oid.c)0
-rw-r--r--trust/tests/test-openssl.c (renamed from tools/tests/test-openssl.c)5
-rw-r--r--trust/tests/test-pem.c (renamed from common/tests/test-pem.c)0
-rw-r--r--trust/tests/test-save.c (renamed from tools/tests/test-save.c)5
-rw-r--r--trust/tests/test-trust.c176
-rw-r--r--trust/tests/test-trust.h74
-rw-r--r--trust/tests/test-utf8.c (renamed from common/tests/test-utf8.c)0
-rw-r--r--trust/tests/test-x509.c (renamed from common/tests/test-x509.c)0
-rw-r--r--trust/trust.c64
-rw-r--r--trust/utf8.c (renamed from common/utf8.c)0
-rw-r--r--trust/utf8.h (renamed from common/utf8.h)0
-rw-r--r--trust/x509.c (renamed from common/x509.c)0
-rw-r--r--trust/x509.h (renamed from common/x509.h)0
76 files changed, 638 insertions, 826 deletions
diff --git a/.gitignore b/.gitignore
index e5b5c8e..a7dfe11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,6 +85,7 @@ x86_64-w64-mingw32
/doc/manual/*.5
/doc/manual/*.8
+/p11-kit/p11-kit
/p11-kit/p11-kit.pc
/p11-kit/p11-kit-1.pc
/p11-kit/pkcs11.conf.example
@@ -108,6 +109,7 @@ x86_64-w64-mingw32
/tools/p11-kit
+/trust/trust
/trust/p11-kit-extract-trust
/p11-kit-?.?
diff --git a/Makefile.am b/Makefile.am
index 13de2bb..03fc5dc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,6 @@ SUBDIRS = \
common \
p11-kit \
$(TRUST_DIR) \
- tools \
doc \
po
diff --git a/common/Makefile.am b/common/Makefile.am
index b3e4eaf..2df3915 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -13,6 +13,7 @@ noinst_LTLIBRARIES = \
libp11-common.la \
libp11-library.la \
libp11-test.la \
+ libp11-tool.la \
$(NULL)
libp11_common_la_SOURCES = \
@@ -41,30 +42,6 @@ libp11_test_la_SOURCES = \
test.c test.h \
$(NULL)
-if WITH_ASN1
-
-noinst_LTLIBRARIES += \
- libp11-data.la \
- $(NULL)
-
-libp11_data_la_SOURCES = \
- asn1.c asn1.h \
- basic.asn basic.asn.h \
- base64.c base64.h \
- oid.c oid.h \
- openssl.asn openssl.asn.h \
- pem.c pem.h \
- pkix.asn pkix.asn.h \
- utf8.c utf8.h \
- x509.c x509.h \
- $(NULL)
-
-libp11_data_la_CFLAGS = \
- $(LIBTASN1_CFLAGS)
-
-asn:
- asn1Parser -o pkix.asn.h pkix.asn
- asn1Parser -o openssl.asn.h openssl.asn
- asn1Parser -o basic.asn.h basic.asn
-
-endif # WITH_ASN1
+libp11_tool_la_SOURCES = \
+ tool.c tool.h \
+ $(NULL) \ No newline at end of file
diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am
index 942bc12..637399b 100644
--- a/common/tests/Makefile.am
+++ b/common/tests/Makefile.am
@@ -22,42 +22,12 @@ CHECK_PROGS = \
test-buffer \
test-url \
test-path \
+ test-lexer \
$(NULL)
noinst_PROGRAMS = \
$(CHECK_PROGS)
-if WITH_ASN1
-
-LDADD += \
- $(top_builddir)/common/libp11-data.la \
- $(LIBTASN1_LIBS) \
- $(NULL)
-
-AM_CPPFLAGS += \
- $(LIBTASN1_CFLAGS) \
- $(NULL)
-
-CHECK_PROGS += \
- test-asn1 \
- test-base64 \
- test-lexer \
- test-pem \
- test-oid \
- test-utf8 \
- test-x509 \
- $(NULL)
-
-noinst_PROGRAMS += \
- frob-cert \
- frob-ku \
- frob-eku \
- frob-cert \
- frob-oid \
- $(NULL)
-
-endif # WITH_ASN1
-
TESTS = $(CHECK_PROGS)
LDADD += \
diff --git a/common/tests/test-lexer.c b/common/tests/test-lexer.c
index ff18a89..7d18e87 100644
--- a/common/tests/test-lexer.c
+++ b/common/tests/test-lexer.c
@@ -43,7 +43,6 @@
#include "debug.h"
#include "lexer.h"
#include "message.h"
-#include "pem.h"
typedef struct {
int tok_type;
@@ -52,16 +51,6 @@ typedef struct {
} expected_tok;
static void
-on_pem_get_type (const char *type,
- const unsigned char *contents,
- size_t length,
- void *user_data)
-{
- char **result = (char **)user_data;
- *result = strdup (type);
-}
-
-static void
check_lex_msg (const char *file,
int line,
const char *function,
@@ -69,9 +58,8 @@ check_lex_msg (const char *file,
const char *input,
bool failure)
{
- unsigned int count;
p11_lexer lexer;
- char *type;
+ size_t len;
bool failed;
int i;
@@ -99,16 +87,13 @@ check_lex_msg (const char *file,
expected[i].name, lexer.tok.field.name);
break;
case TOK_PEM:
- type = NULL;
- count = p11_pem_parse (lexer.tok.pem.begin, lexer.tok.pem.length,
- on_pem_get_type, &type);
- if (count != 1)
- p11_test_fail (file, line, function, "more than one PEM block: %d", count);
- if (strcmp (expected[i].name, type) != 0)
+ len = strlen (expected[i].name);
+ if (lexer.tok.pem.length < len ||
+ strncmp (lexer.tok.pem.begin, expected[i].name, len) != 0) {
p11_test_fail (file, line, function,
- "wrong type of PEM block: (%s != %s)",
- expected[i].name, type);
- free (type);
+ "wrong type of PEM block: %s",
+ expected[i].name);
+ }
break;
case TOK_EOF:
p11_test_fail (file, line, function, "eof should not be recieved");
@@ -144,7 +129,7 @@ test_basic (void)
const expected_tok expected[] = {
{ TOK_SECTION, "the header" },
{ TOK_FIELD, "field", "value" },
- { TOK_PEM, "BLOCK1", },
+ { TOK_PEM, "-----BEGIN BLOCK1-----\n", },
{ TOK_EOF }
};
@@ -174,7 +159,7 @@ test_corners (void)
{ TOK_FIELD, "number", "3" },
{ TOK_FIELD, "number", "4" },
{ TOK_FIELD, "not-a-comment", "# value" },
- { TOK_PEM, "BLOCK1", },
+ { TOK_PEM, "-----BEGIN BLOCK1-----\r\n", },
{ TOK_EOF }
};
@@ -190,7 +175,7 @@ test_following (void)
"field: value";
const expected_tok expected[] = {
- { TOK_PEM, "BLOCK1", },
+ { TOK_PEM, "-----BEGIN BLOCK1-----\n", },
{ TOK_FIELD, "field", "value" },
{ TOK_EOF }
};
diff --git a/tools/tool.c b/common/tool.c
index 313484a..70bb4d2 100644
--- a/tools/tool.c
+++ b/common/tool.c
@@ -39,7 +39,6 @@
#include "debug.h"
#include "message.h"
#include "path.h"
-#include "p11-kit.h"
#include <assert.h>
#include <ctype.h>
@@ -51,18 +50,6 @@
#include "tool.h"
-struct {
- const char *name;
- int (*function) (int, char*[]);
- const char *text;
-} commands[] = {
-#ifdef WITH_ASN1
- { "extract", p11_tool_extract, "Extract certificates" },
-#endif
- { "list-modules", p11_tool_list_modules, "List modules and tokens"},
- { 0, }
-};
-
static char
short_option (int opt)
{
@@ -177,43 +164,25 @@ p11_tool_getopt (int argc,
}
static void
-command_usage (void)
+command_usage (const p11_tool_command *commands)
{
+ const char *progname;
int i;
- printf ("usage: p11-kit command <args>...\n");
- printf ("\nCommon p11-kit commands are:\n");
- for (i = 0; commands[i].name != NULL; i++)
- printf (" %-15s %s\n", commands[i].name, commands[i].text);
- printf ("\nSee 'p11-kit <command> --help' for more information\n");
-}
-
-static void
-exec_external (const char *command,
- int argc,
- char *argv[])
-{
- char *filename;
- char *path;
-
- if (!asprintf (&filename, "p11-kit-%s", command) < 0)
- return_if_reached ();
-
- /* Add our libexec directory to the path */
- path = p11_path_build (PRIVATEDIR, filename, NULL);
- return_if_fail (path != NULL);
-
- argv[0] = filename;
- argv[argc] = NULL;
-
- execvp (path, argv);
+ progname = getprogname ();
+ printf ("usage: %s command <args>...\n", progname);
+ printf ("\nCommon %s commands are:\n", progname);
+ for (i = 0; commands[i].name != NULL; i++) {
+ if (strcmp (commands[i].name, P11_TOOL_FALLBACK) != 0)
+ printf (" %-15s %s\n", commands[i].name, commands[i].text);
+ }
+ printf ("\nSee '%s <command> --help' for more information\n", progname);
}
static void
verbose_arg (void)
{
putenv ("P11_KIT_DEBUG=all");
- p11_kit_be_loud ();
p11_message_loud ();
}
@@ -221,13 +190,15 @@ static void
quiet_arg (void)
{
putenv ("P11_KIT_DEBUG=");
- p11_kit_be_quiet ();
p11_message_quiet ();
}
int
-main (int argc, char *argv[])
+p11_tool_main (int argc,
+ char *argv[],
+ const p11_tool_command *commands)
{
+ const p11_tool_command *fallback = NULL;
char *command = NULL;
bool want_help = false;
bool skip;
@@ -321,12 +292,12 @@ main (int argc, char *argv[])
p11_debug_init ();
if (command == NULL) {
- /* As a special favor if someone just typed 'p11-kit', help them out */
+ /* As a special favor if someone just typed the command, help them out */
if (argc == 1) {
- command_usage ();
+ command_usage (commands);
return 2;
} else if (want_help) {
- command_usage ();
+ command_usage (commands);
return 0;
} else {
p11_message ("no command specified");
@@ -338,16 +309,23 @@ main (int argc, char *argv[])
/* Look for the command */
for (i = 0; commands[i].name != NULL; i++) {
- if (strcmp (commands[i].name, command) == 0) {
+ if (strcmp (commands[i].name, P11_TOOL_FALLBACK) == 0) {
+ fallback = commands + i;
+
+ } else if (strcmp (commands[i].name, command) == 0) {
argv[0] = command;
return (commands[i].function) (argc, argv);
}
}
/* Got here because no command matched */
- exec_external (command, argc, argv);
+ if (fallback != NULL) {
+ argv[0] = command;
+ return (fallback->function) (argc, argv);
+ }
/* At this point we have no command */
- p11_message ("'%s' is not a valid p11-kit command. See 'p11-kit --help'", command);
+ p11_message ("'%s' is not a valid command. See '%s --help'",
+ command, getprogname ());
return 2;
}
diff --git a/tools/tool.h b/common/tool.h
index e0bcf90..16785da 100644
--- a/tools/tool.h
+++ b/common/tool.h
@@ -37,12 +37,24 @@
#include <getopt.h>
+#define P11_TOOL_FALLBACK ""
+
+typedef struct {
+ const char *name;
+ int (*function) (int, char*[]);
+ const char *text;
+} p11_tool_command;
+
typedef struct {
int option;
const char *text;
const char *arg;
} p11_tool_desc;
+int p11_tool_main (int argc,
+ char *argv[],
+ const p11_tool_command *commands);
+
int p11_tool_getopt (int argc,
char *argv[],
const struct option *longopts);
@@ -50,10 +62,4 @@ int p11_tool_getopt (int argc,
void p11_tool_usage (const p11_tool_desc *usages,
const struct option *longopts);
-int p11_tool_list_modules (int argc,
- char *argv[]);
-
-int p11_tool_extract (int argc,
- char **argv);
-
#endif /* P11_TOOL_H_ */
diff --git a/configure.ac b/configure.ac
index 8d88540..886d1eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -458,8 +458,6 @@ AC_CONFIG_FILES([Makefile
p11-kit/tests/Makefile
p11-kit/p11-kit-1.pc
p11-kit/pkcs11.conf.example
- tools/Makefile
- tools/tests/Makefile
trust/Makefile
trust/p11-kit-extract-trust
trust/tests/Makefile
diff --git a/doc/manual/Makefile.am b/doc/manual/Makefile.am
index e306fb1..ea6166e 100644
--- a/doc/manual/Makefile.am
+++ b/doc/manual/Makefile.am
@@ -90,7 +90,6 @@ expand_content_files=
# 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=
# Hacks around gtk-doc brokenness for out of tree builds
diff --git a/gtk-doc.make b/gtk-doc.make
index 824d8d6..4709268 100644
--- a/gtk-doc.make
+++ b/gtk-doc.make
@@ -243,7 +243,7 @@ if ENABLE_GTK_DOC
dist-check-gtkdoc:
else
dist-check-gtkdoc:
- @echo "*** gtk-doc must be installed and enabled in order to make dist"
+ @echo "*** gtk-doc must be installed and --enable-doc in order to make dist"
@false
endif
diff --git a/p11-kit/Makefile.am b/p11-kit/Makefile.am
index 2e08e84..a8f7da7 100644
--- a/p11-kit/Makefile.am
+++ b/p11-kit/Makefile.am
@@ -8,6 +8,8 @@ COMMON = $(top_srcdir)/common
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(COMMON) \
+ -DSRCDIR=\"$(srcdir)\" \
+ -DPRIVATEDIR=\"$(privatedir)\" \
-DP11_KIT_FUTURE_UNSTABLE_API \
$(NULL)
@@ -113,3 +115,21 @@ EXTRA_DIST = \
install-exec-hook:
$(LN_S) -f `readlink $(DESTDIR)$(libdir)/libp11-kit.so` $(DESTDIR)$(libdir)/p11-kit-proxy.so
$(MKDIR_P) $(DESTDIR)$(p11_package_config_modules)
+
+bin_PROGRAMS = \
+ p11-kit
+
+p11_kit_SOURCES = \
+ list.c \
+ p11-kit.c \
+ $(NULL)
+
+p11_kit_CFLAGS = \
+ $(NULL)
+
+p11_kit_LDADD = \
+ $(top_builddir)/p11-kit/libp11-kit.la \
+ $(top_builddir)/common/libp11-tool.la \
+ $(top_builddir)/common/libp11-common.la \
+ $(LTLIBINTL) \
+ $(NULL)
diff --git a/tools/list.c b/p11-kit/list.c
index fe028ae..f46fd7e 100644
--- a/tools/list.c
+++ b/p11-kit/list.c
@@ -49,7 +49,9 @@
#include "tool.h"
#include "uri.h"
-typedef int (*operation) (int argc, char *argv[]);
+int p11_kit_list_modules (int argc,
+ char *argv[]);
+
bool verbose = false;
static const char HEXC_LOWER[] = "0123456789abcdef";
@@ -227,8 +229,8 @@ print_modules (void)
}
int
-p11_tool_list_modules (int argc,
- char *argv[])
+p11_kit_list_modules (int argc,
+ char *argv[])
{
int opt;
@@ -257,9 +259,14 @@ p11_tool_list_modules (int argc,
while ((opt = p11_tool_getopt (argc, argv, options)) != -1) {
switch (opt) {
- /* Ignore these options, already handled */
case opt_verbose:
+ p11_kit_be_loud ();
+ break;
+
case opt_quiet:
+ p11_kit_be_quiet ();
+ break;
+
case opt_list:
break;
diff --git a/p11-kit/p11-kit.c b/p11-kit/p11-kit.c
new file mode 100644
index 0000000..ecee1ff
--- /dev/null
+++ b/p11-kit/p11-kit.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011, Collabora Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ * * The names of contributors to this software may not be
+ * used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Author: Stef Walter <stefw@collabora.co.uk>
+ */
+
+#include "config.h"
+
+#include "compat.h"
+#include "debug.h"
+#include "message.h"
+#include "path.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "tool.h"
+
+int p11_kit_list_modules (int argc,
+ char *argv[]);
+
+int p11_kit_extract (int argc,
+ char *argv[]);
+
+int p11_kit_external (int argc,
+ char *argv[]);
+
+static const p11_tool_command commands[] = {
+ { "list-modules", p11_kit_list_modules, "List modules and tokens" },
+ { "extract", p11_kit_extract, "Extract certificates and trust" },
+ { P11_TOOL_FALLBACK, p11_kit_external, "List modules and tokens" },
+ { 0, }
+};
+
+int
+p11_kit_external (int argc,
+ char *argv[])
+{
+ char *filename;
+ char *path;
+
+ if (!asprintf (&filename, "p11-kit-%s", argv[0]) < 0)
+ return_val_if_reached (1);
+
+ /* Add our libexec directory to the path */
+ path = p11_path_build (PRIVATEDIR, filename, NULL);
+ return_val_if_fail (path != NULL, 1);
+
+ argv[argc] = NULL;
+ execvp (path, argv);
+
+ /* At this point we have no command */
+ p11_message ("'%s' is not a valid command. See 'p11-kit --help'", argv[0]);
+ return 2;
+}
+
+int
+p11_kit_extract (int argc,
+ char *argv[])
+{
+ return p11_kit_external (argc, argv);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ return p11_tool_main (argc, argv, commands);
+}
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index deda642..0000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,53 +0,0 @@
-
-include $(top_srcdir)/build/Makefile.decl
-
-SUBDIRS = . tests
-
-COMMON = $(top_srcdir)/common
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/common \
- -I$(top_srcdir)/p11-kit \
- -DSRCDIR=\"$(srcdir)\" \
- -DPRIVATEDIR=\"$(privatedir)\" \
- -DP11_KIT_FUTURE_UNSTABLE_API \
- $(NULL)
-
-bin_PROGRAMS = \
- p11-kit
-
-p11_kit_SOURCES = \
- list.c \
- tool.c tool.h \
- $(NULL)
-
-p11_kit_CFLAGS = \
- $(NULL)
-
-p11_kit_LDADD = \
- $(top_builddir)/p11-kit/libp11-kit.la \
- $(top_builddir)/common/libp11-common.la \
- $(LTLIBINTL) \
- $(NULL)
-
-if WITH_ASN1
-
-p11_kit_LDADD += \
- $(top_builddir)/common/libp11-data.la \
- $(LIBTASN1_LIBS)
-
-p11_kit_CFLAGS += \
- $(LIBTASN1_CFLAGS)
-
-p11_kit_SOURCES += \
- extract.c extract.h \
- extract-info.c \
- extract-jks.c \
- extract-openssl.c \
- extract-pem.c \
- extract-x509.c \
- save.c save.h \
- $(NULL)
-
-endif # WITH_ASN1
diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am
deleted file mode 100644
index 9a5ab73..0000000
--- a/tools/tests/Makefile.am
+++ /dev/null
@@ -1,84 +0,0 @@
-
-include $(top_srcdir)/build/Makefile.tests
-
-EXTRA_DIST = files
-
-if WITH_ASN1
-
-COMMON = $(top_srcdir)/common
-TOOLS = $(top_srcdir)/tools
-
-TEST_RUNNER = libtool --mode=execute
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/p11-kit \
- -I$(srcdir)/.. \
- -I$(COMMON) \
- -DP11_KIT_FUTURE_UNSTABLE_API \
- $(LIBTASN1_CFLAGS) \
- $(TEST_CFLAGS) \
- $(NULL)
-
-LDADD = \
- $(top_builddir)/p11-kit/libp11-kit.la \
- $(top_builddir)/common/libp11-data.la \
- $(top_builddir)/common/libp11-test.la \
- $(top_builddir)/common/libp11-common.la \
- $(builddir)/libtestcommon.la \
- $(LIBTASN1_LIBS) \
- $(LTLIBINTL) \
- $(CUTEST_LIBS) \
- $(NULL)
-
-noinst_LTLIBRARIES = \
- libtestcommon.la
-
-libtestcommon_la_SOURCES = \
- test-tools.c test-tools.h
-
-CHECK_PROGS = \
- test-save \
- test-extract \
- test-x509 \
- test-pem \
- test-openssl \
- $(NULL)
-
-noinst_PROGRAMS = \
- $(CHECK_PROGS)
-
-TESTS = $(CHECK_PROGS)
-
-test_save_SOURCES = \
- test-save.c \
- $(TOOLS)/save.c \
- $(NULL)
-
-test_extract_SOURCES = \
- test-extract.c \
- $(TOOLS)/extract-info.c \
- $(NULL)
-
-test_x509_SOURCES = \
- test-x509.c \
- $(TOOLS)/extract-info.c \
- $(TOOLS)/extract-x509.c \
- $(TOOLS)/save.c \
- $(NULL)
-
-test_pem_SOURCES = \
- test-pem.c \
- $(TOOLS)/extract-info.c \
- $(TOOLS)/extract-pem.c \
- $(TOOLS)/save.c \
- $(NULL)
-
-test_openssl_SOURCES = \
- test-openssl.c \
- $(TOOLS)/extract-info.c \
- $(TOOLS)/extract-openssl.c \
- $(TOOLS)/save.c \
- $(NULL)
-
-endif # WITH_ASN1
diff --git a/tools/tests/files/cacert3.der b/tools/tests/files/cacert3.der
deleted file mode 100644
index 56f8c88..0000000
--- a/tools/tests/files/cacert3.der
+++ /dev/null
Binary files differ
diff --git a/tools/tests/files/cacert3.pem b/tools/tests/files/cacert3.pem
deleted file mode 100644
index 087ca0e..0000000
--- a/tools/tests/files/cacert3.pem
+++ /dev/null
@@ -1,42 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIHWTCCBUGgAwIBAgIDCkGKMA0GCSqGSIb3DQEBCwUAMHkxEDAOBgNVBAoTB1Jv
-b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ
-Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y
-dEBjYWNlcnQub3JnMB4XDTExMDUyMzE3NDgwMloXDTIxMDUyMDE3NDgwMlowVDEU
-MBIGA1UEChMLQ0FjZXJ0IEluYy4xHjAcBgNVBAsTFWh0dHA6Ly93d3cuQ0FjZXJ0
-Lm9yZzEcMBoGA1UEAxMTQ0FjZXJ0IENsYXNzIDMgUm9vdDCCAiIwDQYJKoZIhvcN
-AQEBBQADggIPADCCAgoCggIBAKtJNRFIfNImflOUz0Op3SjXQiqL84d4GVh8D57a
-iX3h++tykA10oZZkq5+gJJlz2uJVdscXe/UErEa4w75/ZI0QbCTzYZzA8pD6Ueb1
-aQFjww9W4kpCz+JEjCUoqMV5CX1GuYrz6fM0KQhF5Byfy5QEHIGoFLOYZcRD7E6C
-jQnRvapbjZLQ7N6QxX8KwuPr5jFaXnQ+lzNZ6MMDPWAzv/fRb0fEze5ig1JuLgia
-pNkVGJGmhZJHsK5I6223IeyFGmhyNav/8BBdwPSUp2rVO5J+TJAFfpPBLIukjmJ0
-FXFuC3ED6q8VOJrU0gVyb4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aWZpY2F0ZSBmb3IgRlJFRSwgZ28gdG8gaHR0cDovL3d3dy5D
-QWNlcnQub3JnMA0GCSqGSIb3DQEBCwUAA4ICAQApKIWuRKm5r6R5E/CooyuXYPNc
-7uMvwfbiZqARrjY3OnYVBFPqQvX56sAV2KaC2eRhrnILKVyQQ+hBsuF32wITRHhH
-Va9Y/MyY9kW50SD42CEH/m2qc9SzxgfpCYXMO/K2viwcJdVxjDm1Luq+GIG6sJO4
-D+Pm1yaMMVpyA4RS5qb1MyJFCsgLDYq4Nm+QCaGrvdfVTi5xotSu+qdUK+s1jVq3
-VIgv7nSf7UgWyg1I0JTTrKSi9iTfkuO960NAkW4cGI5WtIIS86mTn9S8nK2cde5a
-lxuV53QtHA+wLJef+6kzOXrnAzqSjiL2jA3k2X4Ndhj3AfnvlpaiVXPAPHG0HRpW
-Q7fDCo1y/OIQCQtBzoyUoPkD/XFzS4pXM+WOdH4VAQDmzEoc53+VGS3FpQyLu7Xt
-hbNc09+4ufLKxw0BFKxwWMWMjTPUnWajGlCVI/xI4AZDEtnNp4Y5LzZyo4AQ5OHz
-0ctbGsDkgJp8E3MGT9ujayQKurMcvEp4u+XjdTilSKeiHq921F73OIZWWonO1sOn
-ebJSoMbxhbQljPI/lrMQ2Y1sVzufb4Y6GIIiNsiwkTjbKqGTqoQ/9SdlrnPVyNXT
-d+pLncdBu8fA46A/5H2kjXPmEkvfoXNzczqA6NXLji/L6hOn1kGLrPo8idck9U60
-4GGSt/M3mMS+lqO3ig==
------END CERTIFICATE-----
diff --git a/tools/tests/test-tools.c b/tools/tests/test-tools.c
deleted file mode 100644
index 0c8b624..0000000
--- a/tools/tests/test-tools.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2013, Red Hat Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "test.h"
-
-#include "debug.h"
-#include "test-tools.h"
-
-#include <sys/stat.h>
-
-#include <assert.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static char *
-read_file (const char *file,
- int line,
- const char *function,
- const char *filename,
- long *len)
-{
- struct stat sb;
- FILE *f = NULL;
- char *data;
-
- f = fopen (filename, "rb");
- if (f == NULL)
- p11_test_fail (file, line, function, "Couldn't open file: %s", filename);
-
- /* Figure out size */
- if (stat (filename, &sb) < 0)
- p11_test_fail (file, line, function, "Couldn't stat file: %s", filename);
-
- *len = sb.st_size;
- data = malloc (*len ? *len : 1);
- assert (data != NULL);
-
- /* And read in one block */
- if (fread (data, 1, *len, f) != *len)
- p11_test_fail (file, line, function, "Couldn't read file: %s", filename);
-
- fclose (f);
-
- return data;
-}
-
-void
-test_check_file_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- const char *name,
- const char *reference)
-{
- char *refdata;
- long reflen;
-
- refdata = read_file (file, line, function, reference, &reflen);
- test_check_data_msg (file, line, function, directory, name, refdata, reflen);
- free (refdata);
-}
-
-void
-test_check_data_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- const char *name,
- const void *refdata,
- long reflen)
-{
- char *filedata;
- char *filename;
- long filelen;
-
- if (asprintf (&filename, "%s/%s", directory, name) < 0)
- assert_not_reached ();
-
- filedata = read_file (file, line, function, filename, &filelen);
-
- if (filelen != reflen || memcmp (filedata, refdata, reflen) != 0)
- p11_test_fail (file, line, function, "File contents not as expected: %s", filename);
-
- if (unlink (filename) < 0)
- p11_test_fail (file, line, function, "Couldn't remove file: %s", filename);
- free (filename);
- free (filedata);
-}
-
-#ifdef OS_UNIX
-
-void
-test_check_symlink_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- const char *name,
- const char *destination)
-{
- char buf[1024] = { 0, };
- char *filename;
-
- if (asprintf (&filename, "%s/%s", directory, name) < 0)
- assert_not_reached ();
-
- if (readlink (filename, buf, sizeof (buf)) < 0)
- p11_test_fail (file, line, function, "Couldn't read symlink: %s", filename);
-
- if (strcmp (destination, buf) != 0)
- p11_test_fail (file, line, function, "Symlink contents wrong: %s != %s", destination, buf);
-
- if (unlink (filename) < 0)
- p11_test_fail (file, line, function, "Couldn't remove symlink: %s", filename);
- free (filename);
-}
-
-#endif /* OS_UNIX */
-
-p11_dict *
-test_check_directory_files (const char *file,
- ...)
-{
- p11_dict *files;
- va_list va;
-
- files = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL);
-
- va_start (va, file);
-
- while (file != NULL) {
- if (!p11_dict_set (files, (void *)file, (void *)file))
- return_val_if_reached (NULL);
- file = va_arg (va, const char *);
- }
-
- va_end (va);
-
- return files;
-}
-
-void
-test_check_directory_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- p11_dict *files)
-{
- p11_dictiter iter;
- struct dirent *dp;
- const char *name;
- DIR *dir;
-
- dir = opendir (directory);
- if (dir == NULL)
- p11_test_fail (file ,line, function, "Couldn't open directory: %s", directory);
-
- while ((dp = readdir (dir)) != NULL) {
- if (strcmp (dp->d_name, ".") == 0 ||
- strcmp (dp->d_name, "..") == 0)
- continue;
-
- if (!p11_dict_remove (files, dp->d_name))
- p11_test_fail (file, line, function, "Unexpected file in directory: %s", dp->d_name);
- }
-
- closedir (dir);
-
-#ifdef OS_UNIX
- if (chmod (directory, S_IRWXU) < 0)
- p11_test_fail (file, line, function, "couldn't chown directory: %s: %s", directory, strerror (errno));
-#endif
-
- p11_dict_iterate (files, &iter);
- while (p11_dict_next (&iter, (void **)&name, NULL))
- p11_test_fail (file, line, function, "Couldn't find file in directory: %s", name);
-
- p11_dict_free (files);
-}
diff --git a/tools/tests/test-tools.h b/tools/tests/test-tools.h
deleted file mode 100644
index 8e66c54..0000000
--- a/tools/tests/test-tools.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (c) 2013, Red Hat Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#ifndef TEST_COMMON_H_
-#define TEST_COMMON_H_
-
-#include "test.h"
-
-#include "dict.h"
-
-#include <stdlib.h>
-
-static const char test_text[] = "This is the file text";
-
-static const unsigned char test_cacert3_ca_der[] = {
- 0x30, 0x82, 0x07, 0x59, 0x30, 0x82, 0x05, 0x41, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x0a,
- 0x41, 0x8a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05,
- 0x00, 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f,
- 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15,
- 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72,
- 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x19,
- 0x43, 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20,
- 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a,
- 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72,
- 0x74, 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x1e, 0x17, 0x0d,
- 0x31, 0x31, 0x30, 0x35, 0x32, 0x33, 0x31, 0x37, 0x34, 0x38, 0x30, 0x32, 0x5a, 0x17, 0x0d, 0x32,
- 0x31, 0x30, 0x35, 0x32, 0x30, 0x31, 0x37, 0x34, 0x38, 0x30, 0x32, 0x5a, 0x30, 0x54, 0x31, 0x14,
- 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x20,
- 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68,
- 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74,
- 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x43,
- 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x33, 0x20, 0x52, 0x6f,
- 0x6f, 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 0xe9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x02, 0x0d, 0x30, 0x82, 0x02, 0x09,
- 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x75, 0xa8, 0x71, 0x60, 0x4c,
- 0x88, 0x13, 0xf0, 0x78, 0xd9, 0x89, 0x77, 0xb5, 0x6d, 0xc5, 0x89, 0xdf, 0xbc, 0xb1, 0x7a, 0x30,
- 0x81, 0xa3, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x81, 0x9b, 0x30, 0x81, 0x98, 0x80, 0x14, 0x16,
- 0xb5, 0x32, 0x1b, 0xd4, 0xc7, 0xf3, 0xe0, 0xe6, 0x8e, 0xf3, 0xbd, 0xd2, 0xb0, 0x3a, 0xee, 0xb2,
- 0x39, 0x18, 0xd1, 0xa1, 0x7d, 0xa4, 0x7b, 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55,
- 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06,
- 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
- 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06,
- 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, 0x43, 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69,
- 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31,
- 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12,
- 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f,
- 0x72, 0x67, 0x82, 0x01, 0x00, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04,
- 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x5d, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07,
- 0x01, 0x01, 0x04, 0x51, 0x30, 0x4f, 0x30, 0x23, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07,
- 0x30, 0x01, 0x86, 0x17, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e,
- 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x30, 0x28, 0x06, 0x08, 0x2b,
- 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x1c, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
- 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x63,
- 0x61, 0x2e, 0x63, 0x72, 0x74, 0x30, 0x4a, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x43, 0x30, 0x41,
- 0x30, 0x3f, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x90, 0x4a, 0x30, 0x33, 0x30, 0x31,
- 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x25, 0x68, 0x74, 0x74, 0x70,
- 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72,
- 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x68, 0x70, 0x3f, 0x69, 0x64, 0x3d, 0x31,
- 0x30, 0x30, 0x34, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x08, 0x04, 0x27,
- 0x16, 0x25, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63,
- 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x68,
- 0x70, 0x3f, 0x69, 0x64, 0x3d, 0x31, 0x30, 0x30, 0x50, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86,
- 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x43, 0x16, 0x41, 0x54, 0x6f, 0x20, 0x67, 0x65, 0x74, 0x20, 0x79,
- 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, 0x20, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63,
- 0x61, 0x74, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x46, 0x52, 0x45, 0x45, 0x2c, 0x20, 0x67, 0x6f,
- 0x20, 0x74, 0x6f, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43,
- 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
- 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x29, 0x28, 0x85,
- 0xae, 0x44, 0xa9, 0xb9, 0xaf, 0xa4, 0x79, 0x13, 0xf0, 0xa8, 0xa3, 0x2b, 0x97, 0x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 0xbc, 0x4a, 0x78, 0xbb, 0xe5, 0xe3, 0x75, 0x38, 0xa5, 0x48, 0xa7,
- 0xa2, 0x1e, 0xaf, 0x76, 0xd4, 0x5e, 0xf7, 0x38, 0x86, 0x56, 0x5a, 0x89, 0xce, 0xd6, 0xc3, 0xa7,
- 0x79, 0xb2, 0x52, 0xa0, 0xc6, 0xf1, 0x85, 0xb4, 0x25, 0x8c, 0xf2, 0x3f, 0x96, 0xb3, 0x10, 0xd9,
- 0x8d, 0x6c, 0x57, 0x3b, 0x9f, 0x6f, 0x86, 0x3a, 0x18, 0x82, 0x22, 0x36, 0xc8, 0xb0, 0x91, 0x38,
- 0xdb, 0x2a, 0xa1, 0x93, 0xaa, 0x84, 0x3f, 0xf5, 0x27, 0x65, 0xae, 0x73, 0xd5, 0xc8, 0xd5, 0xd3,
- 0x77, 0xea, 0x4b, 0x9d, 0xc7, 0x41, 0xbb, 0xc7, 0xc0, 0xe3, 0xa0, 0x3f, 0xe4, 0x7d, 0xa4, 0x8d,
- 0x73, 0xe6, 0x12, 0x4b, 0xdf, 0xa1, 0x73, 0x73, 0x73, 0x3a, 0x80, 0xe8, 0xd5, 0xcb, 0x8e, 0x2f,
- 0xcb, 0xea, 0x13, 0xa7, 0xd6, 0x41, 0x8b, 0xac, 0xfa, 0x3c, 0x89, 0xd7, 0x24, 0xf5, 0x4e, 0xb4,
- 0xe0, 0x61, 0x92, 0xb7, 0xf3, 0x37, 0x98, 0xc4, 0xbe, 0x96, 0xa3, 0xb7, 0x8a,
-};
-
-static const char test_cacert3_ca_subject[] = {
- 0x30, 0x54, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x43, 0x41, 0x63,
- 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04,
- 0x0b, 0x13, 0x15, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41,
- 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04,
- 0x03, 0x13, 0x13, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20,
- 0x33, 0x20, 0x52, 0x6f, 0x6f, 0x74,
-};
-
-static const char test_cacert3_ca_issuer[] = {
- 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, 0x6f,
- 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68,
- 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74,
- 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, 0x43,
- 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x41,
- 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86,
- 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74,
- 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67,
-};
-
-static const char test_cacert3_ca_serial[] = {
- 0x02, 0x01, 0x00,
-};
-
-static const char test_eku_server_and_client[] = {
- 0x30, 0x14, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06,
- 0x01, 0x05, 0x05, 0x07, 0x03, 0x02,
-};
-
-static const char test_eku_server[] = {
- 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01,
-};
-
-static const char test_eku_email[] = {
- 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04
-};
-
-static const char test_eku_none[] = {
- 0x30, 0x00,
-};
-
-void test_check_file_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- const char *filename,
- const char *reference);
-
-void test_check_data_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- const char *filename,
- const void *refdata,
- long reflen);
-
-#ifdef OS_UNIX
-
-void test_check_symlink_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- const char *name,
- const char *destination);
-
-#endif /* OS_UNIX */
-
-p11_dict * test_check_directory_files (const char *file,
- ...) GNUC_NULL_TERMINATED;
-
-void test_check_directory_msg (const char *file,
- int line,
- const char *function,
- const char *directory,
- p11_dict *files);
-
-#define test_check_file(directory, name, reference) \
- (test_check_file_msg (__FILE__, __LINE__, __FUNCTION__, directory, name, reference))
-
-#define test_check_data(directory, name, data, length) \
- (test_check_data_msg (__FILE__, __LINE__, __FUNCTION__, directory, name, data, length))
-
-#ifdef OS_UNIX
-
-#define test_check_symlink(directory, name, destination) \
- (test_check_symlink_msg (__FILE__, __LINE__, __FUNCTION__, directory, name, destination))
-
-#endif /* OS_UNIX */
-
-#define test_check_directory(directory, files) \
- (test_check_directory_msg (__FILE__, __LINE__, __FUNCTION__, directory, \
- test_check_directory_files files))
-
-#endif /* TEST_COMMON_H_ */
diff --git a/trust/Makefile.am b/trust/Makefile.am
index 6c2c7c8..582b4f5 100644
--- a/trust/Makefile.am
+++ b/trust/Makefile.am
@@ -13,6 +13,22 @@ AM_CPPFLAGS = \
$(LIBTASN1_CFLAGS) \
$(NULL)
+noinst_LTLIBRARIES = \
+ libtrust-testable.la \
+ libtrust-data.la
+
+libtrust_data_la_SOURCES = \
+ asn1.c asn1.h \
+ basic.asn basic.asn.h \
+ base64.c base64.h \
+ pem.c pem.h \
+ pkix.asn pkix.asn.h \
+ oid.c oid.h \
+ openssl.asn openssl.asn.h \
+ utf8.c utf8.h \
+ x509.c x509.h \
+ $(NULL)
+
MODULE_SRCS = \
builder.c builder.h \
index.c index.h \
@@ -34,7 +50,7 @@ p11_kit_trust_la_CFLAGS = \
$(LIBTASN1_CFLAGS)
p11_kit_trust_la_LIBADD = \
- $(top_builddir)/common/libp11-data.la \
+ libtrust-data.la \
$(top_builddir)/common/libp11-library.la \
$(top_builddir)/common/libp11-common.la \
$(LIBTASN1_LIBS) \
@@ -48,17 +64,49 @@ p11_kit_trust_la_LDFLAGS = \
p11_kit_trust_la_SOURCES = $(MODULE_SRCS)
-noinst_LTLIBRARIES = \
- libtrust-testable.la
-
libtrust_testable_la_LDFLAGS = \
-no-undefined
libtrust_testable_la_SOURCES = $(MODULE_SRCS)
+bin_PROGRAMS = \
+ trust
+
+trust_LDADD = \
+ libtrust-data.la \
+ $(top_builddir)/p11-kit/libp11-kit.la \
+ $(top_builddir)/common/libp11-common.la \
+ $(top_builddir)/common/libp11-tool.la \
+ $(LTLIBINTL) \
+ $(LIBTASN1_LIBS) \
+ $(NULL)
+
+trust_CFLAGS = \
+ -I$(top_srcdir)/p11-kit \
+ -DP11_KIT_FUTURE_UNSTABLE_API \
+ $(LIBTASN1_CFLAGS) \
+ $(NULL)
+
+trust_SOURCES = \
+ extract.c extract.h \
+ extract-info.c \
+ extract-jks.c \
+ extract-openssl.c \
+ extract-pem.c \
+ extract-cer.c \
+ openssl.asn openssl.asn.h \
+ save.c save.h \
+ trust.c \
+ $(NULL)
+
externaldir = $(privatedir)
external_SCRIPTS = \
p11-kit-extract-trust
EXTRA_DIST = \
p11-kit-trust.module
+
+asn:
+ asn1Parser -o pkix.asn.h pkix.asn
+ asn1Parser -o openssl.asn.h openssl.asn
+ asn1Parser -o basic.asn.h basic.asn
diff --git a/common/asn1.c b/trust/asn1.c
index 29cca3a..29cca3a 100644
--- a/common/asn1.c
+++ b/trust/asn1.c
diff --git a/common/asn1.h b/trust/asn1.h
index 1bd7dd1..1bd7dd1 100644
--- a/common/asn1.h
+++ b/trust/asn1.h
diff --git a/common/base64.c b/trust/base64.c
index a9eb966..a9eb966 100644
--- a/common/base64.c
+++ b/trust/base64.c
diff --git a/common/base64.h b/trust/base64.h
index cc27afd..cc27afd 100644
--- a/common/base64.h
+++ b/trust/base64.h
diff --git a/common/basic.asn b/trust/basic.asn
index 3c79a4b..3c79a4b 100644
--- a/common/basic.asn
+++ b/trust/basic.asn
diff --git a/common/basic.asn.h b/trust/basic.asn.h
index b63447b..b63447b 100644
--- a/common/basic.asn.h
+++ b/trust/basic.asn.h
diff --git a/tools/extract-x509.c b/trust/extract-cer.c
index 4a0d9c0..4a0d9c0 100644
--- a/tools/extract-x509.c
+++ b/trust/extract-cer.c
diff --git a/tools/extract-info.c b/trust/extract-info.c
index 133b1cd..133b1cd 100644
--- a/tools/extract-info.c
+++ b/trust/extract-info.c
diff --git a/tools/extract-jks.c b/trust/extract-jks.c
index 2c78a51..2c78a51 100644
--- a/tools/extract-jks.c
+++ b/trust/extract-jks.c
diff --git a/tools/extract-openssl.c b/trust/extract-openssl.c
index 91a9965..91a9965 100644
--- a/tools/extract-openssl.c
+++ b/trust/extract-openssl.c
diff --git a/tools/extract-pem.c b/trust/extract-pem.c
index 0bae3cb..0bae3cb 100644
--- a/tools/extract-pem.c
+++ b/trust/extract-pem.c
diff --git a/tools/extract.c b/trust/extract.c
index 3d1fee7..10f45df 100644
--- a/tools/extract.c
+++ b/trust/extract.c
@@ -295,8 +295,8 @@ validate_filter_and_format (p11_extract_info *ex,
}
int
-p11_tool_extract (int argc,
- char **argv)
+p11_trust_extract (int argc,
+ char **argv)
{
p11_extract_func format = NULL;
CK_FUNCTION_LIST_PTR *modules;
diff --git a/tools/extract.h b/trust/extract.h
index 85405e5..7db61c1 100644
--- a/tools/extract.h
+++ b/trust/extract.h
@@ -119,4 +119,7 @@ bool p11_extract_openssl_bundle (P11KitIter *iter,
bool p11_extract_openssl_directory (P11KitIter *iter,
p11_extract_info *ex);
+int p11_trust_extract (int argc,
+ char **argv);
+
#endif /* P11_EXTRACT_H_ */
diff --git a/common/oid.c b/trust/oid.c
index b4b0bf6..b4b0bf6 100644
--- a/common/oid.c
+++ b/trust/oid.c
diff --git a/common/oid.h b/trust/oid.h
index dee6b10..dee6b10 100644
--- a/common/oid.h
+++ b/trust/oid.h
diff --git a/common/openssl.asn b/trust/openssl.asn
index c1f452b..c1f452b 100644
--- a/common/openssl.asn
+++ b/trust/openssl.asn
diff --git a/common/openssl.asn.h b/trust/openssl.asn.h
index 4e6b240..4e6b240 100644
--- a/common/openssl.asn.h
+++ b/trust/openssl.asn.h
diff --git a/common/pem.c b/trust/pem.c
index 7fe0076..7fe0076 100644
--- a/common/pem.c
+++ b/trust/pem.c
diff --git a/common/pem.h b/trust/pem.h
index 7e4ce63..7e4ce63 100644
--- a/common/pem.h
+++ b/trust/pem.h
diff --git a/common/pkix.asn b/trust/pkix.asn
index 38bb028..38bb028 100644
--- a/common/pkix.asn
+++ b/trust/pkix.asn
diff --git a/common/pkix.asn.h b/trust/pkix.asn.h
index d5d5cc4..d5d5cc4 100644
--- a/common/pkix.asn.h
+++ b/trust/pkix.asn.h
diff --git a/tools/save.c b/trust/save.c
index f1605a3..f1605a3 100644
--- a/tools/save.c
+++ b/trust/save.c
diff --git a/tools/save.h b/trust/save.h
index f68d054..f68d054 100644
--- a/tools/save.h
+++ b/trust/save.h
diff --git a/trust/tests/Makefile.am b/trust/tests/Makefile.am
index abacab6..9d5b3ae 100644
--- a/trust/tests/Makefile.am
+++ b/trust/tests/Makefile.am
@@ -1,29 +1,36 @@
include $(top_srcdir)/build/Makefile.tests
+COMMON = $(top_srcdir)/common
+TRUST = $(top_srcdir)/trust
+
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(srcdir)/.. \
- -I$(top_srcdir)/common \
+ -I$(top_srcdir)/p11-kit \
+ -I$(COMMON) \
-DDATADIR=\"$(datadir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
- $(TEST_CFLAGS)
+ -DP11_KIT_FUTURE_UNSTABLE_API \
+ $(LIBTASN1_CFLAGS) \
+ $(TEST_CFLAGS) \
+ $(NULL)
noinst_LTLIBRARIES = \
- libtestdata.la
+ libtrust-test.la
-libtestdata_la_SOURCES = \
+libtrust_test_la_SOURCES = \
test-trust.c test-trust.h
LDADD = \
$(top_builddir)/trust/libtrust-testable.la \
- $(top_builddir)/common/libp11-data.la \
+ $(top_builddir)/trust/libtrust-data.la \
+ $(builddir)/libtrust-test.la \
+ $(top_builddir)/p11-kit/libp11-kit.la \
$(top_builddir)/common/libp11-library.la \
$(top_builddir)/common/libp11-test.la \
$(top_builddir)/common/libp11-common.la \
- $(builddir)/libtestdata.la \
$(LIBTASN1_LIBS) \
- $(CUTEST_LIBS) \
$(NULL)
CHECK_PROGS = \
@@ -33,12 +40,28 @@ CHECK_PROGS = \
test-builder \
test-token \
test-module \
+ test-save \
+ test-extract \
+ test-cer \
+ test-bundle \
+ test-openssl \
+ test-asn1 \
+ test-base64 \
+ test-pem \
+ test-oid \
+ test-utf8 \
+ test-x509 \
$(NULL)
noinst_PROGRAMS = \
frob-pow \
frob-token \
frob-nss-trust \
+ frob-cert \
+ frob-ku \
+ frob-eku \
+ frob-cert \
+ frob-oid \
$(CHECK_PROGS)
frob_nss_trust_LDADD = \
@@ -51,3 +74,36 @@ EXTRA_DIST = \
input \
files \
$(NULL)
+
+TEST_RUNNER = libtool --mode=execute
+
+test_save_SOURCES = \
+ test-save.c \
+ $(TRUST)/save.c \
+ $(NULL)
+
+test_extract_SOURCES = \
+ test-extract.c \
+ $(TRUST)/extract-info.c \
+ $(NULL)
+
+test_cer_SOURCES = \
+ test-cer.c \
+ $(TRUST)/extract-info.c \
+ $(TRUST)/extract-cer.c \
+ $(TRUST)/save.c \
+ $(NULL)
+
+test_bundle_SOURCES = \
+ test-bundle.c \
+ $(TRUST)/extract-info.c \
+ $(TRUST)/extract-pem.c \
+ $(TRUST)/save.c \
+ $(NULL)
+
+test_openssl_SOURCES = \
+ test-openssl.c \
+ $(TRUST)/extract-info.c \
+ $(TRUST)/extract-openssl.c \
+ $(TRUST)/save.c \
+ $(NULL)
diff --git a/tools/tests/files/cacert3-distrust-all.pem b/trust/tests/files/cacert3-distrust-all.pem
index ce5d887..ce5d887 100644
--- a/tools/tests/files/cacert3-distrust-all.pem
+++ b/trust/tests/files/cacert3-distrust-all.pem
diff --git a/tools/tests/files/cacert3-distrusted-all.pem b/trust/tests/files/cacert3-distrusted-all.pem
index 4a04a39..4a04a39 100644
--- a/tools/tests/files/cacert3-distrusted-all.pem
+++ b/trust/tests/files/cacert3-distrusted-all.pem
diff --git a/tools/tests/files/cacert3-not-trusted.pem b/trust/tests/files/cacert3-not-trusted.pem
index eaa2e54..eaa2e54 100644
--- a/tools/tests/files/cacert3-not-trusted.pem
+++ b/trust/tests/files/cacert3-not-trusted.pem
diff --git a/tools/tests/files/cacert3-trusted-alias.pem b/trust/tests/files/cacert3-trusted-alias.pem
index 44601ea..44601ea 100644
--- a/tools/tests/files/cacert3-trusted-alias.pem
+++ b/trust/tests/files/cacert3-trusted-alias.pem
diff --git a/tools/tests/files/cacert3-trusted-keyid.pem b/trust/tests/files/cacert3-trusted-keyid.pem
index e652733..e652733 100644
--- a/tools/tests/files/cacert3-trusted-keyid.pem
+++ b/trust/tests/files/cacert3-trusted-keyid.pem
diff --git a/tools/tests/files/cacert3-trusted-multiple.pem b/trust/tests/files/cacert3-trusted-multiple.pem
index e56a58f..e56a58f 100644
--- a/tools/tests/files/cacert3-trusted-multiple.pem
+++ b/trust/tests/files/cacert3-trusted-multiple.pem
diff --git a/tools/tests/files/cacert3-trusted-server-alias.pem b/trust/tests/files/cacert3-trusted-server-alias.pem
index 55593ec..55593ec 100644
--- a/tools/tests/files/cacert3-trusted-server-alias.pem
+++ b/trust/tests/files/cacert3-trusted-server-alias.pem
diff --git a/tools/tests/files/cacert3-twice.pem b/trust/tests/files/cacert3-twice.pem
index c73202d..c73202d 100644
--- a/tools/tests/files/cacert3-twice.pem
+++ b/trust/tests/files/cacert3-twice.pem
diff --git a/tools/tests/files/empty-file b/trust/tests/files/empty-file
index e69de29..e69de29 100644
--- a/tools/tests/files/empty-file
+++ b/trust/tests/files/empty-file
diff --git a/tools/tests/files/simple-string b/trust/tests/files/simple-string
index be13474..be13474 100644
--- a/tools/tests/files/simple-string
+++ b/trust/tests/files/simple-string
diff --git a/common/tests/frob-cert.c b/trust/tests/frob-cert.c
index 71018bd..71018bd 100644
--- a/common/tests/frob-cert.c
+++ b/trust/tests/frob-cert.c
diff --git a/common/tests/frob-eku.c b/trust/tests/frob-eku.c
index 42bf50b..42bf50b 100644
--- a/common/tests/frob-eku.c
+++ b/trust/tests/frob-eku.c
diff --git a/common/tests/frob-ku.c b/trust/tests/frob-ku.c
index 00d45c6..00d45c6 100644
--- a/common/tests/frob-ku.c
+++ b/trust/tests/frob-ku.c
diff --git a/common/tests/frob-oid.c b/trust/tests/frob-oid.c
index b4c7658..b4c7658 100644
--- a/common/tests/frob-oid.c
+++ b/trust/tests/frob-oid.c
diff --git a/common/tests/test-asn1.c b/trust/tests/test-asn1.c
index 710928c..710928c 100644
--- a/common/tests/test-asn1.c
+++ b/trust/tests/test-asn1.c
diff --git a/common/tests/test-base64.c b/trust/tests/test-base64.c
index ce303e8..ce303e8 100644
--- a/common/tests/test-base64.c
+++ b/trust/tests/test-base64.c
diff --git a/tools/tests/test-pem.c b/trust/tests/test-bundle.c
index c74d0df..bff135e 100644
--- a/tools/tests/test-pem.c
+++ b/trust/tests/test-bundle.c
@@ -35,8 +35,8 @@
#define P11_KIT_DISABLE_DEPRECATED
#include "config.h"
-#include "test.h"
-#include "test-tools.h"
+
+#include "test-trust.h"
#include "attrs.h"
#include "compat.h"
@@ -49,6 +49,7 @@
#include "pkcs11.h"
#include "pkcs11x.h"
#include "oid.h"
+#include "test.h"
#include <assert.h>
#include <stdio.h>
diff --git a/tools/tests/test-x509.c b/trust/tests/test-cer.c
index 693aaa0..c48a5ab 100644
--- a/tools/tests/test-x509.c
+++ b/trust/tests/test-cer.c
@@ -35,8 +35,8 @@
#define P11_KIT_DISABLE_DEPRECATED
#include "config.h"
-#include "test.h"
-#include "test-tools.h"
+
+#include "test-trust.h"
#include "attrs.h"
#include "compat.h"
@@ -49,6 +49,7 @@
#include "pkcs11.h"
#include "pkcs11x.h"
#include "oid.h"
+#include "test.h"
#include <assert.h>
#include <stdio.h>
diff --git a/tools/tests/test-extract.c b/trust/tests/test-extract.c
index 9712e81..e860996 100644
--- a/tools/tests/test-extract.c
+++ b/trust/tests/test-extract.c
@@ -35,8 +35,8 @@
#define P11_KIT_DISABLE_DEPRECATED
#include "config.h"
-#include "test.h"
-#include "test-tools.h"
+
+#include "test-trust.h"
#include "attrs.h"
#include "compat.h"
@@ -48,6 +48,7 @@
#include "pkcs11.h"
#include "pkcs11x.h"
#include "oid.h"
+#include "test.h"
#include <stdlib.h>
#include <string.h>
diff --git a/common/tests/test-oid.c b/trust/tests/test-oid.c
index 05945d9..05945d9 100644
--- a/common/tests/test-oid.c
+++ b/trust/tests/test-oid.c
diff --git a/tools/tests/test-openssl.c b/trust/tests/test-openssl.c
index d393072..7479812 100644
--- a/tools/tests/test-openssl.c
+++ b/trust/tests/test-openssl.c
@@ -35,8 +35,8 @@
#define P11_KIT_DISABLE_DEPRECATED
#include "config.h"
-#include "test.h"
-#include "test-tools.h"
+
+#include "test-trust.h"
#include "attrs.h"
#include "buffer.h"
@@ -50,6 +50,7 @@
#include "pkcs11.h"
#include "pkcs11x.h"
#include "oid.h"
+#include "test.h"
#include <assert.h>
#include <stdarg.h>
diff --git a/common/tests/test-pem.c b/trust/tests/test-pem.c
index 0c7d60a..0c7d60a 100644
--- a/common/tests/test-pem.c
+++ b/trust/tests/test-pem.c
diff --git a/tools/tests/test-save.c b/trust/tests/test-save.c
index 93af4f9..be072f5 100644
--- a/tools/tests/test-save.c
+++ b/trust/tests/test-save.c
@@ -33,8 +33,8 @@
*/
#include "config.h"
-#include "test.h"
-#include "test-tools.h"
+
+#include "test-trust.h"
#include "attrs.h"
#include "compat.h"
@@ -43,6 +43,7 @@
#include "message.h"
#include "path.h"
#include "save.h"
+#include "test.h"
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/trust/tests/test-trust.c b/trust/tests/test-trust.c
index 6a22946..33ba19e 100644
--- a/trust/tests/test-trust.c
+++ b/trust/tests/test-trust.c
@@ -33,15 +33,24 @@
*/
#include "config.h"
-#include "test.h"
#include "attrs.h"
+#include "debug.h"
+#include "test.h"
+
#include "test-trust.h"
+#include <sys/stat.h>
+
#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
void
test_check_object_msg (const char *file,
@@ -150,3 +159,168 @@ test_check_attr_msg (const char *file,
attr ? p11_attr_to_string (attr, klass) : "(null)");
}
}
+
+static char *
+read_file (const char *file,
+ int line,
+ const char *function,
+ const char *filename,
+ long *len)
+{
+ struct stat sb;
+ FILE *f = NULL;
+ char *data;
+
+ f = fopen (filename, "rb");
+ if (f == NULL)
+ p11_test_fail (file, line, function, "Couldn't open file: %s", filename);
+
+ /* Figure out size */
+ if (stat (filename, &sb) < 0)
+ p11_test_fail (file, line, function, "Couldn't stat file: %s", filename);
+
+ *len = sb.st_size;
+ data = malloc (*len ? *len : 1);
+ assert (data != NULL);
+
+ /* And read in one block */
+ if (fread (data, 1, *len, f) != *len)
+ p11_test_fail (file, line, function, "Couldn't read file: %s", filename);
+
+ fclose (f);
+
+ return data;
+}
+
+void
+test_check_file_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ const char *name,
+ const char *reference)
+{
+ char *refdata;
+ long reflen;
+
+ refdata = read_file (file, line, function, reference, &reflen);
+ test_check_data_msg (file, line, function, directory, name, refdata, reflen);
+ free (refdata);
+}
+
+void
+test_check_data_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ const char *name,
+ const void *refdata,
+ long reflen)
+{
+ char *filedata;
+ char *filename;
+ long filelen;
+
+ if (asprintf (&filename, "%s/%s", directory, name) < 0)
+ assert_not_reached ();
+
+ filedata = read_file (file, line, function, filename, &filelen);
+
+ if (filelen != reflen || memcmp (filedata, refdata, reflen) != 0)
+ p11_test_fail (file, line, function, "File contents not as expected: %s", filename);
+
+ if (unlink (filename) < 0)
+ p11_test_fail (file, line, function, "Couldn't remove file: %s", filename);
+ free (filename);
+ free (filedata);
+}
+
+#ifdef OS_UNIX
+
+void
+test_check_symlink_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ const char *name,
+ const char *destination)
+{
+ char buf[1024] = { 0, };
+ char *filename;
+
+ if (asprintf (&filename, "%s/%s", directory, name) < 0)
+ assert_not_reached ();
+
+ if (readlink (filename, buf, sizeof (buf)) < 0)
+ p11_test_fail (file, line, function, "Couldn't read symlink: %s", filename);
+
+ if (strcmp (destination, buf) != 0)
+ p11_test_fail (file, line, function, "Symlink contents wrong: %s != %s", destination, buf);
+
+ if (unlink (filename) < 0)
+ p11_test_fail (file, line, function, "Couldn't remove symlink: %s", filename);
+ free (filename);
+}
+
+#endif /* OS_UNIX */
+
+p11_dict *
+test_check_directory_files (const char *file,
+ ...)
+{
+ p11_dict *files;
+ va_list va;
+
+ files = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL);
+
+ va_start (va, file);
+
+ while (file != NULL) {
+ if (!p11_dict_set (files, (void *)file, (void *)file))
+ return_val_if_reached (NULL);
+ file = va_arg (va, const char *);
+ }
+
+ va_end (va);
+
+ return files;
+}
+
+void
+test_check_directory_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ p11_dict *files)
+{
+ p11_dictiter iter;
+ struct dirent *dp;
+ const char *name;
+ DIR *dir;
+
+ dir = opendir (directory);
+ if (dir == NULL)
+ p11_test_fail (file ,line, function, "Couldn't open directory: %s", directory);
+
+ while ((dp = readdir (dir)) != NULL) {
+ if (strcmp (dp->d_name, ".") == 0 ||
+ strcmp (dp->d_name, "..") == 0)
+ continue;
+
+ if (!p11_dict_remove (files, dp->d_name))
+ p11_test_fail (file, line, function, "Unexpected file in directory: %s", dp->d_name);
+ }
+
+ closedir (dir);
+
+#ifdef OS_UNIX
+ if (chmod (directory, S_IRWXU) < 0)
+ p11_test_fail (file, line, function, "couldn't chown directory: %s: %s", directory, strerror (errno));
+#endif
+
+ p11_dict_iterate (files, &iter);
+ while (p11_dict_next (&iter, (void **)&name, NULL))
+ p11_test_fail (file, line, function, "Couldn't find file in directory: %s", name);
+
+ p11_dict_free (files);
+}
diff --git a/trust/tests/test-trust.h b/trust/tests/test-trust.h
index 672ae64..18ca13c 100644
--- a/trust/tests/test-trust.h
+++ b/trust/tests/test-trust.h
@@ -32,9 +32,12 @@
* Author: Stef Walter <stefw@gnome.org>
*/
+#include "dict.h"
#include "pkcs11.h"
+#include "test.h"
#include <sys/types.h>
+#include <stdlib.h>
#ifndef TEST_DATA_H_
#define TEST_DATA_H_
@@ -270,4 +273,75 @@ static const unsigned char verisign_v1_ca[] = {
0xfd, 0x76, 0x04, 0xdb, 0x62, 0xbb, 0x90, 0x6a, 0x03, 0xd9, 0x46, 0x35, 0xd9, 0xf8, 0x7c, 0x5b,
};
+static const char test_text[] = "This is the file text";
+
+static const char test_eku_server_and_client[] = {
+ 0x30, 0x14, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06,
+ 0x01, 0x05, 0x05, 0x07, 0x03, 0x02,
+};
+
+static const char test_eku_server[] = {
+ 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01,
+};
+
+static const char test_eku_email[] = {
+ 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04
+};
+
+static const char test_eku_none[] = {
+ 0x30, 0x00,
+};
+
+void test_check_file_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ const char *filename,
+ const char *reference);
+
+void test_check_data_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ const char *filename,
+ const void *refdata,
+ long reflen);
+
+#ifdef OS_UNIX
+
+void test_check_symlink_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ const char *name,
+ const char *destination);
+
+#endif /* OS_UNIX */
+
+p11_dict * test_check_directory_files (const char *file,
+ ...) GNUC_NULL_TERMINATED;
+
+void test_check_directory_msg (const char *file,
+ int line,
+ const char *function,
+ const char *directory,
+ p11_dict *files);
+
+#define test_check_file(directory, name, reference) \
+ (test_check_file_msg (__FILE__, __LINE__, __FUNCTION__, directory, name, reference))
+
+#define test_check_data(directory, name, data, length) \
+ (test_check_data_msg (__FILE__, __LINE__, __FUNCTION__, directory, name, data, length))
+
+#ifdef OS_UNIX
+
+#define test_check_symlink(directory, name, destination) \
+ (test_check_symlink_msg (__FILE__, __LINE__, __FUNCTION__, directory, name, destination))
+
+#endif /* OS_UNIX */
+
+#define test_check_directory(directory, files) \
+ (test_check_directory_msg (__FILE__, __LINE__, __FUNCTION__, directory, \
+ test_check_directory_files files))
+
#endif /* TEST_DATA_H_ */
diff --git a/common/tests/test-utf8.c b/trust/tests/test-utf8.c
index 9b2c3d5..9b2c3d5 100644
--- a/common/tests/test-utf8.c
+++ b/trust/tests/test-utf8.c
diff --git a/common/tests/test-x509.c b/trust/tests/test-x509.c
index 9f7d258..9f7d258 100644
--- a/common/tests/test-x509.c
+++ b/trust/tests/test-x509.c
diff --git a/trust/trust.c b/trust/trust.c
new file mode 100644
index 0000000..1993951
--- /dev/null
+++ b/trust/trust.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Collabora Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ * * The names of contributors to this software may not be
+ * used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Author: Stef Walter <stefw@collabora.co.uk>
+ */
+
+#include "config.h"
+
+#include "extract.h"
+
+#include "buffer.h"
+#include "compat.h"
+#include "debug.h"
+#include "message.h"
+#include "path.h"
+#include "tool.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static const p11_tool_command commands[] = {
+ { "extract", p11_trust_extract, "Extract certificates and trust" },
+ { 0, }
+};
+
+int
+main (int argc,
+ char *argv[])
+{
+ return p11_tool_main (argc, argv, commands);
+}
diff --git a/common/utf8.c b/trust/utf8.c
index b94c3e7..b94c3e7 100644
--- a/common/utf8.c
+++ b/trust/utf8.c
diff --git a/common/utf8.h b/trust/utf8.h
index 8efa66f..8efa66f 100644
--- a/common/utf8.h
+++ b/trust/utf8.h
diff --git a/common/x509.c b/trust/x509.c
index aa6e171..aa6e171 100644
--- a/common/x509.c
+++ b/trust/x509.c
diff --git a/common/x509.h b/trust/x509.h
index af91c28..af91c28 100644
--- a/common/x509.h
+++ b/trust/x509.h