-bool send_ans_key(node_t *to) {
- if(to->status.sptps)
- abort();
-
- size_t keylen = cipher_keylength(myself->incipher);
- char key[keylen * 2 + 1];
-
- cipher_close(to->incipher);
- digest_close(to->indigest);
-
- to->incipher = cipher_open_by_nid(cipher_get_nid(myself->incipher));
- to->indigest = digest_open_by_nid(digest_get_nid(myself->indigest), digest_length(myself->indigest));
- to->incompression = myself->incompression;
-
- if(!to->incipher || !to->indigest)
- abort();
-
- randomize(key, keylen);
- if(!cipher_set_key(to->incipher, key, false))
- abort();
- if(!digest_set_key(to->indigest, key, keylen))
- abort();
-
- bin2hex(key, key, keylen);
-
- // Reset sequence number and late packet window
- mykeyused = true;
- to->received_seqno = 0;
- to->received = 0;
- if(replaywin) memset(to->late, 0, replaywin);
-
- return send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY,
- myself->name, to->name, key,
- cipher_get_nid(to->incipher),
- digest_get_nid(to->indigest),
- (int)digest_length(to->indigest),
- to->incompression);