- // Set key parameters
- to->incipher = myself->incipher;
- to->inkeylength = myself->inkeylength;
- to->indigest = myself->indigest;
+ bin2hex(key, key, ECDH_SIZE);
+ key[ECDH_SIZE * 2] = '\0';
+
+ return send_request(to->nexthop->connection, "%d %s %s ECDH:%s %d %d %zu %d", ANS_KEY,
+ myself->name, to->name, key,
+ cipher_get_nid(&myself->incipher),
+ digest_get_nid(&myself->indigest),
+ digest_length(&myself->indigest),
+ myself->incompression);
+}
+
+bool send_ans_key(node_t *to) {
+ if(to->status.ecdh)
+ return send_ans_key_ecdh(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));