Commit b3b6cf9b authored by Killian Lufau's avatar Killian Lufau Committed by Julien Muchembled

New ignore_no_hmac option

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.
TODO: push upstream
parent 7dee6c6f
......@@ -1226,6 +1226,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)
......
......@@ -39,6 +39,7 @@ THE SOFTWARE.
struct key **keys = NULL;
int numkeys = 0, maxkeys = 0;
int ignore_no_hmac = 0;
struct key *
find_key(const char *id)
......@@ -276,6 +277,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 +296,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;
}
......@@ -24,6 +24,8 @@ THE SOFTWARE.
#define SHA1_BLOCK_SIZE 64
#define RIPEMD160_BLOCK_SIZE 64
extern int ignore_no_hmac;
struct key *find_key(const char *id);
struct key *retain_key(struct key *key);
void release_key(struct key *key);
......
......@@ -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