From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E8A5C4363D for ; Tue, 22 Sep 2020 17:20:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C252A23119 for ; Tue, 22 Sep 2020 17:20:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ek1BIZZy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbgIVRUD (ORCPT ); Tue, 22 Sep 2020 13:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgIVRUD (ORCPT ); Tue, 22 Sep 2020 13:20:03 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D51C061755; Tue, 22 Sep 2020 10:20:03 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id e23so16334811otk.7; Tue, 22 Sep 2020 10:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EItoq1kaiHeWVc5lky8YhdzGpyspzkaqvTZAN+0uG8s=; b=ek1BIZZyVl3RntwXpKxZKVRy7AjMYd2t5ZjDu0Gkr+83ZXPJiTnzcLSziQYU5YQi9M zz5wOAudN8qHSec8RMYhz3079Sg2fztpxsFVlYPTbpjJj4NEFIouF6csvy38nV6qdvO4 LHFyhEB6+sDeNLM20tDikE0MdOwP+PWOSb8F52houXJNiMI3wO2FMRTniR98K97dgkZ4 EtCLz1jHbknfXgrX6t3JeREbjP8noQCnc9wvt1K0D+0uAg6Q1ij30KxXkn+n5pJw/Wot Jh3lFs3CaqraBeH+JP3TFUsIDL8If4ZRXHdII6p6FMHRs1zjGRt8K18vJWC8slKoX1wA E1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EItoq1kaiHeWVc5lky8YhdzGpyspzkaqvTZAN+0uG8s=; b=l0+h5lLkvRLkkQnFYZ/5cFi7WhDHwLkvwEFVEfINT1DSl/+zies1OznIRuV0Z3BaAm VMW7M1QEcE/c+uYsf4J7xr40L7fWLWvTZCF9QyOlr9Rn+l3Sr9gaJfMBR0JmQs4nVwCO GCnbhXSf+mCRQ9RLoN1YynMgH1+q3YEhCOyQ4eDJU3l28AQaJqoFHRBZeUvM+e9SfW2E /fjlgdJT2fFZQHT9FVJs8cWCK6j+H2i7jYQ5xkljd0rZqTlQoBekJDflzEhHwhBWkCDK 6F2H/BMaQ0ow0OL5GQS0lsikYszpOZZ1rr36FOdSX3Bu0sl/MOYZUFXmrlefP7WyjPj2 sxMQ== X-Gm-Message-State: AOAM531IjbME+drraLp1MfJkm4ZexmoZ4pmEMl0/g0cNPoV07MNnQGYY FARMH/iwbZAPDa7qQcElOtrbgJJ2SAZrguiEfbk= X-Google-Smtp-Source: ABdhPJwNcpShFc8c3V/UC1bmKbpnJq1sPySTQ40fTrCHUXJ486Nscbfvc9yXAnnr7C/wr8kImZHNzbiYtV9UD4Td08Q= X-Received: by 2002:a9d:4695:: with SMTP id z21mr3525657ote.91.1600795202320; Tue, 22 Sep 2020 10:20:02 -0700 (PDT) MIME-Version: 1.0 References: <20200921163021.v1.1.Id3160295d33d44a59fa3f2a444d74f40d132ea5c@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Tue, 22 Sep 2020 10:19:50 -0700 Message-ID: Subject: Re: [PATCH v1] Bluetooth: Enforce key size of 16 bytes on FIPS level To: Archie Pusaka Cc: linux-bluetooth , Marcel Holtmann , CrosBT Upstreaming , Archie Pusaka , Alain Michaud , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Linux Kernel Mailing List , "open list:NETWORKING [GENERAL]" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Archie, On Tue, Sep 22, 2020 at 12:37 AM Archie Pusaka wrote: > > Hi Luiz, > > On Tue, 22 Sep 2020 at 01:13, Luiz Augusto von Dentz > wrote: > > > > Hi Archie, > > > > On Mon, Sep 21, 2020 at 1:31 AM Archie Pusaka wrote: > > > > > > From: Archie Pusaka > > > > > > According to the spec Ver 5.2, Vol 3, Part C, Sec 5.2.2.8: > > > Device in security mode 4 level 4 shall enforce: > > > 128-bit equivalent strength for link and encryption keys required > > > using FIPS approved algorithms (E0 not allowed, SAFER+ not allowed, > > > and P-192 not allowed; encryption key not shortened) > > > > > > This patch rejects connection with key size below 16 for FIPS level > > > services. > > > > > > Signed-off-by: Archie Pusaka > > > Reviewed-by: Alain Michaud > > > > > > --- > > > > > > net/bluetooth/l2cap_core.c | 7 ++++++- > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > > > index ade83e224567..306616ec26e6 100644 > > > --- a/net/bluetooth/l2cap_core.c > > > +++ b/net/bluetooth/l2cap_core.c > > > @@ -1515,8 +1515,13 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon) > > > * that have no key size requirements. Ensure that the link is > > > * actually encrypted before enforcing a key size. > > > */ > > > + int min_key_size = hcon->hdev->min_enc_key_size; > > > + > > > + if (hcon->sec_level == BT_SECURITY_FIPS) > > > + min_key_size = 16; > > > + > > > return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || > > > - hcon->enc_key_size >= hcon->hdev->min_enc_key_size); > > > + hcon->enc_key_size >= min_key_size); > > > > While this looks fine to me, it looks like this should be placed > > elsewhere since it takes an hci_conn and it is not L2CAP specific. > > From what I understood, it is permissible to use AES-CCM P-256 > encryption with key length < 16 when encrypting the link, but such a > connection does not satisfy security level 4, and therefore must not > be given access to level 4 services. However, I think it is > permissible to give them access to level 3 services or below. > > Should I use l2cap chan->sec_level for this purpose? I'm kind of lost > on the difference between hcon->sec_level and chan->sec_level. The chan->sec_level is L2CAP channel required sec_level while hcon->sec_level is the current secure level in effect, at some point I guess we assign the hcon->sec_level with chan->sec_level but Im not sure if that has already happened here or not. > > > > > } > > > > > > static void l2cap_do_start(struct l2cap_chan *chan) > > > -- > > > 2.28.0.681.g6f77f65b4e-goog > > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz