|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2017-2018 Red Hat, Inc.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: 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 |
#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 |
int main()
|
|
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 <netinet/in.h>
|
|
Packit Service |
4684c1 |
#include <sys/socket.h>
|
|
Packit Service |
4684c1 |
#include <sys/wait.h>
|
|
Packit Service |
4684c1 |
#include <arpa/inet.h>
|
|
Packit Service |
4684c1 |
#include <unistd.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/dtls.h>
|
|
Packit Service |
4684c1 |
#include <signal.h>
|
|
Packit Service |
4684c1 |
#include <assert.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "cert-common.h"
|
|
Packit Service |
4684c1 |
#include "tls13/ext-parse.h"
|
|
Packit Service |
4684c1 |
#include "utils.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define MAX_AUTHS 4
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* This program tests whether the Post Handshake Auth would work
|
|
Packit Service |
4684c1 |
* under PSK authentication. */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void server_log_func(int level, const char *str)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
fprintf(stderr, "server|<%d>| %s", level, str);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void client_log_func(int level, const char *str)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
fprintf(stderr, "client|<%d>| %s", level, str);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define MAX_BUF 1024
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void client(int fd, unsigned send_cert, unsigned max_auths)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t x509_cred;
|
|
Packit Service |
4684c1 |
gnutls_psk_client_credentials_t pskcred;
|
|
Packit Service |
4684c1 |
const gnutls_datum_t key = { (void *) "DEADBEEF", 8 };
|
|
Packit Service |
4684c1 |
gnutls_session_t session;
|
|
Packit Service |
4684c1 |
char buf[64];
|
|
Packit Service |
4684c1 |
unsigned i;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
global_init();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug) {
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_function(client_log_func);
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_level(7);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_psk_allocate_client_credentials(&pskcred)>=0);
|
|
Packit Service |
4684c1 |
assert(gnutls_psk_set_client_credentials(pskcred, "test", &key,
|
|
Packit Service |
4684c1 |
GNUTLS_PSK_KEY_HEX)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_allocate_credentials(&x509_cred)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Initialize TLS session
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
assert(gnutls_init(&session, GNUTLS_CLIENT|GNUTLS_POST_HANDSHAKE_AUTH)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_timeout(session, 20 * 1000);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_priority_set_direct(session, "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:+VERS-TLS1.0:+ECDHE-PSK:+PSK", NULL);
|
|
Packit Service |
4684c1 |
if (ret < 0)
|
|
Packit Service |
4684c1 |
fail("cannot set TLS 1.3 priorities\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (send_cert) {
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_set_x509_key_mem(x509_cred, &cli_ca3_cert,
|
|
Packit Service |
4684c1 |
&cli_ca3_key,
|
|
Packit Service |
4684c1 |
GNUTLS_X509_FMT_PEM)>=0);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_PSK, pskcred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_transport_set_int(session, fd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Perform the TLS handshake
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_handshake(session);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret != 0)
|
|
Packit Service |
4684c1 |
fail("handshake failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("client handshake completed\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_kx_get(session) == GNUTLS_KX_ECDHE_PSK);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_record_set_timeout(session, 20 * 1000);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i=0;i
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("waiting for post-handshake auth request\n");
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_recv(session, buf, sizeof(buf));
|
|
Packit Service |
4684c1 |
} while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret != GNUTLS_E_REAUTH_REQUEST) {
|
|
Packit Service |
4684c1 |
fail("recv: unexpected error: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("received reauth request\n");
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_reauth(session, 0);
|
|
Packit Service |
4684c1 |
} while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret != 0)
|
|
Packit Service |
4684c1 |
fail("client: gnutls_reauth did not succeed as expected: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
close(fd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(x509_cred);
|
|
Packit Service |
4684c1 |
gnutls_psk_free_client_credentials(pskcred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static unsigned client_hello_ok = 0;
|
|
Packit Service |
4684c1 |
static unsigned server_hello_ok = 0;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define TLS_EXT_POST_HANDSHAKE 49
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void parse_ext(void *priv, gnutls_datum_t *msg)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (msg->size != 0) {
|
|
Packit Service |
4684c1 |
fail("error in extension length: %d\n", (int)msg->size);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int hellos_callback(gnutls_session_t session, unsigned int htype,
|
|
Packit Service |
4684c1 |
unsigned post, unsigned int incoming, const gnutls_datum_t *msg)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (htype == GNUTLS_HANDSHAKE_SERVER_HELLO && post == GNUTLS_HOOK_POST) {
|
|
Packit Service |
4684c1 |
if (find_server_extension(msg, TLS_EXT_POST_HANDSHAKE, NULL, NULL)) {
|
|
Packit Service |
4684c1 |
fail("Post handshake extension seen in server hello!\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
server_hello_ok = 1;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return GNUTLS_E_INTERRUPTED;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO || post != GNUTLS_HOOK_PRE)
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (find_client_extension(msg, TLS_EXT_POST_HANDSHAKE, NULL, parse_ext))
|
|
Packit Service |
4684c1 |
client_hello_ok = 1;
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
fail("Post handshake extension NOT seen in client hello!\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int
|
|
Packit Service |
4684c1 |
pskfunc(gnutls_session_t session, const char *username,
|
|
Packit Service |
4684c1 |
gnutls_datum_t * key)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
printf("psk: username %s\n", username);
|
|
Packit Service |
4684c1 |
key->data = gnutls_malloc(4);
|
|
Packit Service |
4684c1 |
key->data[0] = 0xDE;
|
|
Packit Service |
4684c1 |
key->data[1] = 0xAD;
|
|
Packit Service |
4684c1 |
key->data[2] = 0xBE;
|
|
Packit Service |
4684c1 |
key->data[3] = 0xEF;
|
|
Packit Service |
4684c1 |
key->size = 4;
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void server(int fd, int err, int type, unsigned max_auths)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
char buffer[MAX_BUF + 1];
|
|
Packit Service |
4684c1 |
gnutls_session_t session;
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t x509_cred;
|
|
Packit Service |
4684c1 |
gnutls_psk_server_credentials_t server_pskcred;
|
|
Packit Service |
4684c1 |
unsigned i;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* this must be called once in the program
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
global_init();
|
|
Packit Service |
4684c1 |
memset(buffer, 0, sizeof(buffer));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug) {
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_function(server_log_func);
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_level(6);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_psk_allocate_server_credentials(&server_pskcred)>=0);
|
|
Packit Service |
4684c1 |
gnutls_psk_set_server_credentials_function(server_pskcred,
|
|
Packit Service |
4684c1 |
pskfunc);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_allocate_credentials(&x509_cred)>=0);
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
|
|
Packit Service |
4684c1 |
&server_key,
|
|
Packit Service |
4684c1 |
GNUTLS_X509_FMT_PEM) >= 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_init(&session, GNUTLS_SERVER|GNUTLS_POST_HANDSHAKE_AUTH)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_timeout(session, 20 * 1000);
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_hook_function(session, GNUTLS_HANDSHAKE_ANY,
|
|
Packit Service |
4684c1 |
GNUTLS_HOOK_BOTH,
|
|
Packit Service |
4684c1 |
hellos_callback);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_priority_set_direct(session, "NORMAL:-VERS-ALL:+VERS-TLS1.3:+PSK:+ECDHE-PSK", NULL)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_PSK, server_pskcred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_transport_set_int(session, fd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_handshake(session);
|
|
Packit Service |
4684c1 |
} while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret != 0)
|
|
Packit Service |
4684c1 |
fail("handshake failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (!(gnutls_session_get_flags(session) & GNUTLS_SFLAGS_POST_HANDSHAKE_AUTH)) {
|
|
Packit Service |
4684c1 |
fail("server: session flags did not contain GNUTLS_SFLAGS_POST_HANDSHAKE_AUTH\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (client_hello_ok == 0) {
|
|
Packit Service |
4684c1 |
fail("server: did not verify the client hello\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (server_hello_ok == 0) {
|
|
Packit Service |
4684c1 |
fail("server: did not verify the server hello contents\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server handshake completed\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
|
|
Packit Service |
4684c1 |
gnutls_certificate_server_set_request(session, type);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i=0;i
|
|
Packit Service |
4684c1 |
/* ask peer for re-authentication */
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_reauth(session, 0);
|
|
Packit Service |
4684c1 |
} while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (err) {
|
|
Packit Service |
4684c1 |
if (ret != err)
|
|
Packit Service |
4684c1 |
fail("server: expected error %s, got: %s\n", gnutls_strerror(err),
|
|
Packit Service |
4684c1 |
gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
} else if (ret != 0) {
|
|
Packit Service |
4684c1 |
fail("server: gnutls_reauth did not succeed as expected: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: sent post-handshake auth request\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
close(fd);
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(x509_cred);
|
|
Packit Service |
4684c1 |
gnutls_psk_free_server_credentials(server_pskcred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: client/server hello were verified\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void ch_handler(int sig)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int status = 0;
|
|
Packit Service |
4684c1 |
wait(&status);
|
|
Packit Service |
4684c1 |
check_wait_status(status);
|
|
Packit Service |
4684c1 |
return;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static
|
|
Packit Service |
4684c1 |
void start(const char *name, int err, int type, unsigned max_auths, unsigned send_cert)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int fd[2];
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
pid_t child;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
success("testing %s\n", name);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
client_hello_ok = 0;
|
|
Packit Service |
4684c1 |
server_hello_ok = 0;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
signal(SIGCHLD, ch_handler);
|
|
Packit Service |
4684c1 |
signal(SIGPIPE, SIG_IGN);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
perror("socketpair");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
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 |
fail("fork");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (child) {
|
|
Packit Service |
4684c1 |
/* parent */
|
|
Packit Service |
4684c1 |
close(fd[1]);
|
|
Packit Service |
4684c1 |
server(fd[0], err, type, max_auths);
|
|
Packit Service |
4684c1 |
kill(child, SIGTERM);
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
close(fd[0]);
|
|
Packit Service |
4684c1 |
client(fd[1], send_cert, max_auths);
|
|
Packit Service |
4684c1 |
exit(0);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void doit(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
start("multi-reauth", 0, GNUTLS_CERT_REQUIRE, MAX_AUTHS, 1);
|
|
Packit Service |
4684c1 |
start("reauth-require with no-cert", GNUTLS_E_CERTIFICATE_REQUIRED, GNUTLS_CERT_REQUIRE, 1, 0);
|
|
Packit Service |
4684c1 |
start("reauth-request with no-cert", 0, GNUTLS_CERT_REQUEST, 1, 0);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif /* _WIN32 */
|