summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-09-08 19:19:23 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-09-08 19:19:23 +0200
commit9ca624a9357c21560a6a9be6d64f03c14fa278e8 (patch)
tree97d1458d1650ebb9499b68d94b5b217b4a302afe /tests
parentee981c5b9c30d7495189697a252bebcc721f1a9a (diff)
downloadgnutls-9ca624a9357c21560a6a9be6d64f03c14fa278e8.tar.gz
Test gnutls_handshake_get_last_in() and gnutls_handshake_get_last_out() for correctness.
Diffstat (limited to 'tests')
-rw-r--r--tests/mini-x509-callbacks.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/mini-x509-callbacks.c b/tests/mini-x509-callbacks.c
index 9531c1cc2e..0246f9d7cc 100644
--- a/tests/mini-x509-callbacks.c
+++ b/tests/mini-x509-callbacks.c
@@ -33,6 +33,8 @@
#include "eagain-common.h"
/* Tests whether the verify callbacks are operational.
+ * In addition gnutls_handshake_get_last_in() and gnutls_handshake_get_last_out()
+ * are tested.
*/
const char* side;
@@ -68,6 +70,7 @@ unsigned int msg_order[] = {
static int handshake_callback (gnutls_session_t session, unsigned int htype, unsigned post, unsigned int incoming)
{
static unsigned idx = 0;
+unsigned int msg;
if (msg_order[idx] != htype)
{
@@ -75,6 +78,25 @@ static unsigned idx = 0;
exit(1);
}
idx++;
+
+ if (incoming != 0)
+ {
+ msg = gnutls_handshake_get_last_in(session);
+ if (msg != htype)
+ {
+ fail("last input message was not recorded (exp: %d, found: %d) \n", msg, htype);
+ exit(1);
+ }
+ }
+ else
+ {
+ msg = gnutls_handshake_get_last_out(session);
+ if (msg != htype)
+ {
+ fail("last output message was not recorded (exp: %d, found: %d) \n", msg, htype);
+ exit(1);
+ }
+ }
return 0;
}
@@ -83,6 +105,19 @@ static int
server_callback (gnutls_session_t session)
{
server_ok = 1;
+
+ if (gnutls_handshake_get_last_in(session) != GNUTLS_HANDSHAKE_CERTIFICATE_PKT)
+ {
+ fail("client's last input message was unexpected\n");
+ exit(1);
+ }
+
+ if (gnutls_handshake_get_last_out(session) != GNUTLS_HANDSHAKE_SERVER_HELLO_DONE)
+ {
+ fail("client's last output message was unexpected\n");
+ exit(1);
+ }
+
return 0;
}