From patchwork Mon Aug 7 17:22:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogenes Pereira X-Patchwork-Id: 9885889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78F60602CC for ; Mon, 7 Aug 2017 17:40:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6866A286D5 for ; Mon, 7 Aug 2017 17:40:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D09F286D9; Mon, 7 Aug 2017 17:40:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDCF6286D5 for ; Mon, 7 Aug 2017 17:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751929AbdHGRkx (ORCPT ); Mon, 7 Aug 2017 13:40:53 -0400 Received: from mail-qk0-f179.google.com ([209.85.220.179]:32962 "EHLO mail-qk0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbdHGRkv (ORCPT ); Mon, 7 Aug 2017 13:40:51 -0400 Received: by mail-qk0-f179.google.com with SMTP id a77so6733385qkb.0 for ; Mon, 07 Aug 2017 10:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesar-org-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=cJ1xdy0E0wSWZ2yNiA1LTkJ9waNJDlW3hPvl10DXefg=; b=oYxjIMwTxdt4qb7uLEqyQeb0E19hFDW8nlaZ38//mp+N3iG3EWLpcxW9bu+L9+1v4c ZASo9N3qXp4z/5JwLOx4EfHX5FAdpxwk/sqFXG41xjvwD5/jXf5E7pXQez0fM212DXqU /tbJ3a9/rwnuUIHzflStytPyV5gHwGHf5c6Sez5qrNI8aQhj+GKUrUv0mhDu3kFFT/TK bdR8Qbw/FXl2A9vnOGRroCyZj/LtinVwoimbfLYS4H/aN4/5ssEIRA4eejVlkbyzEOLg 6nT/9ZXf75GdNxasxMMxkNbP/9NyCkYE+BAzJrpgtIYTDIpluH9IJI812Iw+EoXPuUCy +Q2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cJ1xdy0E0wSWZ2yNiA1LTkJ9waNJDlW3hPvl10DXefg=; b=sQYzgjNgcVXaWWVB2T9heF6BZBtXx8TPcT30qSQwQOELf9b20ilxX7j9hLW5niIbXO tJ0389k2NTaZNkKaWdRggiRyF2PfV0tdc46dSXA+gN2N0fLy2Zm+zFKvEwEApmt7QjK2 uVKMfYw1nnkIWdvkgnjp65Ht+eSOF091Ng8Oaek4IifFE1vTRsp7Th9H+wgRFceZfHc9 hLDzGZJ4qzwkJ85Ry+L1zo7/QVTNwerNx5N/p+gGCnXAT1zRzErJ1Z5LnIEDy01YXf9R XAVmbYN3ii4DRiKa/cv4TAmSvgcD3Gm0968cudGaUjAkUTYRSPwvi0U1a8q+AEN5VAcZ BAqA== X-Gm-Message-State: AHYfb5hwNH311Q7ZHo5edQLcpEfDfQlS2eO8XO2DvWB3YywwJtlAFX68 7l4AD9ssGDa5WvI29Xk= X-Received: by 10.55.68.70 with SMTP id r67mr1822433qka.63.1502127649790; Mon, 07 Aug 2017 10:40:49 -0700 (PDT) Received: from dvnp-VM.cesar.intranet (mikiko.cesar.org.br. [200.199.23.104]) by smtp.gmail.com with ESMTPSA id b5sm6010419qkh.82.2017.08.07.10.40.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 10:40:48 -0700 (PDT) From: Diogenes Pereira To: linux-wpan@vger.kernel.org Cc: aar@pengutronix.de, stefan@osg.samsung.com, Diogenes Pereira Subject: [PATCH v0 1/2] mac802154: fix header and payload encrypted Date: Mon, 7 Aug 2017 14:22:39 -0300 Message-Id: <1502126560-24462-1-git-send-email-dvnp@cesar.org.br> X-Mailer: git-send-email 2.7.4 Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to 802.15.4-2015 specification (section 9.2.1 Outgoing frame security procedure) just the outgoing payload is encrypted. The header carries security parameters to destination address, so is not encrypted. Signed-off-by: Diogenes Pereira --- net/mac802154/llsec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c index 1e1c9b2..3c8ae3f 100644 --- a/net/mac802154/llsec.c +++ b/net/mac802154/llsec.c @@ -623,13 +623,18 @@ llsec_do_encrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec, u8 iv[16]; struct scatterlist src; SKCIPHER_REQUEST_ON_STACK(req, key->tfm0); - int err; + int err, datalen; + unsigned char *data; llsec_geniv(iv, sec->params.hwaddr, &hdr->sec); - sg_init_one(&src, skb->data, skb->len); + + data = skb_mac_header(skb) + skb->mac_len; + datalen = skb_tail_pointer(skb) - data; + + sg_init_one(&src, data, datalen); skcipher_request_set_tfm(req, key->tfm0); skcipher_request_set_callback(req, 0, NULL, NULL); - skcipher_request_set_crypt(req, &src, &src, skb->len, iv); + skcipher_request_set_crypt(req, &src, &src, datalen, iv); err = crypto_skcipher_encrypt(req); skcipher_request_zero(req); return err;