summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/extract-openssl.c70
-rw-r--r--tools/tests/Makefile.am7
-rw-r--r--tools/tests/test-openssl.c16
-rw-r--r--tools/tests/test-utf8.c252
-rw-r--r--tools/utf8.c328
-rw-r--r--tools/utf8.h53
6 files changed, 24 insertions, 702 deletions
diff --git a/tools/extract-openssl.c b/tools/extract-openssl.c
index e59d313..fb87cd6 100644
--- a/tools/extract-openssl.c
+++ b/tools/extract-openssl.c
@@ -59,7 +59,7 @@
/* These functions are declared with a global scope for testing */
void p11_openssl_canon_string (char *str,
- long *len);
+ size_t *len);
bool p11_openssl_canon_string_der (p11_buffer *der);
@@ -356,7 +356,7 @@ p11_extract_openssl_bundle (P11KitIter *iter,
void
p11_openssl_canon_string (char *str,
- long *len)
+ size_t *len)
{
bool nsp;
bool sp;
@@ -394,64 +394,24 @@ p11_openssl_canon_string (char *str,
bool
p11_openssl_canon_string_der (p11_buffer *der)
{
- unsigned char *input = der->data;
- int input_len = der->len;
- unsigned char *output;
- unsigned long tag;
- unsigned char cls;
- size_t conv_len;
- int tag_len;
- int len_len;
- void *octets;
- long octet_len;
+ char *string;
+ size_t length;
int output_len;
- void *conv = NULL;
+ int len_len;
+ bool unknown_string;
+ unsigned char *output;
int len;
- int ret;
-
- ret = asn1_get_tag_der (input, input_len, &cls, &tag_len, &tag);
- return_val_if_fail (ret == ASN1_SUCCESS, false);
- octet_len = asn1_get_length_der (input + tag_len, input_len - tag_len, &len_len);
- return_val_if_fail (octet_len >= 0, false);
- return_val_if_fail (tag_len + len_len + octet_len == input_len, false);
-
- octets = input + tag_len + len_len;
-
- /* The following strings are the ones we normalize */
- switch (tag) {
- case 12: /* UTF8String */
- case 18: /* NumericString */
- case 22: /* IA5String */
- case 20: /* TeletexString */
- case 19: /* PrintableString */
- if (!p11_utf8_validate (octets, octet_len))
- return false;
- break;
-
- case 28: /* UniversalString */
- octets = conv = p11_utf8_for_ucs4be (octets, octet_len, &conv_len);
- if (conv == NULL)
- return false;
- octet_len = conv_len;
- break;
-
- case 30: /* BMPString */
- octets = conv = p11_utf8_for_ucs2be (octets, octet_len, &conv_len);
- if (conv == NULL)
- return false;
- octet_len = conv_len;
- break;
+ string = p11_x509_parse_directory_string (der->data, der->len, &unknown_string, &length);
/* Just pass through all the non-string types */
- default:
- return true;
- }
+ if (string == NULL)
+ return unknown_string;
- p11_openssl_canon_string (octets, &octet_len);
+ p11_openssl_canon_string (string, &length);
- asn1_length_der (octet_len, NULL, &len_len);
- output_len = 1 + len_len + octet_len;
+ asn1_length_der (length, NULL, &len_len);
+ output_len = 1 + len_len + length;
if (!p11_buffer_reset (der, output_len))
return_val_if_reached (false);
@@ -461,10 +421,10 @@ p11_openssl_canon_string_der (p11_buffer *der)
output[0] = 12; /* UTF8String */
len = output_len - 1;
- asn1_octet_der (octets, octet_len, output + 1, &len);
+ asn1_octet_der ((unsigned char *)string, length, output + 1, &len);
assert (len == output_len - 1);
- free (conv);
+ free (string);
return true;
}
diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am
index e50836d..4239a41 100644
--- a/tools/tests/Makefile.am
+++ b/tools/tests/Makefile.am
@@ -37,7 +37,6 @@ libtestcommon_la_SOURCES = \
test.c test.h
CHECK_PROGS = \
- test-utf8 \
test-save \
test-extract \
test-x509 \
@@ -79,12 +78,6 @@ test_openssl_SOURCES = \
$(TOOLS)/extract-info.c \
$(TOOLS)/extract-openssl.c \
$(TOOLS)/save.c \
- $(TOOLS)/utf8.c \
- $(NULL)
-
-test_utf8_SOURCES = \
- test-utf8.c \
- $(TOOLS)/utf8.c \
$(NULL)
endif # WITH_ASN1
diff --git a/tools/tests/test-openssl.c b/tools/tests/test-openssl.c
index a48220d..d242b50 100644
--- a/tools/tests/test-openssl.c
+++ b/tools/tests/test-openssl.c
@@ -373,7 +373,7 @@ test_file_without (CuTest *tc)
}
/* From extract-openssl.c */
-void p11_openssl_canon_string (char *str, long *len);
+void p11_openssl_canon_string (char *str, size_t *len);
static void
test_canon_string (CuTest *tc)
@@ -392,21 +392,23 @@ test_canon_string (CuTest *tc)
};
char *str;
- long len;
- long out;
+ size_t len;
+ size_t out;
int i;
for (i = 0; i < ELEMS (fixtures); i++) {
- len = fixtures[i].input_len;
- if (len < 0)
+ if (fixtures[i].input_len < 0)
len = strlen (fixtures[i].input);
+ else
+ len = fixtures[i].input_len;
str = strndup (fixtures[i].input, len);
p11_openssl_canon_string (str, &len);
- out = fixtures[i].output_len;
- if (out < 0)
+ if (fixtures[i].output_len < 0)
out = strlen (fixtures[i].output);
+ else
+ out = fixtures[i].output_len;
CuAssertIntEquals (tc, out, len);
CuAssertStrEquals (tc, fixtures[i].output, str);
diff --git a/tools/tests/test-utf8.c b/tools/tests/test-utf8.c
deleted file mode 100644
index d34f597..0000000
--- a/tools/tests/test-utf8.c
+++ /dev/null
@@ -1,252 +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 "CuTest.h"
-
-#include "utf8.h"
-
-#include <stdio.h>
-
-#define ELEMS(x) (sizeof (x) / sizeof (x[0]))
-
-static void
-test_ucs2be (CuTest *cu)
-{
- char *output;
- size_t length;
- int i;
-
- struct {
- const char *output;
- size_t output_len;
- const unsigned char input[100];
- size_t input_len;
- } fixtures[] = {
- { "This is a test", 14,
- { 0x00, 'T', 0x00, 'h', 0x00, 'i', 0x00, 's', 0x00, ' ', 0x00, 'i', 0x00, 's', 0x00, ' ',
- 0x00, 'a', 0x00, ' ', 0x00, 't', 0x00, 'e', 0x00, 's', 0x00, 't' }, 28,
- },
- { "V\303\266gel", 6,
- { 0x00, 'V', 0x00, 0xF6, 0x00, 'g', 0x00, 'e', 0x00, 'l' }, 10,
- },
- { "M\303\244nwich \340\264\205", 12,
- { 0x00, 'M', 0x00, 0xE4, 0x00, 'n', 0x00, 'w', 0x00, 'i', 0x00, 'c', 0x00, 'h',
- 0x00, ' ', 0x0D, 0x05 }, 18,
- }
- };
-
- for (i = 0; i < ELEMS (fixtures); i++) {
- output = p11_utf8_for_ucs2be (fixtures[i].input,
- fixtures[i].input_len,
- &length);
-
- CuAssertIntEquals (cu, fixtures[i].output_len, length);
- CuAssertStrEquals (cu, fixtures[i].output, output);
- }
-}
-
-static void
-test_ucs2be_fail (CuTest *cu)
-{
- char *output;
- size_t length;
- int i;
-
- struct {
- const unsigned char input[100];
- size_t input_len;
- } fixtures[] = {
- { { 0x00, 'T', 0x00, 'h', 0x00, 'i', 0x00, }, 7 /* truncated */ }
- };
-
- for (i = 0; i < ELEMS (fixtures); i++) {
- output = p11_utf8_for_ucs2be (fixtures[i].input,
- fixtures[i].input_len,
- &length);
- CuAssertPtrEquals (cu, NULL, output);
- }
-}
-
-static void
-test_ucs4be (CuTest *cu)
-{
- char *output;
- size_t length;
- int i;
-
- struct {
- const char *output;
- size_t output_len;
- const unsigned char input[100];
- size_t input_len;
- } fixtures[] = {
- { "This is a test", 14,
- { 0x00, 0x00, 0x00, 'T',
- 0x00, 0x00, 0x00, 'h',
- 0x00, 0x00, 0x00, 'i',
- 0x00, 0x00, 0x00, 's',
- 0x00, 0x00, 0x00, ' ',
- 0x00, 0x00, 0x00, 'i',
- 0x00, 0x00, 0x00, 's',
- 0x00, 0x00, 0x00, ' ',
- 0x00, 0x00, 0x00, 'a',
- 0x00, 0x00, 0x00, ' ',
- 0x00, 0x00, 0x00, 't',
- 0x00, 0x00, 0x00, 'e',
- 0x00, 0x00, 0x00, 's',
- 0x00, 0x00, 0x00, 't',
- }, 56,
- },
- { "Fun \360\220\214\231", 8,
- { 0x00, 0x00, 0x00, 'F',
- 0x00, 0x00, 0x00, 'u',
- 0x00, 0x00, 0x00, 'n',
- 0x00, 0x00, 0x00, ' ',
- 0x00, 0x01, 0x03, 0x19, /* U+10319: looks like an antenna */
- }, 20,
- }
- };
-
- for (i = 0; i < ELEMS (fixtures); i++) {
- output = p11_utf8_for_ucs4be (fixtures[i].input,
- fixtures[i].input_len,
- &length);
-
- CuAssertIntEquals (cu, fixtures[i].output_len, length);
- CuAssertStrEquals (cu, fixtures[i].output, output);
- }
-}
-
-static void
-test_ucs4be_fail (CuTest *cu)
-{
- char *output;
- size_t length;
- int i;
-
- struct {
- const unsigned char input[100];
- size_t input_len;
- } fixtures[] = {
- { { 0x00, 0x00, 'T',
- }, 7 /* truncated */ },
- { { 0x00, 0x00, 0x00, 'F',
- 0x00, 0x00, 0x00, 'u',
- 0x00, 0x00, 0x00, 'n',
- 0x00, 0x00, 0x00, ' ',
- 0xD8, 0x00, 0xDF, 0x19,
- }, 20,
- }
- };
-
- for (i = 0; i < ELEMS (fixtures); i++) {
- output = p11_utf8_for_ucs4be (fixtures[i].input,
- fixtures[i].input_len,
- &length);
- CuAssertPtrEquals (cu, NULL, output);
- }
-}
-
-static void
-test_utf8 (CuTest *cu)
-{
- bool ret;
- int i;
-
- struct {
- const char *input;
- size_t input_len;
- } fixtures[] = {
- { "This is a test", 14 },
- { "Good news everyone", -1 },
- { "Fun \360\220\214\231", -1 },
- { "Fun invalid here: \xfe", 4 }, /* but limited length */
- { "V\303\266gel", 6, },
- };
-
- for (i = 0; i < ELEMS (fixtures); i++) {
- ret = p11_utf8_validate (fixtures[i].input,
- fixtures[i].input_len);
- CuAssertIntEquals (cu, true, ret);
- }
-}
-
-static void
-test_utf8_fail (CuTest *cu)
-{
- bool ret;
- int i;
-
- struct {
- const char *input;
- size_t input_len;
- } fixtures[] = {
- { "This is a test\x80", 15 },
- { "Good news everyone\x88", -1 },
- { "Bad \xe0v following chars should be |0x80", -1 },
- { "Truncated \xe0", -1 },
- };
-
- for (i = 0; i < ELEMS (fixtures); i++) {
- ret = p11_utf8_validate (fixtures[i].input,
- fixtures[i].input_len);
- CuAssertIntEquals (cu, false, ret);
- }
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- SUITE_ADD_TEST (suite, test_ucs2be);
- SUITE_ADD_TEST (suite, test_ucs2be_fail);
- SUITE_ADD_TEST (suite, test_ucs4be);
- SUITE_ADD_TEST (suite, test_ucs4be_fail);
- SUITE_ADD_TEST (suite, test_utf8);
- SUITE_ADD_TEST (suite, test_utf8_fail);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
-
- return ret;
-}
diff --git a/tools/utf8.c b/tools/utf8.c
deleted file mode 100644
index 5ce6889..0000000
--- a/tools/utf8.c
+++ /dev/null
@@ -1,328 +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@redhat.com>
- */
-
-#include "config.h"
-
-#include "buffer.h"
-#include "debug.h"
-#include "utf8.h"
-
-#include <assert.h>
-#include <stddef.h>
-#include <string.h>
-
-/*
- * Some parts come from FreeBSD utf8.c
- *
- * Copyright (c) 2002-2004 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-static ssize_t
-utf8_to_wchar (const char *str,
- size_t len,
- wchar_t *wc)
-{
- int ch, i, mask, want;
- wchar_t lbound, wch;
-
- assert (str != NULL);
- assert (len > 0);
- assert (wc != NULL);
-
- if (((ch = (unsigned char)*str) & ~0x7f) == 0) {
- /* Fast path for plain ASCII characters. */
- *wc = ch;
- return 1;
- }
-
- /*
- * Determine the number of octets that make up this character
- * from the first octet, and a mask that extracts the
- * interesting bits of the first octet. We already know
- * the character is at least two bytes long.
- *
- * We also specify a lower bound for the character code to
- * detect redundant, non-"shortest form" encodings. For
- * example, the sequence C0 80 is _not_ a legal representation
- * of the null character. This enforces a 1-to-1 mapping
- * between character codes and their multibyte representations.
- */
- ch = (unsigned char)*str;
- if ((ch & 0xe0) == 0xc0) {
- mask = 0x1f;
- want = 2;
- lbound = 0x80;
- } else if ((ch & 0xf0) == 0xe0) {
- mask = 0x0f;
- want = 3;
- lbound = 0x800;
- } else if ((ch & 0xf8) == 0xf0) {
- mask = 0x07;
- want = 4;
- lbound = 0x10000;
- } else if ((ch & 0xfc) == 0xf8) {
- mask = 0x03;
- want = 5;
- lbound = 0x200000;
- } else if ((ch & 0xfe) == 0xfc) {
- mask = 0x01;
- want = 6;
- lbound = 0x4000000;
- } else {
- /*
- * Malformed input; input is not UTF-8.
- */
- return -1;
- }
-
- if (want > len) {
- /* Incomplete multibyte sequence. */
- return -1;
- }
-
- /*
- * Decode the octet sequence representing the character in chunks
- * of 6 bits, most significant first.
- */
- wch = (unsigned char)*str++ & mask;
- for (i = 1; i < want; i++) {
- if ((*str & 0xc0) != 0x80) {
- /*
- * Malformed input; bad characters in the middle
- * of a character.
- */
- return -1;
- }
- wch <<= 6;
- wch |= *str++ & 0x3f;
- }
- if (wch < lbound) {
- /*
- * Malformed input; redundant encoding.
- */
- return -1;
- }
-
- *wc = wch;
- return want;
-}
-
-static size_t
-utf8_for_wchar (wchar_t wc,
- char *str,
- size_t len)
-{
- unsigned char lead;
- int i, want;
-
- assert (str != NULL);
- assert (len >= 6);
-
- if ((wc & ~0x7f) == 0) {
- /* Fast path for plain ASCII characters. */
- *str = (char)wc;
- return 1;
- }
-
- /*
- * Determine the number of octets needed to represent this character.
- * We always output the shortest sequence possible. Also specify the
- * first few bits of the first octet, which contains the information
- * about the sequence length.
- */
- if ((wc & ~0x7ff) == 0) {
- lead = 0xc0;
- want = 2;
- } else if ((wc & ~0xffff) == 0) {
- lead = 0xe0;
- want = 3;
- } else if ((wc & ~0x1fffff) == 0) {
- lead = 0xf0;
- want = 4;
- } else if ((wc & ~0x3ffffff) == 0) {
- lead = 0xf8;
- want = 5;
- } else if ((wc & ~0x7fffffff) == 0) {
- lead = 0xfc;
- want = 6;
- } else {
- return -1;
- }
-
- assert (want <= len);
-
- /*
- * Output the octets representing the character in chunks
- * of 6 bits, least significant last. The first octet is
- * a special case because it contains the sequence length
- * information.
- */
- for (i = want - 1; i > 0; i--) {
- str[i] = (wc & 0x3f) | 0x80;
- wc >>= 6;
- }
- *str = (wc & 0xff) | lead;
- return want;
-}
-
-static ssize_t
-ucs2be_to_wchar (const unsigned char *str,
- size_t len,
- wchar_t *wc)
-{
- assert (str != NULL);
- assert (len != 0);
- assert (wc != NULL);
-
- if (len < 2)
- return -1;
-
- *wc = (str[0] << 8 | str[1]);
- return 2;
-}
-
-static ssize_t
-ucs4be_to_wchar (const unsigned char *str,
- size_t len,
- wchar_t *wc)
-{
- assert (str != NULL);
- assert (len != 0);
- assert (wc != NULL);
-
- if (len < 4)
- return -1;
-
- *wc = (str[0] << 24 | str[1] << 16 | str[2] << 8 | str[3]);
- return 4;
-}
-
-bool
-p11_utf8_validate (const char *str,
- ssize_t len)
-{
- wchar_t dummy;
- ssize_t ret;
-
- if (len < 0)
- len = strlen (str);
-
- while (len > 0) {
- ret = utf8_to_wchar (str, len, &dummy);
- if (ret < 0)
- return false;
- str += ret;
- len -= ret;
- }
-
- return true;
-}
-
-static char *
-utf8_for_convert (ssize_t (* convert) (const unsigned char *, size_t, wchar_t *),
- const unsigned char *str,
- size_t num_bytes,
- size_t *ret_len)
-{
- p11_buffer buf;
- char block[6];
- wchar_t wc;
- ssize_t ret;
-
- assert (convert);
-
- if (!p11_buffer_init_null (&buf, num_bytes))
- return_val_if_reached (NULL);
-
- while (num_bytes != 0) {
- ret = (convert) (str, num_bytes, &wc);
- if (ret < 0) {
- p11_buffer_uninit (&buf);
- return NULL;
- }
-
- str += ret;
- num_bytes -= ret;
-
- ret = utf8_for_wchar (wc, block, 6);
- if (ret < 0) {
- p11_buffer_uninit (&buf);
- return NULL;
- }
- p11_buffer_add (&buf, block, ret);
- }
-
- return_val_if_fail (p11_buffer_ok (&buf), NULL);
- return p11_buffer_steal (&buf, ret_len);
-}
-
-char *
-p11_utf8_for_ucs2be (const unsigned char *str,
- size_t num_bytes,
- size_t *ret_len)
-{
- assert (str != NULL);
- return utf8_for_convert (ucs2be_to_wchar, str, num_bytes, ret_len);
-}
-
-char *
-p11_utf8_for_ucs4be (const unsigned char *str,
- size_t num_bytes,
- size_t *ret_len)
-{
- assert (str != NULL);
- return utf8_for_convert (ucs4be_to_wchar, str, num_bytes, ret_len);
-}
diff --git a/tools/utf8.h b/tools/utf8.h
deleted file mode 100644
index 8efa66f..0000000
--- a/tools/utf8.h
+++ /dev/null
@@ -1,53 +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@redhat.com>
- */
-
-#ifndef P11_UTF8_H_
-#define P11_UTF8_H_
-
-#include "compat.h"
-
-#include <sys/types.h>
-
-bool p11_utf8_validate (const char *str,
- ssize_t len);
-
-char * p11_utf8_for_ucs2be (const unsigned char *str,
- size_t num_bytes,
- size_t *ret_len);
-
-char * p11_utf8_for_ucs4be (const unsigned char *str,
- size_t num_bytes,
- size_t *ret_len);
-
-#endif /* P11_UTF8_H_ */