|
@@ -1710,102 +1710,6 @@ dummy_handshake_func(SSL *s)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-static void
|
|
|
-test_tortls_shutdown(void *ignored)
|
|
|
-{
|
|
|
- (void)ignored;
|
|
|
- int ret;
|
|
|
- tor_tls_t *tls;
|
|
|
- SSL_METHOD *method = give_me_a_test_method();
|
|
|
- setup_capture_of_logs(LOG_WARN);
|
|
|
-
|
|
|
- tls = tor_malloc_zero(sizeof(tor_tls_t));
|
|
|
- tls->ssl = tor_malloc_zero(sizeof(SSL));
|
|
|
- tls->ssl->method = method;
|
|
|
- method->ssl_read = fixed_ssl_read;
|
|
|
- method->ssl_shutdown = fixed_ssl_shutdown;
|
|
|
-
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, -9);
|
|
|
-
|
|
|
- tls->state = TOR_TLS_ST_SENTCLOSE;
|
|
|
- fixed_ssl_read_result_index = 0;
|
|
|
- fixed_ssl_read_result[0] = 10;
|
|
|
- fixed_ssl_read_result[1] = -1;
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, -9);
|
|
|
-
|
|
|
-#ifndef LIBRESSL_VERSION_NUMBER
|
|
|
- tls->ssl->handshake_func = dummy_handshake_func;
|
|
|
-
|
|
|
- fixed_ssl_read_result_index = 0;
|
|
|
- fixed_ssl_read_result[0] = 10;
|
|
|
- fixed_ssl_read_result[1] = 42;
|
|
|
- fixed_ssl_read_result[2] = 0;
|
|
|
- fixed_ssl_shutdown_result = 1;
|
|
|
- ERR_clear_error();
|
|
|
- tls->ssl->version = SSL2_VERSION;
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, TOR_TLS_DONE);
|
|
|
- tt_int_op(tls->state, OP_EQ, TOR_TLS_ST_CLOSED);
|
|
|
-
|
|
|
- fixed_ssl_read_result_index = 0;
|
|
|
- fixed_ssl_read_result[0] = 10;
|
|
|
- fixed_ssl_read_result[1] = 42;
|
|
|
- fixed_ssl_read_result[2] = 0;
|
|
|
- fixed_ssl_shutdown_result = 0;
|
|
|
- ERR_clear_error();
|
|
|
- tls->ssl->version = 0;
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, TOR_TLS_DONE);
|
|
|
- tt_int_op(tls->state, OP_EQ, TOR_TLS_ST_CLOSED);
|
|
|
-
|
|
|
- fixed_ssl_read_result_index = 0;
|
|
|
- fixed_ssl_read_result[0] = 10;
|
|
|
- fixed_ssl_read_result[1] = 42;
|
|
|
- fixed_ssl_read_result[2] = 0;
|
|
|
- fixed_ssl_shutdown_result = 0;
|
|
|
- ERR_clear_error();
|
|
|
- tls->ssl->version = 0;
|
|
|
- method->ssl_shutdown = setting_version_ssl_shutdown;
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_MISC);
|
|
|
-
|
|
|
- fixed_ssl_read_result_index = 0;
|
|
|
- fixed_ssl_read_result[0] = 10;
|
|
|
- fixed_ssl_read_result[1] = 42;
|
|
|
- fixed_ssl_read_result[2] = 0;
|
|
|
- fixed_ssl_shutdown_result = 0;
|
|
|
- fixed_tls = tls;
|
|
|
- fixed_ssl_state_to_set = TOR_TLS_ST_GOTCLOSE;
|
|
|
- ERR_clear_error();
|
|
|
- tls->ssl->version = 0;
|
|
|
- method->ssl_shutdown = setting_version_and_state_ssl_shutdown;
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_MISC);
|
|
|
-
|
|
|
- fixed_ssl_read_result_index = 0;
|
|
|
- fixed_ssl_read_result[0] = 10;
|
|
|
- fixed_ssl_read_result[1] = 42;
|
|
|
- fixed_ssl_read_result[2] = 0;
|
|
|
- fixed_ssl_read_result[3] = -1;
|
|
|
- fixed_ssl_shutdown_result = 0;
|
|
|
- fixed_tls = tls;
|
|
|
- fixed_ssl_state_to_set = 0;
|
|
|
- ERR_clear_error();
|
|
|
- tls->ssl->version = 0;
|
|
|
- method->ssl_shutdown = setting_version_and_state_ssl_shutdown;
|
|
|
- ret = tor_tls_shutdown(tls);
|
|
|
- tt_int_op(ret, OP_EQ, TOR_TLS_ERROR_MISC);
|
|
|
-#endif /* !defined(LIBRESSL_VERSION_NUMBER) */
|
|
|
-
|
|
|
- done:
|
|
|
- teardown_capture_of_logs();
|
|
|
- tor_free(method);
|
|
|
- tor_free(tls->ssl);
|
|
|
- tor_free(tls);
|
|
|
-}
|
|
|
-
|
|
|
static int negotiated_callback_called;
|
|
|
|
|
|
static void
|