summaryrefslogtreecommitdiff
path: root/tests/tls12-rehandshake-cert-3.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2018-04-16 09:51:11 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-04-16 09:51:24 +0200
commitf3bbeba99258c9e5e90630451c7005192850d718 (patch)
tree55a3f86eafeb6d5c1b089a6a460223bf09f97b8c /tests/tls12-rehandshake-cert-3.c
parenta2ee59b47d8ebf366a00be0275285bb16a435786 (diff)
downloadgnutls-f3bbeba99258c9e5e90630451c7005192850d718.tar.gz
tests: tls12-rehandshake-cert-3: run multiple rehandshake tests
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'tests/tls12-rehandshake-cert-3.c')
-rw-r--r--tests/tls12-rehandshake-cert-3.c67
1 files changed, 44 insertions, 23 deletions
diff --git a/tests/tls12-rehandshake-cert-3.c b/tests/tls12-rehandshake-cert-3.c
index b3c827cfaf..94ab1126a0 100644
--- a/tests/tls12-rehandshake-cert-3.c
+++ b/tests/tls12-rehandshake-cert-3.c
@@ -69,6 +69,7 @@ static void client_log_func(int level, const char *str)
}
#define MAX_BUF 1024
+#define MAX_REHANDSHAKES 32
static void client(int fd)
{
@@ -76,6 +77,7 @@ static void client(int fd)
char buffer[MAX_BUF + 1];
gnutls_certificate_credentials_t x509_cred;
gnutls_session_t session;
+ unsigned i;
global_init();
memset(buffer, 2, sizeof(buffer));
@@ -122,18 +124,23 @@ static void client(int fd)
gnutls_protocol_get_name
(gnutls_protocol_get_version(session)));
- ret = gnutls_handshake(session);
- if (ret != 0) {
- fail("client: error in code after rehandshake: %s\n",
- gnutls_strerror(ret));
- exit(1);
+ for (i=0;i<MAX_REHANDSHAKES;i++) {
+ do {
+ ret = gnutls_handshake(session);
+ } while(ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN);
+ if (ret != 0) {
+ fail("client: error in code after rehandshake: %s\n",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+
}
do {
do {
ret =
gnutls_record_recv(session, buffer,
- MAX_BUF);
+ MAX_BUF);
} while (ret == GNUTLS_E_AGAIN
|| ret == GNUTLS_E_INTERRUPTED);
} while (ret > 0);
@@ -170,6 +177,7 @@ static void server(int fd)
char buffer[MAX_BUF + 1];
gnutls_session_t session;
gnutls_certificate_credentials_t x509_cred;
+ unsigned tries = 0;
/* this must be called once in the program
*/
@@ -220,27 +228,40 @@ static void server(int fd)
gnutls_certificate_server_set_request(session, GNUTLS_CERT_IGNORE);
do {
+ tries++;
+
do {
- ret =
- gnutls_record_recv(session, buffer,
- MAX_BUF);
- } while (ret == GNUTLS_E_AGAIN
- || ret == GNUTLS_E_INTERRUPTED);
- } while (ret > 0);
+ do {
+ ret =
+ gnutls_record_recv(session, buffer,
+ MAX_BUF);
+ } while (ret == GNUTLS_E_AGAIN
+ || ret == GNUTLS_E_INTERRUPTED);
+ } while (ret > 0);
+
+ if (ret == 0)
+ break;
+
+ if (ret != GNUTLS_E_REHANDSHAKE) {
+ fail("server: Error receiving client handshake request: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
- if (ret != GNUTLS_E_REHANDSHAKE) {
- fail("server: Error receiving client handshake request: %s\n", gnutls_strerror(ret));
- terminate();
- }
+ if (debug)
+ success("server: starting handshake\n");
- if (debug)
- success("server: starting handshake\n");
+ ret = gnutls_handshake(session);
+ if (ret != 0) {
+ fail("server: unexpected error: %s\n", gnutls_strerror(ret));
+ terminate();
+ }
- ret = gnutls_handshake(session);
- if (ret != 0) {
- fail("server: unexpected error: %s\n", gnutls_strerror(ret));
- terminate();
- }
+ if (debug)
+ success("server: handshake %d\n", tries);
+ } while(tries < MAX_REHANDSHAKES);
+
+ if (tries < MAX_REHANDSHAKES)
+ fail("server: only did %d rehandshakes\n", tries);
ret = gnutls_record_send(session, "hello", 4);
if (ret < 0) {