int s;
dh = crypto_dh_dup(dh_out);
s = onion_skin_TAP_client_handshake(dh, or, key_out, sizeof(key_out));
+ crypto_dh_free(dh);
tor_assert(s == 0);
}
end = perftime();
end = perftime();
printf("Client-side, part 1: %f usec.\n", NANOCOUNT(start, end, iters)/1e3);
+ state = NULL;
onion_skin_ntor_create(nodeid, &keypair1.pubkey, &state, os);
start = perftime();
for (i = 0; i < iters; ++i) {
tt_int_op(0,==,curve25519_keypair_write_to_file(&keypair, fname, "testing"));
tt_int_op(0,==,curve25519_keypair_read_from_file(&keypair2, &tag, fname));
tt_str_op(tag,==,"testing");
+ tor_free(tag);
test_memeq(keypair.pubkey.public_key,
keypair2.pubkey.public_key,
fname = tor_strdup(get_fname("bogus_keypair"));
tt_int_op(-1, ==, curve25519_keypair_read_from_file(&keypair2, &tag, fname));
+ tor_free(tag);
content[69] ^= 0xff;
tt_int_op(0, ==, write_bytes_to_file(fname, content, st.st_size, 1));
done:
tor_free(fname);
tor_free(content);
+ tor_free(tag);
}
#endif
/* client1 nodeID B -> msg state */
curve25519_public_key_t B;
uint8_t node_id[DIGEST_LEN];
- ntor_handshake_state_t *state;
+ ntor_handshake_state_t *state = NULL;
uint8_t msg[NTOR_ONIONSKIN_LEN];
char buf[1024];
- memset(&state, 0, sizeof(state));
-
N_ARGS(4);
BASE16(2, node_id, DIGEST_LEN);
BASE16(3, B.public_key, CURVE25519_PUBKEY_LEN);
printf("%s\n", buf);
base16_encode(buf, sizeof(buf), (void*)state, sizeof(*state));
printf("%s\n", buf);
+
ntor_handshake_state_free(state);
return 0;
}
int keybytes;
uint8_t msg_out[NTOR_REPLY_LEN];
- uint8_t *keys;
- char *hexkeys;
+ uint8_t *keys = NULL;
+ char *hexkeys = NULL;
+ int result = 0;
char buf[256];
msg_in, keymap, NULL, node_id, msg_out, keys,
(size_t)keybytes)<0) {
fprintf(stderr, "handshake failed");
- return 2;
+ result = 2;
+ goto done;
}
base16_encode(buf, sizeof(buf), (const char*)msg_out, sizeof(msg_out));
base16_encode(hexkeys, keybytes*2+1, (const char*)keys, keybytes);
printf("%s\n", hexkeys);
+ done:
tor_free(keys);
tor_free(hexkeys);
- return 0;
+ return result;
}
static int
int keybytes;
uint8_t *keys;
char *hexkeys;
+ int result = 0;
N_ARGS(5);
BASE16(2, (&state), sizeof(state));
hexkeys = tor_malloc(keybytes*2+1);
if (onion_skin_ntor_client_handshake(&state, msg, keys, keybytes)<0) {
fprintf(stderr, "handshake failed");
- return 2;
+ result = 2;
+ goto done;
}
base16_encode(hexkeys, keybytes*2+1, (const char*)keys, keybytes);
printf("%s\n", hexkeys);
+ done:
tor_free(keys);
tor_free(hexkeys);
-
- return 0;
+ return result;
}
int