Commit a62b7c9b authored by Etienne MARAIS's avatar Etienne MARAIS Committed by Juliusz Chroboczek

Add no_hmac_verify flag.

Flag to allow empty or wrong hmac in the packet trailer.
parent 1544810a
...@@ -414,6 +414,11 @@ otherwise. ...@@ -414,6 +414,11 @@ otherwise.
Send multiple copies of TLVs other than Hellos to all neighbours rather Send multiple copies of TLVs other than Hellos to all neighbours rather
than sending a single multicast packet. The default is false. than sending a single multicast packet. The default is false.
.TP .TP
.BR no_hmac_verify " {" true | false }
Do not check packet signatures, accept unsigned or incorrectly signed packets
even if one or more keys are configured on the interface. The default is
.BR false .
.TP
.BR rfc6126\-compatible " {" true | false } .BR rfc6126\-compatible " {" true | false }
Disable some features that are incompatible with RFC 6126 (the older Disable some features that are incompatible with RFC 6126 (the older
version of the Babel protocol), such as source-specific routing and RTT version of the Babel protocol), such as source-specific routing and RTT
......
...@@ -607,6 +607,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure, ...@@ -607,6 +607,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if(c < -1) if(c < -1)
goto error; goto error;
if_conf->unicast = v; if_conf->unicast = v;
} else if(strcmp(token, "no_hmac_verify") == 0) {
int v;
c = getbool(c, &v, gnc, closure);
if(c < -1)
goto error;
if_conf->no_hmac_verify = v;
} else if(strcmp(token, "link-quality") == 0) { } else if(strcmp(token, "link-quality") == 0) {
int v; int v;
c = getbool(c, &v, gnc, closure); c = getbool(c, &v, gnc, closure);
...@@ -829,6 +835,7 @@ merge_ifconf(struct interface_conf *dest, ...@@ -829,6 +835,7 @@ merge_ifconf(struct interface_conf *dest,
MERGE(lq); MERGE(lq);
MERGE(faraway); MERGE(faraway);
MERGE(unicast); MERGE(unicast);
MERGE(no_hmac_verify);
MERGE(channel); MERGE(channel);
MERGE(enable_timestamps); MERGE(enable_timestamps);
MERGE(rfc6126); MERGE(rfc6126);
......
...@@ -396,7 +396,8 @@ interface_updown(struct interface *ifp, int up) ...@@ -396,7 +396,8 @@ interface_updown(struct interface *ifp, int up)
if(IF_CONF(ifp, unicast) == CONFIG_YES) if(IF_CONF(ifp, unicast) == CONFIG_YES)
ifp->flags |= IF_UNICAST; ifp->flags |= IF_UNICAST;
if(IF_CONF(ifp, no_hmac_verify) == CONFIG_YES)
ifp->flags |= IF_NO_HMAC_VERIFY;
if(IF_CONF(ifp, hello_interval) > 0) if(IF_CONF(ifp, hello_interval) > 0)
ifp->hello_interval = IF_CONF(ifp, hello_interval); ifp->hello_interval = IF_CONF(ifp, hello_interval);
else if(type == IF_TYPE_WIRELESS) else if(type == IF_TYPE_WIRELESS)
......
...@@ -53,6 +53,7 @@ struct interface_conf { ...@@ -53,6 +53,7 @@ struct interface_conf {
char lq; char lq;
char faraway; char faraway;
char unicast; char unicast;
char no_hmac_verify;
int channel; int channel;
int enable_timestamps; int enable_timestamps;
int rfc6126; int rfc6126;
...@@ -84,6 +85,8 @@ struct interface_conf { ...@@ -84,6 +85,8 @@ struct interface_conf {
#define IF_TIMESTAMPS (1 << 6) #define IF_TIMESTAMPS (1 << 6)
/* Remain compatible with RFC 6126. */ /* Remain compatible with RFC 6126. */
#define IF_RFC6126 (1 << 7) #define IF_RFC6126 (1 << 7)
/* Packets with a wrong or empty packet trailer are accepted */
#define IF_NO_HMAC_VERIFY (1 << 8)
/* Use Babel over DTLS on this interface. */ /* Use Babel over DTLS on this interface. */
#define IF_DTLS (1 << 9) #define IF_DTLS (1 << 9)
......
...@@ -586,17 +586,16 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -586,17 +586,16 @@ parse_packet(const unsigned char *from, struct interface *ifp,
return; return;
} }
if(ifp->key != NULL) { if(ifp->key != NULL && !(ifp->flags & IF_NO_HMAC_VERIFY)) {
if(check_hmac(packet, packetlen, bodylen, neigh->address, if(check_hmac(packet, packetlen, bodylen, neigh->address, to) != 1) {
to) != 1) { fprintf(stderr, "Received wrong hmac.\n");
fprintf(stderr, "Received wrong hmac.\n"); return;
return; }
}
if(preparse_packet(packet, bodylen, neigh, ifp) == 0) { if(preparse_packet(packet, bodylen, neigh, ifp) == 0) {
fprintf(stderr, "Received wrong PC or failed the challenge.\n"); fprintf(stderr, "Received wrong PC or failed the challenge.\n");
return; return;
} }
} }
i = 0; i = 0;
......
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