summaryrefslogtreecommitdiff
path: root/tests/moredn.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-07-19 13:35:13 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-07-19 14:11:16 +0200
commit122f2530098123fea2a1a93e1d3696f24488b186 (patch)
tree8a0b6e62562bec87c97e2f2e7a06f48aab0d65c7 /tests/moredn.c
parent571bebe311ba54153e68260b5a91d04a38bcae35 (diff)
downloadgnutls-122f2530098123fea2a1a93e1d3696f24488b186.tar.gz
tests: added checks for the RFC4514 decoding via gnutls_x509_dn_get_str()
Diffstat (limited to 'tests/moredn.c')
-rw-r--r--tests/moredn.c109
1 files changed, 0 insertions, 109 deletions
diff --git a/tests/moredn.c b/tests/moredn.c
deleted file mode 100644
index 528be496e4..0000000000
--- a/tests/moredn.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2008-2012 Free Software Foundation, Inc.
- *
- * Author: Joe Orton
- *
- * 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 3 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
- */
-
-/* Parts copied from GnuTLS example programs. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <gnutls/gnutls.h>
-#include <gnutls/x509.h>
-
-#include "utils.h"
-
-static const char cert_pem[] =
- "-----BEGIN CERTIFICATE-----\n"
- "MIICHjCCAYmgAwIBAgIERiYdNzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n"
- "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTI3WhcNMDgwNDE3MTMyOTI3WjAdMRsw\n"
- "GQYDVQQDExJHbnVUTFMgdGVzdCBjbGllbnQwgZwwCwYJKoZIhvcNAQEBA4GMADCB\n"
- "iAKBgLtmQ/Xyxde2jMzF3/WIO7HJS2oOoa0gUEAIgKFPXKPQ+GzP5jz37AR2ExeL\n"
- "ZIkiW8DdU3w77XwEu4C5KL6Om8aOoKUSy/VXHqLnu7czSZ/ju0quak1o/8kR4jKN\n"
- "zj2AC41179gAgY8oBAOgIo1hBAf6tjd9IQdJ0glhaZiQo1ipAgMBAAGjdjB0MAwG\n"
- "A1UdEwEB/wQCMAAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDwYDVR0PAQH/BAUDAweg\n"
- "ADAdBgNVHQ4EFgQUTLkKm/odNON+3svSBxX+odrLaJEwHwYDVR0jBBgwFoAU6Twc\n"
- "+62SbuYGpFYsouHAUyfI8pUwCwYJKoZIhvcNAQEFA4GBALujmBJVZnvaTXr9cFRJ\n"
- "jpfc/3X7sLUsMvumcDE01ls/cG5mIatmiyEU9qI3jbgUf82z23ON/acwJf875D3/\n"
- "U7jyOsBJ44SEQITbin2yUeJMIm1tievvdNXBDfW95AM507ShzP12sfiJkJfjjdhy\n"
- "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n";
-static const gnutls_datum_t cert_datum = { (unsigned char *) cert_pem,
- sizeof(cert_pem)
-};
-
-void doit(void)
-{
- gnutls_x509_crt_t cert;
- gnutls_x509_dn_t sdn, dn2;
- unsigned char buf[8192], buf2[8192];
- size_t buflen, buf2len;
- gnutls_datum_t datum;
- int rv;
-
- global_init();
-
- if (gnutls_x509_crt_init(&cert) != 0)
- fail("cert init failure\n");
-
- if (gnutls_x509_crt_import(cert, &cert_datum, GNUTLS_X509_FMT_PEM)
- != 0)
- fail("FAIL: could not import PEM cert\n");
-
- if (gnutls_x509_crt_get_subject(cert, &sdn) != 0)
- fail("FAIL: could not get subject DN.\n");
-
- buflen = sizeof buf;
- rv = gnutls_x509_dn_export(sdn, GNUTLS_X509_FMT_DER, buf, &buflen);
- if (rv != 0)
- fail("FAIL: could not export subject DN: %s\n",
- gnutls_strerror(rv));
-
- if (gnutls_x509_dn_init(&dn2) != 0)
- fail("FAIL: DN init.\n");
-
- datum.data = buf;
- datum.size = buflen;
-
- if (gnutls_x509_dn_import(dn2, &datum) != 0)
- fail("FAIL: re-import subject DN.\n");
-
- buf2len = sizeof buf2;
- rv = gnutls_x509_dn_export(dn2, GNUTLS_X509_FMT_DER, buf2,
- &buf2len);
- if (rv != 0)
- fail("FAIL: could not export subject DN: %s\n",
- gnutls_strerror(rv));
-
- if (buflen == buf2len && memcmp(buf, buf2, buflen) != 0)
- fail("FAIL: export/import/export differ.\n");
-
- gnutls_x509_dn_deinit(dn2);
-
- gnutls_x509_crt_deinit(cert);
-
- gnutls_global_deinit();
-}