Skip to content

Commit 3e49626

Browse files
dvnpStefan Schmidt
authored andcommitted
mac802154: Fix MAC header and payload encrypted
According to 802.15.4-2003/2006/2015 specifications the MAC frame is composed of MHR, MAC payload and MFR and just the outgoing MAC payload must be encrypted. If communication is secure,sender build Auxiliary Security Header(ASH), insert it next to the standard MHR header with security enabled bit ON, and secure frames before transmitting them. According to the information carried within the ASH, recipient retrieves the right cryptographic key and correctly un-secure MAC frames. The error scenario occurs on Linux using IEEE802154_SCF_SECLEVEL_ENC(4) security level when llsec_do_encrypt_unauth() function builds theses MAC frames incorrectly. On recipients these MAC frames are discarded,logging "got invalid frame" messages. Signed-off-by: Diogenes Pereira <dvnp@cesar.org.br> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
1 parent 91f4aa9 commit 3e49626

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

net/mac802154/llsec.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,18 @@ llsec_do_encrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec,
623623
u8 iv[16];
624624
struct scatterlist src;
625625
SKCIPHER_REQUEST_ON_STACK(req, key->tfm0);
626-
int err;
626+
int err, datalen;
627+
unsigned char *data;
627628

628629
llsec_geniv(iv, sec->params.hwaddr, &hdr->sec);
629-
sg_init_one(&src, skb->data, skb->len);
630+
/* Compute data payload offset and data length */
631+
data = skb_mac_header(skb) + skb->mac_len;
632+
datalen = skb_tail_pointer(skb) - data;
633+
sg_init_one(&src, data, datalen);
634+
630635
skcipher_request_set_tfm(req, key->tfm0);
631636
skcipher_request_set_callback(req, 0, NULL, NULL);
632-
skcipher_request_set_crypt(req, &src, &src, skb->len, iv);
637+
skcipher_request_set_crypt(req, &src, &src, datalen, iv);
633638
err = crypto_skcipher_encrypt(req);
634639
skcipher_request_zero(req);
635640
return err;

0 commit comments

Comments
 (0)