summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-02-08 13:13:49 +0000
committerSimon Josefsson <simon@josefsson.org>2006-02-08 13:13:49 +0000
commit51f46f895b3e5e07157331e80cdff1f330b9f432 (patch)
treeb50b95a291e9c0e032ff74cc922a6b0a80dc7454 /tests
parentf67a71f50b2981268257bc59a02c7b07eb118446 (diff)
downloadgnutls-51f46f895b3e5e07157331e80cdff1f330b9f432.tar.gz
Add.
Diffstat (limited to 'tests')
-rw-r--r--tests/certder.c185
1 files changed, 185 insertions, 0 deletions
diff --git a/tests/certder.c b/tests/certder.c
new file mode 100644
index 0000000000..a2acc36c84
--- /dev/null
+++ b/tests/certder.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2006 Free Software Foundation
+ *
+ * Author: Simon Josefsson
+ *
+ * This file is part of GNUTLS.
+ *
+ * GNUTLS is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GNUTLS is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNUTLS; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gnutls/gnutls.h>
+#include <gnutls/x509.h>
+#include "utils.h"
+
+void
+doit (void)
+{
+ int ret;
+ unsigned char der[] = {
+ 0x30, 0x82, 0x04, 0x10, 0x30, 0x82, 0x03, 0x79,
+ 0xa0, 0x07, 0x02, 0x84, 0x90, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
+ 0x04, 0x05, 0x00, 0x30, 0x81, 0xbb, 0x31, 0x0b,
+ 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
+ 0x02, 0x2d, 0x2d, 0x31, 0x12, 0x30, 0x10, 0x06,
+ 0x03, 0x55, 0x04, 0x08, 0x13, 0x09, 0x53, 0x6f,
+ 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31,
+ 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07,
+ 0x13, 0x08, 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69,
+ 0x74, 0x79, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03,
+ 0x55, 0x04, 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d,
+ 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a,
+ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30,
+ 0x1d, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16,
+ 0x53, 0x6f, 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61,
+ 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e,
+ 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
+ 0x15, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f,
+ 0x73, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x31, 0x29,
+ 0x30, 0x27, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x1a, 0x72,
+ 0x6f, 0x6f, 0x74, 0x40, 0x6c, 0x6f, 0x63, 0x61,
+ 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x6c, 0x6f,
+ 0x63, 0x61, 0x6c, 0x64, 0x6f, 0x6d, 0x61, 0x69,
+ 0x6e, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x34, 0x30,
+ 0x32, 0x31, 0x38, 0x32, 0x30, 0x30, 0x32, 0x33,
+ 0x34, 0x5a, 0x17, 0x0d, 0x30, 0x35, 0x31, 0x31,
+ 0x31, 0x37, 0x32, 0x30, 0x30, 0x32, 0x33, 0x34,
+ 0x5a, 0x30, 0x81, 0xbb, 0x31, 0x0b, 0x30, 0x09,
+ 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x2d,
+ 0x2d, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55,
+ 0x04, 0x08, 0x13, 0x09, 0x53, 0x6f, 0x6d, 0x65,
+ 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x11, 0x30,
+ 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x08,
+ 0x53, 0x6f, 0x6d, 0x65, 0x43, 0x69, 0x74, 0x79,
+ 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04,
+ 0x0a, 0x13, 0x10, 0x53, 0x6f, 0x6d, 0x65, 0x4f,
+ 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x31, 0x1f, 0x30, 0x1d, 0x06,
+ 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16, 0x53, 0x6f,
+ 0x6d, 0x65, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
+ 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
+ 0x55, 0x6e, 0x69, 0x74, 0x31, 0x1e, 0x30, 0x1c,
+ 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x15, 0x6c,
+ 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 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65, 0x41, 0xea, 0x0e, 0x46, 0x08, 0x6c,
+ 0x2f, 0xd5, 0xa7, 0xe4, 0x29, 0xd7, 0x3f, 0x18,
+ 0x16, 0xd7, 0x4b, 0x6f, 0x9d, 0xc0, 0x5b, 0xbf,
+ 0x68, 0x7b, 0x2e, 0x66, 0xa5, 0x1b, 0xfd, 0xff,
+ 0x09, 0x25, 0xa5, 0x56, 0x37, 0x41, 0xd8, 0xaf,
+ 0x07, 0xa6, 0x12, 0xa8, 0x58, 0xc4, 0x42, 0x9c,
+ 0xce, 0x90, 0x6a, 0x9e, 0x7e, 0x04, 0x27, 0xe3,
+ 0xfa, 0x8e, 0xe5, 0xdc, 0xa8, 0x5a, 0xf7, 0xc9,
+ 0x0d, 0x23, 0x56, 0x8e, 0x46, 0x84, 0xe8, 0x34,
+ 0x83, 0x86, 0xca, 0xc1, 0xcd, 0xfe, 0x68, 0x00,
+ 0x67, 0x3f, 0x24, 0x3b, 0x50, 0x63, 0x21, 0x7f,
+ 0xba, 0xc6, 0xdb, 0xff, 0xf4, 0x3a, 0x10, 0xb6,
+ 0xb5, 0x09, 0x4d, 0x41, 0xff, 0xef, 0xc0, 0x84,
+ 0x48, 0x1b, 0x51, 0x87, 0xe6, 0x85, 0xf0, 0x1e,
+ 0xbd, 0x99, 0x0d, 0xd3, 0x98, 0xd0, 0xab, 0xd8,
+ 0x30, 0x2a, 0xd5, 0x74 };
+ gnutls_datum_t derCert = { der, 1044 };
+ gnutls_x509_crt_t cert;
+
+ ret = gnutls_global_init ();
+ if (ret < 0)
+ fail ("init %d\n", ret);
+
+ ret = gnutls_x509_crt_init (&cert);
+ if (ret < 0)
+ fail ("crt_init %d\n", ret);
+
+ ret = gnutls_x509_crt_import (cert, &derCert, GNUTLS_X509_FMT_DER);
+ if (ret != GNUTLS_E_ASN1_DER_ERROR)
+ fail ("crt_import %d\n", ret);
+
+ success ("done");
+
+ gnutls_x509_crt_deinit (cert);
+}