aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench.c32
-rw-r--r--src/test/test.c46
-rw-r--r--src/test/test.h2
-rw-r--r--src/test/test_containers.c28
-rw-r--r--src/test/test_crypto.c80
-rw-r--r--src/test/test_dir.c64
-rw-r--r--src/test/test_microdesc.c2
-rw-r--r--src/test/test_pt.c4
-rw-r--r--src/test/test_util.c6
9 files changed, 132 insertions, 132 deletions
diff --git a/src/test/bench.c b/src/test/bench.c
index ff2794e7c..a662bd23e 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -73,11 +73,11 @@ bench_aes(void)
{
int len, i;
char *b1, *b2;
- crypto_cipher_env_t *c;
+ crypto_cipher_t *c;
uint64_t start, end;
const int bytes_per_iter = (1<<24);
reset_perftime();
- c = crypto_new_cipher_env();
+ c = crypto_cipher_new();
crypto_cipher_generate_key(c);
crypto_cipher_encrypt_init_cipher(c);
for (len = 1; len <= 8192; len *= 2) {
@@ -94,7 +94,7 @@ bench_aes(void)
printf("%d bytes: %.2f nsec per byte\n", len,
NANOCOUNT(start, end, iters*len));
}
- crypto_free_cipher_env(c);
+ crypto_cipher_free(c);
}
static void
@@ -105,10 +105,10 @@ bench_cell_aes(void)
const int iters = (1<<16);
const int max_misalign = 15;
char *b = tor_malloc(len+max_misalign);
- crypto_cipher_env_t *c;
+ crypto_cipher_t *c;
int i, misalign;
- c = crypto_new_cipher_env();
+ c = crypto_cipher_new();
crypto_cipher_generate_key(c);
crypto_cipher_encrypt_init_cipher(c);
@@ -123,7 +123,7 @@ bench_cell_aes(void)
NANOCOUNT(start, end, iters*len));
}
- crypto_free_cipher_env(c);
+ crypto_cipher_free(c);
tor_free(b);
}
@@ -131,8 +131,8 @@ bench_cell_aes(void)
static void
bench_dmap(void)
{
- smartlist_t *sl = smartlist_create();
- smartlist_t *sl2 = smartlist_create();
+ smartlist_t *sl = smartlist_new();
+ smartlist_t *sl2 = smartlist_new();
uint64_t start, end, pt2, pt3, pt4;
int iters = 8192;
const int elts = 4000;
@@ -221,14 +221,14 @@ bench_cell_ops(void)
or_circ->_base.purpose = CIRCUIT_PURPOSE_OR;
/* Initialize crypto */
- or_circ->p_crypto = crypto_new_cipher_env();
+ or_circ->p_crypto = crypto_cipher_new();
crypto_cipher_generate_key(or_circ->p_crypto);
crypto_cipher_encrypt_init_cipher(or_circ->p_crypto);
- or_circ->n_crypto = crypto_new_cipher_env();
+ or_circ->n_crypto = crypto_cipher_new();
crypto_cipher_generate_key(or_circ->n_crypto);
crypto_cipher_encrypt_init_cipher(or_circ->n_crypto);
- or_circ->p_digest = crypto_new_digest_env();
- or_circ->n_digest = crypto_new_digest_env();
+ or_circ->p_digest = crypto_digest_new();
+ or_circ->n_digest = crypto_digest_new();
reset_perftime();
@@ -247,10 +247,10 @@ bench_cell_ops(void)
NANOCOUNT(start,end,iters*CELL_PAYLOAD_SIZE));
}
- crypto_free_digest_env(or_circ->p_digest);
- crypto_free_digest_env(or_circ->n_digest);
- crypto_free_cipher_env(or_circ->p_crypto);
- crypto_free_cipher_env(or_circ->n_crypto);
+ crypto_digest_free(or_circ->p_digest);
+ crypto_digest_free(or_circ->n_digest);
+ crypto_cipher_free(or_circ->p_crypto);
+ crypto_cipher_free(or_circ->n_crypto);
tor_free(or_circ);
tor_free(cell);
}
diff --git a/src/test/test.c b/src/test/test.c
index 5fcc31c47..9d369c04d 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -164,27 +164,27 @@ remove_directory(void)
/** Define this if unit tests spend too much time generating public keys*/
#undef CACHE_GENERATED_KEYS
-static crypto_pk_env_t *pregen_keys[5] = {NULL, NULL, NULL, NULL, NULL};
+static crypto_pk_t *pregen_keys[5] = {NULL, NULL, NULL, NULL, NULL};
#define N_PREGEN_KEYS ((int)(sizeof(pregen_keys)/sizeof(pregen_keys[0])))
/** Generate and return a new keypair for use in unit tests. If we're using
* the key cache optimization, we might reuse keys: we only guarantee that
* keys made with distinct values for <b>idx</b> are different. The value of
* <b>idx</b> must be at least 0, and less than N_PREGEN_KEYS. */
-crypto_pk_env_t *
+crypto_pk_t *
pk_generate(int idx)
{
#ifdef CACHE_GENERATED_KEYS
tor_assert(idx < N_PREGEN_KEYS);
if (! pregen_keys[idx]) {
- pregen_keys[idx] = crypto_new_pk_env();
+ pregen_keys[idx] = crypto_pk_new();
tor_assert(!crypto_pk_generate_key(pregen_keys[idx]));
}
return crypto_pk_dup_key(pregen_keys[idx]);
#else
- crypto_pk_env_t *result;
+ crypto_pk_t *result;
(void) idx;
- result = crypto_new_pk_env();
+ result = crypto_pk_new();
tor_assert(!crypto_pk_generate_key(result));
return result;
#endif
@@ -197,7 +197,7 @@ free_pregenerated_keys(void)
unsigned idx;
for (idx = 0; idx < N_PREGEN_KEYS; ++idx) {
if (pregen_keys[idx]) {
- crypto_free_pk_env(pregen_keys[idx]);
+ crypto_pk_free(pregen_keys[idx]);
pregen_keys[idx] = NULL;
}
}
@@ -812,7 +812,7 @@ static void
test_onion_handshake(void)
{
/* client-side */
- crypto_dh_env_t *c_dh = NULL;
+ crypto_dh_t *c_dh = NULL;
char c_buf[ONIONSKIN_CHALLENGE_LEN];
char c_keys[40];
@@ -821,7 +821,7 @@ test_onion_handshake(void)
char s_keys[40];
/* shared */
- crypto_pk_env_t *pk = NULL;
+ crypto_pk_t *pk = NULL;
pk = pk_generate(0);
@@ -851,7 +851,7 @@ test_onion_handshake(void)
if (c_dh)
crypto_dh_free(c_dh);
if (pk)
- crypto_free_pk_env(pk);
+ crypto_pk_free(pk);
}
static void
@@ -1010,7 +1010,7 @@ test_policy_summary_helper(const char *policy_str,
const char *expected_summary)
{
config_line_t line;
- smartlist_t *policy = smartlist_create();
+ smartlist_t *policy = smartlist_new();
char *summary = NULL;
int r;
short_policy_t *short_policy = NULL;
@@ -1050,7 +1050,7 @@ test_policies(void)
smartlist_t *sm = NULL;
char *policy_str = NULL;
- policy = smartlist_create();
+ policy = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject 192.168.0.0/16:*",-1);
test_assert(p != NULL);
@@ -1076,7 +1076,7 @@ test_policies(void)
test_assert(0 == policies_parse_exit_policy(NULL, &policy2, 1, NULL, 1));
test_assert(policy2);
- policy3 = smartlist_create();
+ policy3 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject *:*",-1);
test_assert(p != NULL);
smartlist_add(policy3, p);
@@ -1084,7 +1084,7 @@ test_policies(void)
test_assert(p != NULL);
smartlist_add(policy3, p);
- policy4 = smartlist_create();
+ policy4 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept *:443",-1);
test_assert(p != NULL);
smartlist_add(policy4, p);
@@ -1092,7 +1092,7 @@ test_policies(void)
test_assert(p != NULL);
smartlist_add(policy4, p);
- policy5 = smartlist_create();
+ policy5 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject 0.0.0.0/8:*",-1);
test_assert(p != NULL);
smartlist_add(policy5, p);
@@ -1124,12 +1124,12 @@ test_policies(void)
test_assert(p != NULL);
smartlist_add(policy5, p);
- policy6 = smartlist_create();
+ policy6 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept 43.3.0.0/9:*",-1);
test_assert(p != NULL);
smartlist_add(policy6, p);
- policy7 = smartlist_create();
+ policy7 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept 0.0.0.0/8:*",-1);
test_assert(p != NULL);
smartlist_add(policy7, p);
@@ -1226,7 +1226,7 @@ test_policies(void)
"reject 1,3,5,7");
/* truncation ports */
- sm = smartlist_create();
+ sm = smartlist_new();
for (i=1; i<2000; i+=2) {
char buf[POLICY_BUF_LEN];
tor_snprintf(buf, sizeof(buf), "reject *:%d", i);
@@ -1273,10 +1273,10 @@ test_rend_fns(void)
char service_id[DIGEST_LEN];
char service_id_base32[REND_SERVICE_ID_LEN_BASE32+1];
const char *next_desc;
- smartlist_t *descs = smartlist_create();
+ smartlist_t *descs = smartlist_new();
char computed_desc_id[DIGEST_LEN];
char parsed_desc_id[DIGEST_LEN];
- crypto_pk_env_t *pk1 = NULL, *pk2 = NULL;
+ crypto_pk_t *pk1 = NULL, *pk2 = NULL;
time_t now;
char *intro_points_encrypted = NULL;
size_t intro_points_size;
@@ -1303,11 +1303,11 @@ test_rend_fns(void)
generated->timestamp = now;
generated->version = 2;
generated->protocols = 42;
- generated->intro_nodes = smartlist_create();
+ generated->intro_nodes = smartlist_new();
for (i = 0; i < 3; i++) {
rend_intro_point_t *intro = tor_malloc_zero(sizeof(rend_intro_point_t));
- crypto_pk_env_t *okey = pk_generate(2 + i);
+ crypto_pk_t *okey = pk_generate(2 + i);
intro->extend_info = tor_malloc_zero(sizeof(extend_info_t));
intro->extend_info->onion_key = okey;
crypto_pk_get_digest(intro->extend_info->onion_key,
@@ -1374,9 +1374,9 @@ test_rend_fns(void)
if (generated)
rend_service_descriptor_free(generated);
if (pk1)
- crypto_free_pk_env(pk1);
+ crypto_pk_free(pk1);
if (pk2)
- crypto_free_pk_env(pk2);
+ crypto_pk_free(pk2);
tor_free(intro_points_encrypted);
}
diff --git a/src/test/test.h b/src/test/test.h
index a053a7ac4..0fcb02a41 100644
--- a/src/test/test.h
+++ b/src/test/test.h
@@ -67,7 +67,7 @@
#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, ==, hex)
const char *get_fname(const char *name);
-crypto_pk_env_t *pk_generate(int idx);
+crypto_pk_t *pk_generate(int idx);
void legacy_test_helper(void *data);
extern const struct testcase_setup_t legacy_setup;
diff --git a/src/test/test_containers.c b/src/test/test_containers.c
index af9fb1c5c..b5b0ef36e 100644
--- a/src/test/test_containers.c
+++ b/src/test/test_containers.c
@@ -34,7 +34,7 @@ test_container_smartlist_basic(void)
/* XXXX test sort_digests, uniq_strings, uniq_digests */
/* Test smartlist add, del_keeporder, insert, get. */
- sl = smartlist_create();
+ sl = smartlist_new();
smartlist_add(sl, (void*)1);
smartlist_add(sl, (void*)2);
smartlist_add(sl, (void*)3);
@@ -68,7 +68,7 @@ test_container_smartlist_basic(void)
static void
test_container_smartlist_strings(void)
{
- smartlist_t *sl = smartlist_create();
+ smartlist_t *sl = smartlist_new();
char *cp=NULL, *cp_alloc=NULL;
size_t sz;
@@ -298,11 +298,11 @@ test_container_smartlist_strings(void)
static void
test_container_smartlist_overlap(void)
{
- smartlist_t *sl = smartlist_create();
- smartlist_t *ints = smartlist_create();
- smartlist_t *odds = smartlist_create();
- smartlist_t *evens = smartlist_create();
- smartlist_t *primes = smartlist_create();
+ smartlist_t *sl = smartlist_new();
+ smartlist_t *ints = smartlist_new();
+ smartlist_t *odds = smartlist_new();
+ smartlist_t *evens = smartlist_new();
+ smartlist_t *primes = smartlist_new();
int i;
for (i=1; i < 10; i += 2)
smartlist_add(odds, (void*)(uintptr_t)i);
@@ -351,7 +351,7 @@ test_container_smartlist_overlap(void)
static void
test_container_smartlist_digests(void)
{
- smartlist_t *sl = smartlist_create();
+ smartlist_t *sl = smartlist_new();
/* digest_isin. */
smartlist_add(sl, tor_memdup("AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN));
@@ -384,9 +384,9 @@ test_container_smartlist_digests(void)
static void
test_container_smartlist_join(void)
{
- smartlist_t *sl = smartlist_create();
- smartlist_t *sl2 = smartlist_create(), *sl3 = smartlist_create(),
- *sl4 = smartlist_create();
+ smartlist_t *sl = smartlist_new();
+ smartlist_t *sl2 = smartlist_new(), *sl3 = smartlist_new(),
+ *sl4 = smartlist_new();
char *joined=NULL;
/* unique, sorted. */
smartlist_split_string(sl,
@@ -479,7 +479,7 @@ test_container_bitarray(void)
static void
test_container_digestset(void)
{
- smartlist_t *included = smartlist_create();
+ smartlist_t *included = smartlist_new();
char d[DIGEST_LEN];
int i;
int ok = 1;
@@ -532,7 +532,7 @@ _compare_strings_for_pqueue(const void *p1, const void *p2)
static void
test_container_pqueue(void)
{
- smartlist_t *sl = smartlist_create();
+ smartlist_t *sl = smartlist_new();
int (*cmp)(const void *, const void*);
const int offset = STRUCT_OFFSET(pq_entry_t, idx);
#define ENTRY(s) pq_entry_t s = { #s, -1 }
@@ -669,7 +669,7 @@ test_container_strmap(void)
/* Test iterator. */
iter = strmap_iter_init(map);
- found_keys = smartlist_create();
+ found_keys = smartlist_new();
while (!strmap_iter_done(iter)) {
strmap_iter_get(iter,&k,&v);
smartlist_add(found_keys, tor_strdup(k));
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 2adbcc96e..bf0962e98 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -13,8 +13,8 @@
static void
test_crypto_dh(void)
{
- crypto_dh_env_t *dh1 = crypto_dh_new(DH_TYPE_CIRCUIT);
- crypto_dh_env_t *dh2 = crypto_dh_new(DH_TYPE_CIRCUIT);
+ crypto_dh_t *dh1 = crypto_dh_new(DH_TYPE_CIRCUIT);
+ crypto_dh_t *dh2 = crypto_dh_new(DH_TYPE_CIRCUIT);
char p1[DH_BYTES];
char p2[DH_BYTES];
char s1[DH_BYTES];
@@ -99,7 +99,7 @@ static void
test_crypto_aes(void *arg)
{
char *data1 = NULL, *data2 = NULL, *data3 = NULL;
- crypto_cipher_env_t *env1 = NULL, *env2 = NULL;
+ crypto_cipher_t *env1 = NULL, *env2 = NULL;
int i, j;
char *mem_op_hex_tmp=NULL;
@@ -118,9 +118,9 @@ test_crypto_aes(void *arg)
memset(data2, 0, 1024);
memset(data3, 0, 1024);
- env1 = crypto_new_cipher_env();
+ env1 = crypto_cipher_new();
test_neq(env1, 0);
- env2 = crypto_new_cipher_env();
+ env2 = crypto_cipher_new();
test_neq(env2, 0);
j = crypto_cipher_generate_key(env1);
crypto_cipher_set_key(env2, crypto_cipher_get_key(env1));
@@ -151,11 +151,11 @@ test_crypto_aes(void *arg)
test_memeq(data1, data3, 1024-5);
/* Now make sure that when we encrypt with different chunk sizes, we get
the same results. */
- crypto_free_cipher_env(env2);
+ crypto_cipher_free(env2);
env2 = NULL;
memset(data3, 0, 1024);
- env2 = crypto_new_cipher_env();
+ env2 = crypto_cipher_new();
test_neq(env2, 0);
crypto_cipher_set_key(env2, crypto_cipher_get_key(env1));
crypto_cipher_encrypt_init_cipher(env2);
@@ -168,13 +168,13 @@ test_crypto_aes(void *arg)
}
}
test_memeq(data2, data3, 1024-16);
- crypto_free_cipher_env(env1);
+ crypto_cipher_free(env1);
env1 = NULL;
- crypto_free_cipher_env(env2);
+ crypto_cipher_free(env2);
env2 = NULL;
/* NIST test vector for aes. */
- env1 = crypto_new_cipher_env(); /* IV starts at 0 */
+ env1 = crypto_cipher_new(); /* IV starts at 0 */
crypto_cipher_set_key(env1, "\x80\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00");
crypto_cipher_encrypt_init_cipher(env1);
@@ -222,9 +222,9 @@ test_crypto_aes(void *arg)
done:
tor_free(mem_op_hex_tmp);
if (env1)
- crypto_free_cipher_env(env1);
+ crypto_cipher_free(env1);
if (env2)
- crypto_free_cipher_env(env2);
+ crypto_cipher_free(env2);
tor_free(data1);
tor_free(data2);
tor_free(data3);
@@ -234,7 +234,7 @@ test_crypto_aes(void *arg)
static void
test_crypto_sha(void)
{
- crypto_digest_env_t *d1 = NULL, *d2 = NULL;
+ crypto_digest_t *d1 = NULL, *d2 = NULL;
int i;
char key[160];
char digest[32];
@@ -351,7 +351,7 @@ test_crypto_sha(void)
"bfdc63644f0713938a7f51535c3a35e2");
/* Incremental digest code. */
- d1 = crypto_new_digest_env();
+ d1 = crypto_digest_new();
test_assert(d1);
crypto_digest_add_bytes(d1, "abcdef", 6);
d2 = crypto_digest_dup(d1);
@@ -368,11 +368,11 @@ test_crypto_sha(void)
crypto_digest_get_digest(d1, d_out1, sizeof(d_out1));
crypto_digest(d_out2, "abcdef", 6);
test_memeq(d_out1, d_out2, DIGEST_LEN);
- crypto_free_digest_env(d1);
- crypto_free_digest_env(d2);
+ crypto_digest_free(d1);
+ crypto_digest_free(d2);
/* Incremental digest code with sha256 */
- d1 = crypto_new_digest256_env(DIGEST_SHA256);
+ d1 = crypto_digest256_new(DIGEST_SHA256);
test_assert(d1);
crypto_digest_add_bytes(d1, "abcdef", 6);
d2 = crypto_digest_dup(d1);
@@ -392,9 +392,9 @@ test_crypto_sha(void)
done:
if (d1)
- crypto_free_digest_env(d1);
+ crypto_digest_free(d1);
if (d2)
- crypto_free_digest_env(d2);
+ crypto_digest_free(d2);
tor_free(mem_op_hex_tmp);
}
@@ -402,7 +402,7 @@ test_crypto_sha(void)
static void
test_crypto_pk(void)
{
- crypto_pk_env_t *pk1 = NULL, *pk2 = NULL;
+ crypto_pk_t *pk1 = NULL, *pk2 = NULL;
char *encoded = NULL;
char data1[1024], data2[1024], data3[1024];
size_t size;
@@ -410,7 +410,7 @@ test_crypto_pk(void)
/* Public-key ciphers */
pk1 = pk_generate(0);
- pk2 = crypto_new_pk_env();
+ pk2 = crypto_pk_new();
test_assert(pk1 && pk2);
test_assert(! crypto_pk_write_public_key_to_string(pk1, &encoded, &size));
test_assert(! crypto_pk_read_public_key_from_string(pk2, encoded, size));
@@ -476,7 +476,7 @@ test_crypto_pk(void)
/*XXXX test failed signing*/
/* Try encoding */
- crypto_free_pk_env(pk2);
+ crypto_pk_free(pk2);
pk2 = NULL;
i = crypto_pk_asn1_encode(pk1, data1, 1024);
test_assert(i>0);
@@ -504,7 +504,7 @@ test_crypto_pk(void)
}
/* Try copy_full */
- crypto_free_pk_env(pk2);
+ crypto_pk_free(pk2);
pk2 = crypto_pk_copy_full(pk1);
test_assert(pk2 != NULL);
test_neq_ptr(pk1, pk2);
@@ -512,9 +512,9 @@ test_crypto_pk(void)
done:
if (pk1)
- crypto_free_pk_env(pk1);
+ crypto_pk_free(pk1);
if (pk2)
- crypto_free_pk_env(pk2);
+ crypto_pk_free(pk2);
tor_free(encoded);
}
@@ -677,7 +677,7 @@ test_crypto_s2k(void)
static void
test_crypto_aes_iv(void *arg)
{
- crypto_cipher_env_t *cipher;
+ crypto_cipher_t *cipher;
char *plain, *encrypted1, *encrypted2, *decrypted1, *decrypted2;
char plain_1[1], plain_15[15], plain_16[16], plain_17[17];
char key1[16], key2[16];
@@ -704,7 +704,7 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 1);
encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted1, 16 + 4095,
plain, 4095);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(encrypted_size, 16 + 4095);
tt_assert(encrypted_size > 0); /* This is obviously true, since 4111 is
@@ -713,7 +713,7 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 4095,
encrypted1, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(decrypted_size, 4095);
tt_assert(decrypted_size > 0);
@@ -722,14 +722,14 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 1);
encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted2, 16 + 4095,
plain, 4095);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(encrypted_size, 16 + 4095);
tt_assert(encrypted_size > 0);
cipher = crypto_create_init_cipher(key1, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted2, 4095,
encrypted2, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(decrypted_size, 4095);
tt_assert(decrypted_size > 0);
@@ -739,7 +739,7 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key2, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted2, 4095,
encrypted1, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_memneq(plain, decrypted2, encrypted_size);
/* Alter the initialization vector. */
@@ -747,21 +747,21 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 4095,
encrypted1, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_memneq(plain, decrypted2, 4095);
/* Special length case: 1. */
cipher = crypto_create_init_cipher(key1, 1);
encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted1, 16 + 1,
plain_1, 1);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(encrypted_size, 16 + 1);
tt_assert(encrypted_size > 0);
cipher = crypto_create_init_cipher(key1, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 1,
encrypted1, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(decrypted_size, 1);
tt_assert(decrypted_size > 0);
@@ -770,14 +770,14 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 1);
encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted1, 16 + 15,
plain_15, 15);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(encrypted_size, 16 + 15);
tt_assert(encrypted_size > 0);
cipher = crypto_create_init_cipher(key1, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 15,
encrypted1, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(decrypted_size, 15);
tt_assert(decrypted_size > 0);
@@ -786,14 +786,14 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 1);
encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted1, 16 + 16,
plain_16, 16);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(encrypted_size, 16 + 16);
tt_assert(encrypted_size > 0);
cipher = crypto_create_init_cipher(key1, 0);
decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 16,
encrypted1, encrypted_size);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(decrypted_size, 16);
tt_assert(decrypted_size > 0);
@@ -802,7 +802,7 @@ test_crypto_aes_iv(void *arg)
cipher = crypto_create_init_cipher(key1, 1);
encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted1, 16 + 17,
plain_17, 17);
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
cipher = NULL;
test_eq(encrypted_size, 16 + 17);
tt_assert(encrypted_size > 0);
@@ -821,7 +821,7 @@ test_crypto_aes_iv(void *arg)
tor_free(decrypted1);
tor_free(decrypted2);
if (cipher)
- crypto_free_cipher_env(cipher);
+ crypto_cipher_free(cipher);
}
/** Test base32 decoding. */
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 42d368cb0..fb2351957 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -76,7 +76,7 @@ test_dir_formats(void)
char *pk1_str = NULL, *pk2_str = NULL, *pk3_str = NULL, *cp;
size_t pk1_str_len, pk2_str_len, pk3_str_len;
routerinfo_t *r1=NULL, *r2=NULL;
- crypto_pk_env_t *pk1 = NULL, *pk2 = NULL, *pk3 = NULL;
+ crypto_pk_t *pk1 = NULL, *pk2 = NULL, *pk3 = NULL;
routerinfo_t *rp1 = NULL;
addr_policy_t *ex1, *ex2;
routerlist_t *dir1 = NULL, *dir2 = NULL;
@@ -127,7 +127,7 @@ test_dir_formats(void)
r2->onion_pkey = crypto_pk_dup_key(pk2);
r2->identity_pkey = crypto_pk_dup_key(pk1);
r2->bandwidthrate = r2->bandwidthburst = r2->bandwidthcapacity = 3000;
- r2->exit_policy = smartlist_create();
+ r2->exit_policy = smartlist_new();
smartlist_add(r2->exit_policy, ex2);
smartlist_add(r2->exit_policy, ex1);
r2->nickname = tor_strdup("Fred");
@@ -213,7 +213,7 @@ test_dir_formats(void)
/* Okay, now for the directories. */
{
- fingerprint_list = smartlist_create();
+ fingerprint_list = smartlist_new();
crypto_pk_get_fingerprint(pk2, buf, 1);
add_fingerprint_to_dir("Magri", buf, fingerprint_list);
crypto_pk_get_fingerprint(pk1, buf, 1);
@@ -250,9 +250,9 @@ test_dir_formats(void)
tor_free(pk1_str);
tor_free(pk2_str);
tor_free(pk3_str);
- if (pk1) crypto_free_pk_env(pk1);
- if (pk2) crypto_free_pk_env(pk2);
- if (pk3) crypto_free_pk_env(pk3);
+ if (pk1) crypto_pk_free(pk1);
+ if (pk2) crypto_pk_free(pk2);
+ if (pk3) crypto_pk_free(pk3);
if (rp1) routerinfo_free(rp1);
tor_free(dir1); /* XXXX And more !*/
tor_free(dir2); /* And more !*/
@@ -378,7 +378,7 @@ test_dir_versions(void)
static void
test_dir_fp_pairs(void)
{
- smartlist_t *sl = smartlist_create();
+ smartlist_t *sl = smartlist_new();
fp_pair_t *pair;
dir_split_resource_into_fingerprint_pairs(
@@ -406,7 +406,7 @@ test_dir_fp_pairs(void)
static void
test_dir_split_fps(void *testdata)
{
- smartlist_t *sl = smartlist_create();
+ smartlist_t *sl = smartlist_new();
char *mem_op_hex_tmp = NULL;
(void)testdata;
@@ -594,7 +594,7 @@ static void
test_dir_param_voting(void)
{
networkstatus_t vote1, vote2, vote3, vote4;
- smartlist_t *votes = smartlist_create();
+ smartlist_t *votes = smartlist_new();
char *res = NULL;
/* dirvote_compute_params only looks at the net_params field of the votes,
@@ -604,10 +604,10 @@ test_dir_param_voting(void)
memset(&vote2, 0, sizeof(vote2));
memset(&vote3, 0, sizeof(vote3));
memset(&vote4, 0, sizeof(vote4));
- vote1.net_params = smartlist_create();
- vote2.net_params = smartlist_create();
- vote3.net_params = smartlist_create();
- vote4.net_params = smartlist_create();
+ vote1.net_params = smartlist_new();
+ vote2.net_params = smartlist_new();
+ vote3.net_params = smartlist_new();
+ vote4.net_params = smartlist_new();
smartlist_split_string(vote1.net_params,
"ab=90 abcd=20 cw=50 x-yz=-99", NULL, 0, 0);
smartlist_split_string(vote2.net_params,
@@ -759,7 +759,7 @@ generate_ri_from_rs(const vote_routerstatus_t *vrs)
tor_strdup("123456789012345678901234567890123");
r->cache_info.signed_descriptor_len =
strlen(r->cache_info.signed_descriptor_body);
- r->exit_policy = smartlist_create();
+ r->exit_policy = smartlist_new();
r->cache_info.published_on = ++published + time(NULL);
return r;
}
@@ -772,7 +772,7 @@ get_detached_sigs(networkstatus_t *ns, networkstatus_t *ns2)
char *r;
smartlist_t *sl;
tor_assert(ns && ns->flavor == FLAV_NS);
- sl = smartlist_create();
+ sl = smartlist_new();
smartlist_add(sl,ns);
if (ns2)
smartlist_add(sl,ns2);
@@ -787,8 +787,8 @@ static void
test_dir_v3_networkstatus(void)
{
authority_cert_t *cert1=NULL, *cert2=NULL, *cert3=NULL;
- crypto_pk_env_t *sign_skey_1=NULL, *sign_skey_2=NULL, *sign_skey_3=NULL;
- crypto_pk_env_t *sign_skey_leg1=NULL;
+ crypto_pk_t *sign_skey_1=NULL, *sign_skey_2=NULL, *sign_skey_3=NULL;
+ crypto_pk_t *sign_skey_leg1=NULL;
const char *msg=NULL;
time_t now = time(NULL);
@@ -799,7 +799,7 @@ test_dir_v3_networkstatus(void)
vote_routerstatus_t *vrs;
routerstatus_t *rs;
char *v1_text=NULL, *v2_text=NULL, *v3_text=NULL, *consensus_text=NULL, *cp;
- smartlist_t *votes = smartlist_create();
+ smartlist_t *votes = smartlist_new();
/* For generating the two other consensuses. */
char *detached_text1=NULL, *detached_text2=NULL;
@@ -817,9 +817,9 @@ test_dir_v3_networkstatus(void)
test_assert(cert2);
cert3 = authority_cert_parse_from_string(AUTHORITY_CERT_3, NULL);
test_assert(cert3);
- sign_skey_1 = crypto_new_pk_env();
- sign_skey_2 = crypto_new_pk_env();
- sign_skey_3 = crypto_new_pk_env();
+ sign_skey_1 = crypto_pk_new();
+ sign_skey_2 = crypto_pk_new();
+ sign_skey_3 = crypto_pk_new();
sign_skey_leg1 = pk_generate(4);
test_assert(!crypto_pk_read_private_key_from_string(sign_skey_1,
@@ -843,15 +843,15 @@ test_dir_v3_networkstatus(void)
vote->valid_until = now+3000;
vote->vote_seconds = 100;
vote->dist_seconds = 200;
- vote->supported_methods = smartlist_create();
+ vote->supported_methods = smartlist_new();
smartlist_split_string(vote->supported_methods, "1 2 3", NULL, 0, -1);
vote->client_versions = tor_strdup("0.1.2.14,0.1.2.15");
vote->server_versions = tor_strdup("0.1.2.14,0.1.2.15,0.1.2.16");
- vote->known_flags = smartlist_create();
+ vote->known_flags = smartlist_new();
smartlist_split_string(vote->known_flags,
"Authority Exit Fast Guard Running Stable V2Dir Valid",
0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- vote->voters = smartlist_create();
+ vote->voters = smartlist_new();
voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t));
voter->nickname = tor_strdup("Voter1");
voter->address = tor_strdup("1.2.3.4");
@@ -862,10 +862,10 @@ test_dir_v3_networkstatus(void)
crypto_pk_get_digest(cert1->identity_key, voter->identity_digest);
smartlist_add(vote->voters, voter);
vote->cert = authority_cert_dup(cert1);
- vote->net_params = smartlist_create();
+ vote->net_params = smartlist_new();
smartlist_split_string(vote->net_params, "circuitwindow=101 foo=990",
NULL, 0, 0);
- vote->routerstatus_list = smartlist_create();
+ vote->routerstatus_list = smartlist_new();
/* add the first routerstatus. */
vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
rs = &vrs->status;
@@ -1007,7 +1007,7 @@ test_dir_v3_networkstatus(void)
vote->dist_seconds = 300;
authority_cert_free(vote->cert);
vote->cert = authority_cert_dup(cert2);
- vote->net_params = smartlist_create();
+ vote->net_params = smartlist_new();
smartlist_split_string(vote->net_params, "bar=2000000000 circuitwindow=20",
NULL, 0, 0);
tor_free(vote->client_versions);
@@ -1048,7 +1048,7 @@ test_dir_v3_networkstatus(void)
vote->dist_seconds = 250;
authority_cert_free(vote->cert);
vote->cert = authority_cert_dup(cert3);
- vote->net_params = smartlist_create();
+ vote->net_params = smartlist_new();
smartlist_split_string(vote->net_params, "circuitwindow=80 foo=660",
NULL, 0, 0);
smartlist_add(vote->supported_methods, tor_strdup("4"));
@@ -1347,13 +1347,13 @@ test_dir_v3_networkstatus(void)
if (con_md)
networkstatus_vote_free(con_md);
if (sign_skey_1)
- crypto_free_pk_env(sign_skey_1);
+ crypto_pk_free(sign_skey_1);
if (sign_skey_2)
- crypto_free_pk_env(sign_skey_2);
+ crypto_pk_free(sign_skey_2);
if (sign_skey_3)
- crypto_free_pk_env(sign_skey_3);
+ crypto_pk_free(sign_skey_3);
if (sign_skey_leg1)
- crypto_free_pk_env(sign_skey_leg1);
+ crypto_pk_free(sign_skey_leg1);
if (cert1)
authority_cert_free(cert1);
if (cert2)
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index b807265c8..dcc6f9c16 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -88,7 +88,7 @@ test_md_cache(void *data)
smartlist_free(added);
added = NULL;
- wanted = smartlist_create();
+ wanted = smartlist_new();
added = microdescs_add_to_cache(mc, test_md2, NULL, SAVED_NOWHERE, 0,
time2, wanted);
/* Should fail, since we didn't list test_md2's digest in wanted */
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index 45f441106..9d6aa09f0 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -25,7 +25,7 @@ test_pt_parsing(void)
managed_proxy_t *mp = tor_malloc(sizeof(managed_proxy_t));
mp->conf_state = PT_PROTO_INFANT;
- mp->transports = smartlist_create();
+ mp->transports = smartlist_new();
/* incomplete cmethod */
strcpy(line,"CMETHOD trebuchet");
@@ -93,7 +93,7 @@ test_pt_protocol(void)
managed_proxy_t *mp = tor_malloc_zero(sizeof(managed_proxy_t));
mp->conf_state = PT_PROTO_LAUNCHED;
- mp->transports = smartlist_create();
+ mp->transports = smartlist_new();
/* various wrong protocol runs: */
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 4fc8b84d5..670d87d07 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -397,7 +397,7 @@ test_util_strmisc(void)
/* Test wrap_string */
{
- smartlist_t *sl = smartlist_create();
+ smartlist_t *sl = smartlist_new();
wrap_string(sl, "This is a test of string wrapping functionality: woot.",
10, "", "");
cp = smartlist_join_strings(sl, "", 0, NULL);
@@ -928,7 +928,7 @@ test_util_mempool(void)
test_eq(pool->item_alloc_size & 0x03, 0);
test_assert(pool->new_chunk_capacity < 60);
- allocated = smartlist_create();
+ allocated = smartlist_new();
for (i = 0; i < 20000; ++i) {
if (smartlist_len(allocated) < 20 || crypto_rand_int(2)) {
void *m = mp_pool_get(pool);
@@ -1685,7 +1685,7 @@ test_util_split_lines(void *ptr)
(void)ptr;
for (i=0; tests[i].orig_line; i++) {
- sl = smartlist_create();
+ sl = smartlist_new();
/* Allocate space for string and trailing NULL */
orig_line = tor_memdup(tests[i].orig_line, tests[i].orig_length + 1);
tor_split_lines(sl, orig_line, tests[i].orig_length);