|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: Thierry Quemerais, Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
* under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
* along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* This program tests whether an extension is exchanged when registered
|
|
Packit Service |
4684c1 |
* at the session level */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if defined(_WIN32)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* socketpair isn't supported on Win32. */
|
|
Packit Service |
4684c1 |
int main(int argc, char **argv)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
exit(77);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#else
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <sys/types.h>
|
|
Packit Service |
4684c1 |
#include <sys/socket.h>
|
|
Packit Service |
4684c1 |
#if !defined(_WIN32)
|
|
Packit Service |
4684c1 |
#include <sys/wait.h>
|
|
Packit Service |
4684c1 |
#include <signal.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <unistd.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include <assert.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "utils.h"
|
|
Packit Service |
4684c1 |
#include "cert-common.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
const char *side = "";
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void tls_log_func(int level, const char *str)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
fprintf(stderr, "%s|<%d>| %s", side, level, str);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define TLSEXT_TYPE_SAMPLE 0xF1
|
|
Packit Service |
4684c1 |
#define TLSEXT_TYPE_IGN 0xF2
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int TLSEXT_TYPE_client_sent = 0;
|
|
Packit Service |
4684c1 |
static int TLSEXT_TYPE_client_received = 0;
|
|
Packit Service |
4684c1 |
static int TLSEXT_TYPE_server_sent = 0;
|
|
Packit Service |
4684c1 |
static int TLSEXT_TYPE_server_received = 0;
|
|
Packit Service |
4684c1 |
static int ign_extension_called = 0;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void reset_vars(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_client_sent = 0;
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_client_received = 0;
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_server_sent = 0;
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_server_received = 0;
|
|
Packit Service |
4684c1 |
ign_extension_called = 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static const unsigned char ext_data[] =
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
0xFE,
|
|
Packit Service |
4684c1 |
0xED
|
|
Packit Service |
4684c1 |
};
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define myfail(fmt, ...) \
|
|
Packit Service |
4684c1 |
fail("%s: "fmt, name, ##__VA_ARGS__)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int ext_recv_client_params(gnutls_session_t session, const unsigned char *buf, size_t buflen)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
const char *name;
|
|
Packit Service |
4684c1 |
name = gnutls_session_get_ptr(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (buflen != sizeof(ext_data))
|
|
Packit Service |
4684c1 |
myfail("ext_recv_client_params: Invalid input buffer length\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (memcmp(buf, ext_data, sizeof(ext_data)) != 0)
|
|
Packit Service |
4684c1 |
myfail("ext_recv_client_params: Invalid input buffer data\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_client_received = 1;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_ext_set_data(session, TLSEXT_TYPE_SAMPLE, session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0; //Success
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int ext_send_client_params(gnutls_session_t session, gnutls_buffer_t extdata)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_client_sent = 1;
|
|
Packit Service |
4684c1 |
gnutls_buffer_append_data(extdata, ext_data, sizeof(ext_data));
|
|
Packit Service |
4684c1 |
return sizeof(ext_data);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int ext_recv_client_ign_params(gnutls_session_t session, const unsigned char *buf, size_t buflen)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int ext_send_client_ign_params(gnutls_session_t session, gnutls_buffer_t extdata)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
ign_extension_called = 1;
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int ext_recv_server_params(gnutls_session_t session, const unsigned char *buf, size_t buflen)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
const char *name;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
name = gnutls_session_get_ptr(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (buflen != sizeof(ext_data))
|
|
Packit Service |
4684c1 |
myfail("ext_recv_server_params: Invalid input buffer length\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (memcmp(buf, ext_data, sizeof(ext_data)) != 0)
|
|
Packit Service |
4684c1 |
myfail("ext_recv_server_params: Invalid input buffer data\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_server_received = 1;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0; //Success
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int ext_send_server_params(gnutls_session_t session, gnutls_buffer_t extdata)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
TLSEXT_TYPE_server_sent = 1;
|
|
Packit Service |
4684c1 |
gnutls_buffer_append_data(extdata, ext_data, sizeof(ext_data));
|
|
Packit Service |
4684c1 |
return sizeof(ext_data);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void client(int sd, const char *name, const char *prio, unsigned flags, unsigned expected_ok)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
gnutls_session_t session;
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t clientx509cred;
|
|
Packit Service |
4684c1 |
const char *ext_name;
|
|
Packit Service |
4684c1 |
void *p;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
side = "client";
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_allocate_credentials(&clientx509cred) >= 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Initialize TLS session
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
assert(gnutls_init(&session, GNUTLS_CLIENT) >= 0);
|
|
Packit Service |
4684c1 |
gnutls_session_set_ptr(session, (void*)name);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Use default priorities */
|
|
Packit Service |
4684c1 |
assert(gnutls_priority_set_direct(session, prio,
|
|
Packit Service |
4684c1 |
NULL)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* put the anonymous credentials to the current session
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
|
|
Packit Service |
4684c1 |
clientx509cred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_transport_set_int(session, sd);
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_timeout(session, 20 * 1000);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_session_ext_register(session, "ext_ign", TLSEXT_TYPE_IGN, GNUTLS_EXT_TLS, ext_recv_client_ign_params, ext_send_client_ign_params, NULL, NULL, NULL, flags);
|
|
Packit Service |
4684c1 |
if (ret < 0)
|
|
Packit Service |
4684c1 |
myfail("client: register extension\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ext_name = gnutls_ext_get_name2(session, TLSEXT_TYPE_IGN, GNUTLS_EXT_ANY);
|
|
Packit Service |
4684c1 |
if (ext_name == NULL || strcmp(ext_name, "ext_ign"))
|
|
Packit Service |
4684c1 |
myfail("client: retrieve name of extension %u\n", TLSEXT_TYPE_IGN);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ext_name = gnutls_ext_get_name2(session, TLSEXT_TYPE_IGN, GNUTLS_EXT_APPLICATION);
|
|
Packit Service |
4684c1 |
if (ext_name)
|
|
Packit Service |
4684c1 |
myfail("client: retrieve name of extension %u (expected none)\n", TLSEXT_TYPE_IGN);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_session_ext_register(session, "ext_client", TLSEXT_TYPE_SAMPLE, GNUTLS_EXT_TLS, ext_recv_client_params, ext_send_client_params, NULL, NULL, NULL, flags);
|
|
Packit Service |
4684c1 |
if (ret < 0)
|
|
Packit Service |
4684c1 |
myfail("client: register extension\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Perform the TLS handshake
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
ret = gnutls_handshake(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
if (!expected_ok) {
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("client: handshake failed as expected: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
myfail("client: Handshake failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
goto end;
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("client: Handshake was completed\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (TLSEXT_TYPE_client_sent != 1 || TLSEXT_TYPE_client_received != 1) {
|
|
Packit Service |
4684c1 |
if (expected_ok) {
|
|
Packit Service |
4684c1 |
myfail("client: extension not properly sent/received\n");
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
goto end;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_ext_get_data(session, TLSEXT_TYPE_SAMPLE, &p);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
myfail("gnutls_ext_get_data: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (p != session) {
|
|
Packit Service |
4684c1 |
myfail("client: gnutls_ext_get_data failed\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ign_extension_called == 0) {
|
|
Packit Service |
4684c1 |
myfail("registered ign extension was not called\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_bye(session, GNUTLS_SHUT_RDWR);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (!expected_ok)
|
|
Packit Service |
4684c1 |
myfail("client: expected failure but succeeded!\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
end:
|
|
Packit Service |
4684c1 |
close(sd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(clientx509cred);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void server(int sd, const char *name, const char *prio, unsigned flags, unsigned expected_ok)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t serverx509cred;
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
gnutls_session_t session;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
side = "server";
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_allocate_credentials(&serverx509cred)>=0);
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_set_x509_key_mem(serverx509cred,
|
|
Packit Service |
4684c1 |
&server_cert, &server_key,
|
|
Packit Service |
4684c1 |
GNUTLS_X509_FMT_PEM) >= 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_init(&session, GNUTLS_SERVER) >= 0);
|
|
Packit Service |
4684c1 |
gnutls_session_set_ptr(session, (void*)name);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* avoid calling all the priority functions, since the defaults
|
|
Packit Service |
4684c1 |
* are adequate.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
assert(gnutls_priority_set_direct(session, prio,
|
|
Packit Service |
4684c1 |
NULL) >= 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
|
|
Packit Service |
4684c1 |
serverx509cred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_session_ext_register(session, "ext_server", TLSEXT_TYPE_SAMPLE, GNUTLS_EXT_TLS, ext_recv_server_params, ext_send_server_params, NULL, NULL, NULL, flags) >= 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_transport_set_int(session, sd);
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_timeout(session, 20 * 1000);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_handshake(session);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
if (!expected_ok) {
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: handshake failed as expected: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
goto cleanup;
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
close(sd);
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
myfail("server: Handshake has failed (%s)\n",
|
|
Packit Service |
4684c1 |
gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
return;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: Handshake was completed\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (TLSEXT_TYPE_server_sent != 1 || TLSEXT_TYPE_server_received != 1) {
|
|
Packit Service |
4684c1 |
if (expected_ok)
|
|
Packit Service |
4684c1 |
myfail("server: extension not properly sent/received\n");
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
goto cleanup;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* do not wait for the peer to close the connection.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
gnutls_bye(session, GNUTLS_SHUT_WR);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (!expected_ok)
|
|
Packit Service |
4684c1 |
myfail("server: expected failure but succeeded!\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
cleanup:
|
|
Packit Service |
4684c1 |
close(sd);
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(serverx509cred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: finished\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define try_common(name, prio, flags, sok, cok) \
|
|
Packit Service |
4684c1 |
try(name, prio, flags, flags, sok, cok)
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void try(const char *name, const char *prio, unsigned server_flags,
|
|
Packit Service |
4684c1 |
unsigned client_flags, unsigned server_ok, unsigned client_ok)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
pid_t child;
|
|
Packit Service |
4684c1 |
int sockets[2];
|
|
Packit Service |
4684c1 |
int err;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
success("Testing: %s: ", name);
|
|
Packit Service |
4684c1 |
reset_vars();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
|
|
Packit Service |
4684c1 |
if (err == -1) {
|
|
Packit Service |
4684c1 |
perror("socketpair");
|
|
Packit Service |
4684c1 |
myfail("socketpair failed\n");
|
|
Packit Service |
4684c1 |
return;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
child = fork();
|
|
Packit Service |
4684c1 |
if (child < 0) {
|
|
Packit Service |
4684c1 |
perror("fork");
|
|
Packit Service |
4684c1 |
myfail("fork");
|
|
Packit Service |
4684c1 |
return;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (child) {
|
|
Packit Service |
4684c1 |
int status;
|
|
Packit Service |
4684c1 |
/* parent */
|
|
Packit Service |
4684c1 |
close(sockets[1]);
|
|
Packit Service |
4684c1 |
server(sockets[0], name, prio, server_flags, server_ok);
|
|
Packit Service |
4684c1 |
wait(&status);
|
|
Packit Service |
4684c1 |
check_wait_status(status);
|
|
Packit Service |
4684c1 |
success("ok");
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
close(sockets[0]);
|
|
Packit Service |
4684c1 |
client(sockets[1], name, prio, client_flags, client_ok);
|
|
Packit Service |
4684c1 |
_exit(0);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
success("\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void doit(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned i;
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
signal(SIGPIPE, SIG_IGN);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
global_init();
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_function(tls_log_func);
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_level(5);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
try_common("TLS1.2 both ways (default)", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", 0, 1, 1);
|
|
Packit Service |
4684c1 |
try_common("TLS1.2 both ways", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", GNUTLS_EXT_FLAG_CLIENT_HELLO|GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO, 1, 1);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
try_common("TLS1.2 client only", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", GNUTLS_EXT_FLAG_CLIENT_HELLO, 0, 0);
|
|
Packit Service |
4684c1 |
try_common("TLS1.2 client and TLS 1.3 server", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", GNUTLS_EXT_FLAG_CLIENT_HELLO|GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO, 0, 0);
|
|
Packit Service |
4684c1 |
try_common("TLS1.2 server only", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO, 0, 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
try("TLS1.2 client rejects", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", GNUTLS_EXT_FLAG_CLIENT_HELLO|GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO, GNUTLS_EXT_FLAG_CLIENT_HELLO, 0, 0);
|
|
Packit Service |
4684c1 |
try("TLS1.2 never on client hello", "NORMAL:+ANON-ECDH:-VERS-TLS-ALL:+VERS-TLS1.2", GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO, GNUTLS_EXT_FLAG_CLIENT_HELLO, 0, 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* check whether we can crash the library by adding many extensions */
|
|
Packit Service |
4684c1 |
success("Testing: register many global extensions\n");
|
|
Packit Service |
4684c1 |
for (i=0;i<64;i++) {
|
|
Packit Service |
4684c1 |
ret = gnutls_ext_register("ext_serverxx", TLSEXT_TYPE_SAMPLE+i+1, GNUTLS_EXT_TLS, ext_recv_server_params, ext_send_server_params, NULL, NULL, NULL);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
success("failed registering extension no %d (expected)\n", i+1);
|
|
Packit Service |
4684c1 |
break;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#endif /* _WIN32 */
|