extern int more_info;
static int dh_bits;
-extern int tls1_ok;
-extern int ssl3_ok;
+int tls1_ok = 0;
+int ssl3_ok = 0;
+int tls1_1_ok = 0;
/* keep session info */
static char *session_data = NULL;
}
session_data = malloc(session_data_size);
sfree = 1;
- if (session_data==NULL) exit(1);
+ if (session_data==NULL) {
+ fprintf(stderr, "Memory error\n");
+ exit(1);
+ }
gnutls_session_get_data(session, session_data, &session_data_size);
session_id_size = sizeof( session_id);
gnutls_certificate_type_set_priority(session, _ct_priority);
}
-static void ADD_PROTOCOL(gnutls_session session, int protocol) {
+static void ADD_PROTOCOL(gnutls_session session, int protocol)
+{
static int _proto_priority[] = { 0, 0 };
_proto_priority[0] = protocol;
gnutls_protocol_set_priority(session, _proto_priority);
}
+static void ADD_PROTOCOL3(gnutls_session session, int p1, int p2, int p3)
+{
+ static int _proto_priority[] = { 0, 0, 0, 0 };
+ _proto_priority[0] = p1;
+ _proto_priority[1] = p2;
+ _proto_priority[2] = p3;
+
+ gnutls_protocol_set_priority(session, _proto_priority);
+}
+
#ifdef ENABLE_SRP
static int srp_detected;
return SUCCEED;
}
-int test_ssl3( gnutls_session session) {
+int test_ssl3( gnutls_session session)
+{
int ret;
ADD_ALL_CIPHERS(session);
ADD_ALL_COMP(session);
return ret;
}
+
static int alrm=0;
-void got_alarm(int k) {
+void got_alarm(int k)
+{
alrm = 1;
}
return ret;
}
-int test_tls1( gnutls_session session) {
+int test_tls1( gnutls_session session)
+{
int ret;
ADD_ALL_CIPHERS(session);
ADD_ALL_COMP(session);
}
-int test_tls1_1( gnutls_session session) {
+int test_tls1_1( gnutls_session session)
+{
int ret;
ADD_ALL_CIPHERS(session);
ADD_ALL_COMP(session);
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake( session);
- if (ret==SUCCEED) tls1_ok = 1;
+ if (ret==SUCCEED) tls1_1_ok = 1;
return ret;
}
+int test_tls1_1_fallback( gnutls_session session)
+{
+int ret;
+ ADD_ALL_CIPHERS(session);
+ ADD_ALL_COMP(session);
+ ADD_ALL_CERTTYPES(session);
+ ADD_PROTOCOL3(session, GNUTLS_TLS1_1, GNUTLS_TLS1, GNUTLS_SSL3);
+ ADD_ALL_MACS(session);
+ ADD_ALL_KX(session);
+ gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
+
+ if (tls1_1_ok) return UNSURE;
+
+ ret = do_handshake( session);
+ if (ret!=SUCCEED) return GFAILED;
+
+ if (gnutls_protocol_get_version( session)==GNUTLS_TLS1)
+ return SUCCEED;
+ else if (gnutls_protocol_get_version( session)==GNUTLS_SSL3)
+ return UNSURE;
+
+ return GFAILED;
+
+}
+
/* Advertize both TLS 1.0 and SSL 3.0. If the connection fails,
* but the previous SSL 3.0 test succeeded then disable TLS 1.0.
*/
int more_info = 0;
-int tls1_ok = 0;
-int ssl3_ok = 0;
+extern int tls1_ok;
+extern int tls1_1_ok;
+extern int ssl3_ok;
static void tls_log_func( int level, const char* str)
{
static const TLS_TEST tls_tests[] = {
{ "for TLS 1.1 support", test_tls1_1, "yes", "no", "dunno" },
+ { "fallback from TLS 1.1 to", test_tls1_1_fallback, "TLS 1.0", "", "SSL 3.0" },
{ "for TLS 1.0 support", test_tls1, "yes", "no", "dunno" },
{ "for SSL 3.0 support", test_ssl3, "yes", "no", "dunno" },
{ "for version rollback bug in RSA PMS", test_rsa_pms, "no", "yes", "dunno" },
gnutls_session state;
char buffer[MAX_BUF + 1];
struct hostent *server_host;
- int ssl3_ok = 0;
- int tls1_ok = 0;
gaa_parser(argc, argv);
/* if neither of SSL3 and TLSv1 are supported, exit
*/
- if (i > 1 && tls1_ok == 0 && ssl3_ok == 0) break;
+ if (i > 3 && tls1_1_ok == 0 && tls1_ok == 0 && ssl3_ok == 0) {
+ fprintf(stderr, "%d %d %d\n", tls1_1_ok,tls1_ok,ssl3_ok);
+ break;
+ }
CONNECT();
gnutls_init(&state, GNUTLS_CLIENT);