diff options
Diffstat (limited to '')
-rw-r--r-- | tests/pcert-list.c | 368 |
1 files changed, 368 insertions, 0 deletions
diff --git a/tests/pcert-list.c b/tests/pcert-list.c new file mode 100644 index 0000000..5502b70 --- /dev/null +++ b/tests/pcert-list.c @@ -0,0 +1,368 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * Author: Nikos Mavrogiannopoulos + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <gnutls/gnutls.h> +#include <gnutls/abstract.h> +#include <gnutls/x509.h> +#include "utils.h" + +/* This tests functions related to pcert-lists + */ + +#define CERT0 \ +"-----BEGIN CERTIFICATE-----\n" \ +"MIIEITCCAomgAwIBAgIMVsXM+TCHHodT4TxYMA0GCSqGSIb3DQEBCwUAMA8xDTAL\n" \ +"BgNVBAMTBENBLTIwIBcNMTYwMjE4MTM1NDAxWhgPOTk5OTEyMzEyMzU5NTlaMBMx\n" \ +"ETAPBgNVBAMTCHNlcnZlci0zMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKC\n" \ +"AYEAs6z83Jg9XjIuBb87zm6uuBjGG+45IpSw6gRgU/1izgBUofefrkdvjhpneBYU\n" \ +"7PySNxTcyKUe1ZijKAYwck5jE76Y/xKNdMffgYqXOusCij7xutssdtvYw7yJjUHv\n" \ +"43+zqbydONRNebO8qw1/BGXzKCsAE83iY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k2WCxhFrN3\n" +"n6JZgI2aUWin2OL1VA1hfddAPUSHOCV8nP/Vu1f/BEaeQjEVS2AOF7T+eQSTNQtN\n" +"MkTTi0UKKXZjIIXiW4YXDs2b22JIOXkL9rFyrvN4vvbIp/jwLWx5UTHFtsktMkai\n" +"MteJBobd69ra7kdX43EkUKrgSDNpMQn10y3w4ziPDsLZ9sWaRxESbXWqDn4A7J9t\n" +"prfxut+s/3rsZgpt4s2FsswymfuW8DhzH1EjfV1Tb32blpgz/40sIRbU158Wh1UH\n" +"/DGQ6RVX0RcRt7ce7QCYTROD/yHYPVucqLfRpVNJ3oujGYaMgnSSuxEOsfwx5u+P\n" +"8USIxyQNR9cX/gQswzs3Ouj1rXBnjiSS1YXWZXvqHsUamJ8O7qpnqkL2Ti64O0HA\n" +"wdTtAcDO0BTHvanKZojLZm8nStvTvFpSVh7z+8Fu0A5zAcHsDj4vLABsdPDsXUTr\n" +"kb2G3Yy/UA==\n" +"-----END CERTIFICATE-----\n"; + +const gnutls_datum_t server_cert = { server_cert_pem, + sizeof(server_cert_pem) +}; + +static unsigned char unsorted_server_cert_pem[] = +CERT0 +"-----BEGIN CERTIFICATE-----\n" +"MIIEFDCCAnygAwIBAgIBATANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRDQS0w\n" +"MCAXDTE2MDIxODEzNTQwMVoYDzk5OTkxMjMxMjM1OTU5WjAPMQ0wCwYDVQQDEwRD\n" +"QS0xMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0QG/LnrMV5vsE3G7\n" +"mGVYr33PFQ/WojwKg1C8GGH9aaIn+VMuBS2d1/mwtM9axoje1uQzwKp/hPT+N3Z3\n" +"qmFWeX8somDwowNDWN3skST4ob/M4aSlfP6OhNeIfBNvPTz3GtsbOtN5TkOX7Nf2\n" +"+mfFm09xMHQ3z4yyGNmKG/oxGKY2WDe93hp0rlIZ6ihMPcsCHwWLfja3SAT4AcXs\n" +"TFrTxEnaTYuVxcRc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w1M2dSTW9RJLzUF3fXYOsuh32qMel9IzhnVh8Veyl0I0WL\n" +"hThmkF73mGWcVq4lMPXwEnwYJtRLeH5HWvG3rgmb7m827XMNnqKE0NOkPH63OUqJ\n" +"0h4b6PBb6wiOgnsC3yZIf0KgB0gToySvmD6MyJsmbN9rQit1AgMBAAGjeTB3MA8G\n" +"A1UdEwEB/wQFMAMBAf8wEwYDVR0lBAwwCgYIKwYBBQUHAwkwDwYDVR0PAQH/BAUD\n" +"AwcEADAdBgNVHQ4EFgQUUZGvUEIirQAeYHn21QGyCEyO/P8wHwYDVR0jBBgwFoAU\n" +"v9x1k1GrVS0yXKvMzD7k/zInm9gwDQYJKoZIhvcNAQELBQADggGBAIwUNzAo7Efm\n" +"X8dVGz6OEsfZ/RPIeYxZ5cmqWwcZ4oLBv55xGJNG+nIcgLMA2L6ybtFiK2nKtqy4\n" +"hMv/P6qvjX5vVQGVgLclvMkDkmXWVdqkTYDX7cSe/Bv6qIS2KBaVo87r2DIWN8Zu\n" +"J3w0U3RcD6ilXVmqvARLeKWBPrCep0DJvg/BEAFSjCgHImrpZdzm6NuUr1eYCfgN\n" +"HPwUj5Ivyy9ioPRXGzzHQH6T1p/xIRbuhqTGRUin3MqGQlFseBJ2qXPf6uQmCaWZ\n" +"tFp4oWLJThqVmlvHViPDy235roYSKkJXH4qxjbhuv0pgUZOzmSsG7YA/oYNGDm6I\n" +"bEvids1r45PjYDHctB4QLhXNY3SJVgMog1KuVCK6JQL8F8XP5Sup1qW4ed/WvXwe\n" +"PBTOWbE/ENnxF2/nQLwnr80cgVx8rAE5sxubNNQVHu/6NonPzGUhTHXmGleuXPbb\n" +"Mjv4x9s3QftWUVJb7b8GUt5bMAthqo7Y47Jed1kKIt2PAm0SNBMYrw==\n" +"-----END CERTIFICATE-----\n"; + +const gnutls_datum_t unsorted_server_cert = { unsorted_server_cert_pem, + sizeof(unsorted_server_cert_pem) +}; + +const gnutls_datum_t single_server_cert = { server_cert_pem, + sizeof(CERT0)-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Vu1f/BEaeQjEVS2AOF7T+eQSTNQtN\n" +"MkTTi0UKKXZjIIXiW4YXDs2b22JIOXkL9rFyrvN4vvbIp/jwLWx5UTHFtsktMkai\n" +"MteJBobd69ra7kdX43EkUKrgSDNpMQn10y3w4ziPDsLZ9sWaRxESbXWqDn4A7J9t\n" +"prfxut+s/3rsZgpt4s2FsswymfuW8DhzH1EjfV1Tb32blpgz/40sIRbU158Wh1UH\n" +"/DGQ6RVX0RcRt7ce7QCYTROD/yHYPVucqLfRpVNJ3oujGYaMgnSSuxEOsfwx5u+P\n" +"8USIxyQNR9cX/gQswzs3Ouj1rXBnjiSS1YXWZXvqHsUamJ8O7qpnqkL2Ti64O0HA\n" +"wdTtAcDO0BTHvanKZojLZm8nStvTvFpSVh7z+8Fu0A5zAcHsDj4vLABsdPDsXUTr\n" +"kb2G3Yy/UA==\n" +"-----END CERTIFICATE-----\n"; + +const gnutls_datum_t isolated_server_cert = { isolated_server_cert_pem, + sizeof(isolated_server_cert_pem) +}; + +void doit(void) +{ + gnutls_pcert_st pcert_list[16]; + unsigned pcert_list_size, flags, i; + int ret; + + flags = GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED; + + pcert_list_size = 3; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) { + fail("the GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED was not considered\n"); + } + + pcert_list_size = 3; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &server_cert, GNUTLS_X509_FMT_PEM, 0); + if (ret < 0) { + fail("the normal/smaller import has failed\n"); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + + pcert_list_size = 16; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &server_cert, GNUTLS_X509_FMT_PEM, 0); + if (ret != 0 || pcert_list_size != 4) { + fail("the normal import failed\n"); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + + pcert_list_size = 16; + flags = GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret != 0 || pcert_list_size != 4) { + fail("the fail if unsorted import failed\n"); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + + pcert_list_size = 16; + flags = GNUTLS_X509_CRT_LIST_SORT; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret != 0 || pcert_list_size != 4) { + fail("the list sort import failed\n"); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + + pcert_list_size = 16; + flags = GNUTLS_X509_CRT_LIST_SORT|GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret != 0 || pcert_list_size != 4) { + fail("the combined import failed\n"); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + /* try the unsorted list */ + pcert_list_size = 16; + flags = GNUTLS_X509_CRT_LIST_SORT|GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &unsorted_server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret < 0 || pcert_list_size != 4) { + fail("the combined import failed for the unsorted list (%d): %s\n", pcert_list_size, gnutls_strerror(ret)); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + /* try the single cert list */ + pcert_list_size = 16; + flags = GNUTLS_X509_CRT_LIST_SORT|GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &single_server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret < 0 || pcert_list_size != 1) { + fail("the combined import failed for the single cert (%d): %s\n", pcert_list_size, gnutls_strerror(ret)); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + /* try the single final cert list */ + pcert_list_size = 16; + flags = GNUTLS_X509_CRT_LIST_SORT|GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED; + ret = gnutls_pcert_list_import_x509_raw(pcert_list, &pcert_list_size, + &isolated_server_cert, GNUTLS_X509_FMT_PEM, flags); + if (ret < 0 || pcert_list_size != 1) { + fail("the combined import failed for the isolated cert (%d): %s\n", pcert_list_size, gnutls_strerror(ret)); + } + + for (i=0;i<pcert_list_size;i++) + gnutls_pcert_deinit(&pcert_list[i]); + + success("all ok\n"); +} |