Commit 378be94a authored by Julien Muchembled's avatar Julien Muchembled

fixup! Add no_hmac_verify flag

Commit a62b7c9b was broken in that
2 nodes with same id/hmac settings could not communicate when
1 of the 2 has no_hmac_verify.
parent 4b06eebb
...@@ -259,6 +259,7 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen, ...@@ -259,6 +259,7 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
{ {
int i = bodylen + 4; int i = bodylen + 4;
int len; int len;
int rc = -1;
debugf("check_hmac %s -> %s\n", debugf("check_hmac %s -> %s\n",
format_address(src), format_address(dst)); format_address(src), format_address(dst));
...@@ -278,8 +279,9 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen, ...@@ -278,8 +279,9 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
packet + i + 2, len, ifp->key); packet + i + 2, len, ifp->key);
if(ok) if(ok)
return 1; return 1;
rc = 0;
} }
i += len + 2; i += len + 2;
} }
return 0; return rc;
} }
...@@ -580,21 +580,24 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -580,21 +580,24 @@ parse_packet(const unsigned char *from, struct interface *ifp,
bodylen = packetlen - 4; bodylen = packetlen - 4;
} }
if(ifp->key != NULL && !(ifp->flags & IF_NO_HMAC_VERIFY)) { if(ifp->key != NULL) {
if(check_hmac(packet, packetlen, bodylen, from, to, ifp) != 1) { switch(check_hmac(packet, packetlen, bodylen, from, to, ifp)) {
fprintf(stderr, "Received wrong hmac.\n"); case -1:
return; if(ifp->flags & IF_NO_HMAC_VERIFY)
} break; /* missing key ignored */
case 0:
neigh = find_neighbour(from, ifp); fprintf(stderr, "Received wrong hmac.\n");
if(neigh == NULL) { return;
fprintf(stderr, "Couldn't allocate neighbour.\n"); case 1:
return; neigh = find_neighbour(from, ifp);
} if(neigh == NULL) {
fprintf(stderr, "Couldn't allocate neighbour.\n");
if(preparse_packet(packet, bodylen, neigh, ifp) == 0) { return;
fprintf(stderr, "Received wrong PC or failed the challenge.\n"); }
return; if(preparse_packet(packet, bodylen, neigh, ifp) == 0) {
fprintf(stderr, "Received wrong PC or failed the challenge.\n");
return;
}
} }
} }
......
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