+
+ /* Update our copy of the origin's packet key */
+ from->outkey = xrealloc(from->outkey, strlen(key) / 2);
+
+ from->outkey = xstrdup(key);
+ from->outkeylength = strlen(key) / 2;
+ hex2bin(key, from->outkey, from->outkeylength);
+
+ /* Check and lookup cipher and digest algorithms */
+
+ if(cipher) {
+ from->outcipher = EVP_get_cipherbynid(cipher);
+
+ if(!from->outcipher) {
+ logger(LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name,
+ from->hostname);
+ return true;
+ }
+
+ if(from->outkeylength != from->outcipher->key_len + from->outcipher->iv_len) {
+ logger(LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name,
+ from->hostname);
+ return true;
+ }
+ } else {
+ from->outcipher = NULL;
+ }
+
+ from->outmaclength = maclength;
+
+ if(digest) {
+ from->outdigest = EVP_get_digestbynid(digest);
+
+ if(!from->outdigest) {
+ logger(LOG_ERR, "Node %s (%s) uses unknown digest!", from->name,
+ from->hostname);
+ return true;
+ }
+
+ if(from->outmaclength > from->outdigest->md_size || from->outmaclength < 0) {
+ logger(LOG_ERR, "Node %s (%s) uses bogus MAC length!",
+ from->name, from->hostname);
+ return true;
+ }
+ } else {
+ from->outdigest = NULL;
+ }
+
+ if(compression < 0 || compression > 11) {
+ logger(LOG_ERR, "Node %s (%s) uses bogus compression level!", from->name, from->hostname);
+ return true;
+ }
+
+ from->outcompression = compression;
+
+ if(from->outcipher)
+ if(!EVP_EncryptInit_ex(&from->outctx, from->outcipher, NULL, (unsigned char *)from->outkey, (unsigned char *)from->outkey + from->outcipher->key_len)) {
+ logger(LOG_ERR, "Error during initialisation of key from %s (%s): %s",
+ from->name, from->hostname, ERR_error_string(ERR_get_error(), NULL));
+ return true;
+ }
+
+ from->status.validkey = true;
+ from->sent_seqno = 0;
+
+ if(*address && *port) {
+ ifdebug(PROTOCOL) logger(LOG_DEBUG, "Using reflexive UDP address from %s: %s port %s", from->name, address, port);
+ sockaddr_t sa = str2sockaddr(address, port);
+ update_node_udp(from, &sa);
+ }
+
+ if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuprobes)
+ send_mtu_probe(from);
+
+ return true;