-int send_ans_key(connection_t *c, node_t *from, node_t *to)
-{
- char key[MAX_STRING_SIZE];
+bool send_ans_key(node_t *to) {
+ size_t keylen = cipher_keylength(&myself->incipher);
+ char key[keylen * 2 + 1];
+
+ cipher_open_by_nid(&to->incipher, cipher_get_nid(&myself->incipher));
+ digest_open_by_nid(&to->indigest, digest_get_nid(&myself->indigest), digest_length(&myself->indigest));
+ to->incompression = myself->incompression;
+
+ randomize(key, keylen);
+ cipher_set_key(&to->incipher, key, true);