Commit 1f08db8e authored by Killian Lufau's avatar Killian Lufau

New accept_unsigned option for HMAC

The possibility to accept packets without HMAC on interfaces
configured for HMAC is added to do non-blocking steps when
initializing HMAC on a network. We should push this upstream
parent 42b1604b
......@@ -65,6 +65,8 @@ int config_finalised = 0;
/* get_next_char callback */
typedef int (*gnc_t)(void*);
int ignore_no_hmac = 0;
static int
skip_whitespace(int c, gnc_t gnc, void *closure)
{
......@@ -1227,6 +1229,8 @@ parse_config_line(int c, gnc_t gnc, void *closure,
}
add_key(key->id, key->type, key->len, key->value);
free(key);
} else if(strcmp(token, "ignore_no_hmac") == 0) {
ignore_no_hmac = 1;
} else {
c = parse_option(c, gnc, closure, token);
if(c < -1)
......
......@@ -59,6 +59,7 @@ struct filter {
};
extern struct interface_conf *default_interface_conf;
extern int ignore_no_hmac;
void flush_ifconf(struct interface_conf *if_conf);
......
......@@ -276,6 +276,7 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
{
int i = bodylen + 4;
int len;
int rc = ignore_no_hmac ? 2 : 0;
debugf("check_hmac %s -> %s\n",
format_address(src), format_address(dst));
......@@ -294,8 +295,9 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
packet + i + 2 , len) == 1) {
return 1;
}
rc = 0;
}
i += len + 2;
}
return 0;
return rc;
}
......@@ -575,15 +575,18 @@ parse_packet(const unsigned char *from, struct interface *ifp,
}
if(ifp->key != NULL) {
if(check_hmac(packet, packetlen, bodylen, neigh->address,
to) != 1) {
fprintf(stderr, "Received wrong hmac.\n");
return;
}
if(preparse_packet(packet, bodylen, neigh, ifp) == 0) {
fprintf(stderr, "Received wrong PC or failed the challenge.\n");
return;
switch(check_hmac(packet, packetlen, bodylen, neigh->address, to)) {
case 0:
fprintf(stderr, "Received wrong hmac.\n");
return;
case 1:
if(preparse_packet(packet, bodylen, neigh, ifp) == 0) {
fprintf(stderr, "Received wrong PC or failed the challenge.\n");
return;
}
break;
case 2: /* missing key ignored */
;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment