logger(DEBUG_ALWAYS, LOG_DEBUG, "Got REQ_KEY from %s while we already started a SPTPS session!", from->name);
char buf[MAX_STRING_SIZE];
- if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1) {
+ int len;
+
+ if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "REQ_SPTPS_START", from->name, from->hostname, "invalid SPTPS data");
return true;
}
- int len = b64decode(buf, buf, strlen(buf));
char label[25 + strlen(from->name) + strlen(myself->name)];
snprintf(label, sizeof label, "tinc UDP key expansion %s %s", from->name, myself->name);
}
char buf[MAX_STRING_SIZE];
- if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1) {
+ int len;
+ if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "REQ_SPTPS", from->name, from->hostname, "invalid SPTPS data");
return true;
}
- int len = b64decode(buf, buf, strlen(buf));
sptps_receive_data(&from->sptps, buf, len);
return true;
}
abort();
randomize(key, keylen);
- cipher_set_key(to->incipher, key, false);
- digest_set_key(to->indigest, key, keylen);
+ if(!cipher_set_key(to->incipher, key, false))
+ abort();
+ if(!digest_set_key(to->indigest, key, keylen))
+ abort();
bin2hex(key, key, keylen);
char buf[strlen(key)];
int len = b64decode(key, buf, strlen(key));
- if(!sptps_receive_data(&from->sptps, buf, len))
+ if(!len || !sptps_receive_data(&from->sptps, buf, len))
logger(DEBUG_ALWAYS, LOG_ERR, "Error processing SPTPS data from %s (%s)", from->name, from->hostname);
if(from->status.validkey) {
update_node_udp(from, &sa);
}
- if(from->options & OPTION_PMTU_DISCOVERY)
+ if(from->options & OPTION_PMTU_DISCOVERY && !(from->options & OPTION_TCPONLY))
send_mtu_probe(from);
}
/* Check and lookup cipher and digest algorithms */
- if(!(from->outcipher = cipher_open_by_nid(cipher))) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name, from->hostname);
- return false;
+ if(cipher) {
+ if(!(from->outcipher = cipher_open_by_nid(cipher))) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name, from->hostname);
+ return false;
+ }
+ } else {
+ from->outcipher = NULL;
}
- if(!(from->outdigest = digest_open_by_nid(digest, maclength))) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses unknown digest!", from->name, from->hostname);
- return false;
+ if(digest) {
+ if(!(from->outdigest = digest_open_by_nid(digest, maclength))) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses unknown digest!", from->name, from->hostname);
+ return false;
+ }
+ } else {
+ from->outdigest = NULL;
}
if(maclength != digest_length(from->outdigest)) {
/* Update our copy of the origin's packet key */
- cipher_set_key(from->outcipher, key, true);
- digest_set_key(from->outdigest, key, keylen);
+ if(!cipher_set_key(from->outcipher, key, true))
+ return false;
+ if(!digest_set_key(from->outdigest, key, keylen))
+ return false;
from->status.validkey = true;
from->sent_seqno = 0;
update_node_udp(from, &sa);
}
- if(from->options & OPTION_PMTU_DISCOVERY)
+ if(from->options & OPTION_PMTU_DISCOVERY && !(from->options & OPTION_TCPONLY))
send_mtu_probe(from);
return true;