static void
test_tortls_errno_to_tls_error(void *data)
{
+ (void) data;
tt_int_op(tor_errno_to_tls_error(SOCK_ERRNO(ECONNRESET)),OP_EQ,TOR_TLS_ERROR_CONNRESET);
tt_int_op(tor_errno_to_tls_error(SOCK_ERRNO(ETIMEDOUT)),OP_EQ,TOR_TLS_ERROR_TIMEOUT);
tt_int_op(tor_errno_to_tls_error(SOCK_ERRNO(EHOSTUNREACH)),OP_EQ,TOR_TLS_ERROR_NO_ROUTE);
static void
test_tortls_err_to_string(void *data)
{
+ (void) data;
tt_str_op(tor_tls_err_to_string(1),OP_EQ,"[Not an error.]");
tt_str_op(tor_tls_err_to_string(TOR_TLS_ERROR_MISC),OP_EQ,"misc error");
tt_str_op(tor_tls_err_to_string(TOR_TLS_ERROR_IO),OP_EQ,"unexpected close");
static void
test_tortls_tor_tls_new(void *data)
{
+ (void) data;
MOCK(tor_tls_cert_matches_key, mock_tls_cert_matches_key);
crypto_pk_t *key1 = NULL, *key2 = NULL;
key1 = pk_generate(2);
static void
test_tortls_tor_tls_get_error(void *data)
{
+ (void) data;
MOCK(tor_tls_cert_matches_key, mock_tls_cert_matches_key);
crypto_pk_t *key1 = NULL, *key2 = NULL;
key1 = pk_generate(2);
tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error: (null) (in (null):(null):---)\n");
mock_clean_saved_logs();
- tls->address = "127.hello";
+ tls->address = tor_strdup("127.hello");
tor_tls_log_one_error(tls, 0, LOG_WARN, 0, NULL);
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error with 127.hello: (null) (in (null):(null):---)\n");
mock_clean_saved_logs();
- tls->address = "127.hello";
+ tls->address = tor_strdup("127.hello");
tor_tls_log_one_error(tls, 0, LOG_WARN, 0, "blarg");
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error while blarg with 127.hello: (null) (in (null):(null):---)\n");
static int
fixed_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
{
+ (void) a; (void) b;
return 1;
}
}
static SSL_CIPHER *
-get_cipher_by_name(char *name)
+get_cipher_by_name(const char *name)
{
int i;
const SSL_METHOD *method = SSLv23_method();
for (i = 0; i < num; ++i) {
const SSL_CIPHER *cipher = method->get_cipher(i);
const char *ciphername = SSL_CIPHER_get_name(cipher);
- if(!strcmp(ciphername, name)) {
+ if (!strcmp(ciphername, name)) {
return (SSL_CIPHER *)cipher;
}
}
static X509 *fixed_try_to_extract_certs_from_tls_id_cert_out_result = NULL;
static void
-fixed_try_to_extract_certs_from_tls(int severity, tor_tls_t *tls, X509 **cert_out, X509 **id_cert_out)
+fixed_try_to_extract_certs_from_tls(int severity, tor_tls_t *tls,
+ X509 **cert_out, X509 **id_cert_out)
{
+ (void) severity;
+ (void) tls;
*cert_out = fixed_try_to_extract_certs_from_tls_cert_out_result;
*id_cert_out = fixed_try_to_extract_certs_from_tls_id_cert_out_result;
}
read_cert_from(const char *str)
{
BIO *bio = BIO_new(BIO_s_mem());
- BIO_write(bio, str, strlen(str));
+ BIO_write(bio, str, (int) strlen(str));
X509 *res = PEM_read_bio_X509(bio, NULL, NULL, NULL);
BIO_free(bio);
return res;
test_tortls_get_forced_write_size(void *ignored)
{
(void)ignored;
- int ret;
+ long ret;
tor_tls_t *tls;
tls = tor_malloc_zero(sizeof(tor_tls_t));
{
(void)ignored;
tor_tls_t *tls;
- char *arg = "hello";
+ const char *arg = "hello";
tls = tor_malloc_zero(sizeof(tor_tls_t));
tls->ssl = tor_malloc_zero(sizeof(SSL));
- tor_tls_set_renegotiate_callback(tls, example_cb, arg);
+ tor_tls_set_renegotiate_callback(tls, example_cb, (void*)arg);
tt_assert(tls->negotiated_callback == example_cb);
tt_assert(tls->callback_arg == arg);
tt_assert(!tls->got_renegotiate);
/* Assumes V2_HANDSHAKE_SERVER */
tt_assert(tls->ssl->info_callback == tor_tls_server_info_callback);
- tor_tls_set_renegotiate_callback(tls, NULL, arg);
+ tor_tls_set_renegotiate_callback(tls, NULL, (void*)arg);
tt_assert(tls->ssl->info_callback == tor_tls_debug_state_callback);
done:
static int
fixed_ssl_read(SSL *s, void *buf, int len)
{
+ (void)s;
+ (void)buf;
+ (void)len;
return fixed_ssl_read_result[fixed_ssl_read_result_index++];
}
static int
fixed_ssl_shutdown(SSL *s)
{
+ (void)s;
return fixed_ssl_shutdown_result;
}
static int
dummy_handshake_func(SSL *s)
{
+ (void)s;
return 1;
}
static int
fixed_ssl_write(SSL *s, const void *buf, int len)
{
+ (void)s;
+ (void)buf;
+ (void)len;
return fixed_ssl_write_result;
}
static int
fixed_ssl_renegotiate(SSL *s)
{
+ (void) s;
return fixed_ssl_renegotiate_result;
}
static int
setting_error_ssl_accept(SSL *ssl)
{
+ (void)ssl;
ERR_put_error(ERR_LIB_BN, 2, -1, "somewhere.c", 99);
ERR_put_error(ERR_LIB_SYS, 2, -1, "somewhere.c", 99);
return fixed_ssl_accept_result;
static int
setting_error_ssl_connect(SSL *ssl)
{
+ (void)ssl;
ERR_put_error(ERR_LIB_BN, 2, -1, "somewhere.c", 99);
ERR_put_error(ERR_LIB_SYS, 2, -1, "somewhere.c", 99);
return fixed_ssl_connect_result;
static int
fixed_ssl_accept(SSL *ssl)
{
+ (void) ssl;
return fixed_ssl_accept_result;
}
static int
fixed_crypto_pk_generate_key_with_bits(crypto_pk_t *env, int bits)
{
- return fixed_crypto_pk_generate_key_with_bits_result[fixed_crypto_pk_generate_key_with_bits_result_index++];
+ (void)env;
+ (void)bits;
+ return fixed_crypto_pk_generate_key_with_bits_result[
+ fixed_crypto_pk_generate_key_with_bits_result_index++];
}
static X509 *
const char *cname_sign,
unsigned int cert_lifetime)
{
- return fixed_tor_tls_create_certificate_result[fixed_tor_tls_create_certificate_result_index++];
+ (void)rsa;
+ (void)rsa_sign;
+ (void)cname;
+ (void)cname_sign;
+ (void)cert_lifetime;
+ return fixed_tor_tls_create_certificate_result[
+ fixed_tor_tls_create_certificate_result_index++];
}
static tor_x509_cert_t *
fixed_tor_x509_cert_new(X509 *x509_cert)
{
+ (void) x509_cert;
return fixed_tor_x509_cert_new_result[fixed_tor_x509_cert_new_result_index++];
}
{
(void)ignored;
tor_tls_context_t *ret;
- crypto_pk_t *pk1, *pk2, *pk3, *pk4, *pk5, *pk6, *pk7, *pk8, *pk9, *pk10, *pk11, *pk12, *pk13, *pk14, *pk15, *pk16, *pk17, *pk18;
+ crypto_pk_t *pk1, *pk2, *pk3, *pk4, *pk5, *pk6, *pk7, *pk8, *pk9, *pk10,
+ *pk11, *pk12, *pk13, *pk14, *pk15, *pk16, *pk17, *pk18;
pk1 = crypto_pk_new();
pk2 = crypto_pk_new();
static EVP_PKEY *
fixed_crypto_pk_get_evp_pkey_(crypto_pk_t *env, int private)
{
- return fixed_crypto_pk_get_evp_pkey_result[fixed_crypto_pk_get_evp_pkey_result_index++];
+ (void) env;
+ (void) private;
+ return fixed_crypto_pk_get_evp_pkey_result[
+ fixed_crypto_pk_get_evp_pkey_result_index++];
}
static int
fixed_crypto_rand(char *to, size_t n)
{
+ (void)to;
+ (void)n;
return fixed_crypto_rand_result;
}