Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp836125rwe; Wed, 31 Aug 2022 11:55:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qweqHMJNjqMw7bN52I5EXZ/D4mo0iRCLGx3vRPctbox3DtUz4g4yiBfP/7kSxat4ll+CF X-Received: by 2002:a05:6402:454:b0:447:59a8:fc7d with SMTP id p20-20020a056402045400b0044759a8fc7dmr26437854edw.68.1661972140504; Wed, 31 Aug 2022 11:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661972140; cv=none; d=google.com; s=arc-20160816; b=Rdl1lSFvaQuotcrmxwOK2iPDcV9LAIzUlCnzOTVq+w5I1XouD3nZTlfh/KNhpTIkqq 3jWCifz2bS/0MsmTx2v/PKIPMx0UdB2Kn6iN+ec/PmHCh6WzkHggoa1vTiYz2W5UIn/7 PN0qkAu9ZjIkSLhiBiMIhcfr9iDgkPDTUpHw/cs1PP6S5cXnaVnTwZhbS4Im3WgLBnPP vporUYXFi+0UJrRNpmvQV+bEvgLY4jAVgZ4OldUtobfnAgXJNTMGpwlMpB1X+BWsD15m l4NWXwthcP0MC2rOUABCMNE0o6c+TbvjTBQ4C/ZL29mK+8Xt4YEHDLMVroSogbIhLful r9NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dEU++UBToH866zrJEWnx3P4LrLN/LbOdcwtLNxqEBv8=; b=Ae3nNMUblGMeUTFyWWVDaD/cqGlEOqM9UjaUrGgY6BYMCv+U0cPnBNxFvKPV44VD1x wtUq0Lrt4fQsMtHUBijlyTF/tLW0QRvHcRnlcOR2Jq9vlywOOCw5ZjP5gPjfwwLvnIjV 2mIBkvGPQpxHqvClvehy9Q9PiR8FfOUClu2ahm2nODPXJbXlkh9vvM4Ek92amYPWDx6N SP52gEtFaofVlZ5nm6dJ8gqR7z/1NhEWtJBNfNfUT/A6k9CP1ZSr3VTAcF61W3Tc3KeC lrzyDr3CtJ/RPK1BRvFVX3rSzVVvN8LQ2Q9oZezHkW7gxJq+fyWA3h+YILtAzuKAZ0OR Vn+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=U9ZebKNx; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc3-20020a056402204300b0043d85ca3c96si9397edb.440.2022.08.31.11.55.09; Wed, 31 Aug 2022 11:55:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=U9ZebKNx; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232599AbiHaSsU (ORCPT + 99 others); Wed, 31 Aug 2022 14:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232482AbiHaSsT (ORCPT ); Wed, 31 Aug 2022 14:48:19 -0400 Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6F8543DC for ; Wed, 31 Aug 2022 11:48:16 -0700 (PDT) Received: by mail-vk1-xa2c.google.com with SMTP id s66so5291497vkb.4 for ; Wed, 31 Aug 2022 11:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=dEU++UBToH866zrJEWnx3P4LrLN/LbOdcwtLNxqEBv8=; b=U9ZebKNx1Snn9CscuSDhl5p+6YnZ1po5Ug1VuOaTebdwd2Tp0Ky9d5YyfV73lbMfsu klznxiFzDFWfdcWTtHFNZ8VCCZW64v5k+4XeicE0IYnJyc5dawoFqjHC8yaRQSoSdiOv I0zAhUk7IXlXYMO8n39DJhY1BOKnLiTLbLcjFcswCIl1ItmgOh65lrXWRK0LSTcm3xrh 7rXyHWFZgnvUU/dgiBactL0WsGoddNUOgExz4ILuuCn/5MLlTQjLhyc62Shbvb8kG307 CoMu9pBa3U5vAlrM74NYE/nwRie61x2184yMCnrhC+q2+gr04p1s0PZmFglsRPJpFLJw aV8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=dEU++UBToH866zrJEWnx3P4LrLN/LbOdcwtLNxqEBv8=; b=dDKoNIPPG55xXKHLS8z2ZroEORCRGUHdaDQ9pOb94PoxHrbDhSFVApHwN/d79oTQME AmM19NoIAyKDnDv/NBQaAhM1rRuPnyFKCZf1KqaK0iaqBa8NewjbVbVk9wO0J4mgIrwt tCUxKu4Fs7Pek7t8bAOsTD34AKQxVicQGk+aqV0YZwCBpL73pCfk/gUGAap4rNU+XK9A vxUxAadhuIsaDyhqllh+aMLc8gw3zk9ToaBzF1jmc1mSz9gMlDaMHWY3Ciw3TwCUfk5J ndyxSSpZJJFbHvjkKEDwhlnlccKyldQRsz28M11neS3ML/9Um8wom8mrtGjzDw7j3F21 ltkA== X-Gm-Message-State: ACgBeo0fbAoARTXoZjxIZBALU9F2eeBsyo8snzqpBmq9Vxt9kj9N7Fen hCJ5jni4mlnAPPSu4BQuy4QfIhGqFQdur5hB0Y2f8Q== X-Received: by 2002:a1f:1f49:0:b0:394:5a44:9a98 with SMTP id f70-20020a1f1f49000000b003945a449a98mr5452642vkf.32.1661971695746; Wed, 31 Aug 2022 11:48:15 -0700 (PDT) MIME-Version: 1.0 References: <20220818170005.747015-1-dima@arista.com> <20220818170005.747015-9-dima@arista.com> <162ae93b-5589-fbde-c63b-749f21051784@gmail.com> In-Reply-To: <162ae93b-5589-fbde-c63b-749f21051784@gmail.com> From: Dmitry Safonov Date: Wed, 31 Aug 2022 19:48:02 +0100 Message-ID: Subject: Re: [PATCH 08/31] net/tcp: Introduce TCP_AO setsockopt()s To: Leonard Crestez Cc: Andy Lutomirski , Ard Biesheuvel , Bob Gilligan , David Ahern , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers , Francesco Ruggeri , Herbert Xu , Hideaki YOSHIFUJI , Ivan Delalande , Jakub Kicinski , Paolo Abeni , Salam Noureddine , Shuah Khan , netdev@vger.kernel.org, linux-crypto@vger.kernel.org, Eric Dumazet , linux-kernel@vger.kernel.org, "David S. Miller" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 8/23/22 15:45, Leonard Crestez wrote: > On 8/18/22 19:59, Dmitry Safonov wrote: [..] >> +#define TCP_AO 38 /* (Add/Set MKT) */ >> +#define TCP_AO_DEL 39 /* (Delete MKT) */ >> +#define TCP_AO_MOD 40 /* (Modify MKT) */ > > The TCP_AO_MOD sockopt doesn't actually modify and MKT, it only controls > per-socket properties. It is equivalent to my TCP_AUTHOPT sockopt while > TCP_AO is equivalent to TCP_AUTHOPT_KEY. My equivalent of TCP_AO_DEL > sockopt is a flag inside tcp_authopt_key. Fair point, the comment could be "Modify AO", rather than "Modify MKT". On the other side, this can later support more per-key changes than in the initial proposal: i.e., zero per-key counters. Password and rcv/snd ids can't change to follow RFC text, but non-essentials may. So, the comment to the command here is not really incorrect. >> +struct tcp_ao { /* setsockopt(TCP_AO) */ >> + struct __kernel_sockaddr_storage tcpa_addr; >> + char tcpa_alg_name[64]; >> + __u16 tcpa_flags; > > This field accept TCP_AO_CMDF_CURR and TCP_AO_CMDF_NEXT which means that > you are combining key addition with key selection. Not clear it > shouldn't just always be a separate sockopt? I don't see any downside. A user can add a key and start using it immediately with one syscall instead of two. It's not necessary, one can do it in 2 setsockopt()s if they want. [..] > I also have two fields called "recv_keyid" and "recv_rnextkeyid" which > inform userspace about what the remote is sending, I'm not seeing an > equivalent on your side. Sounds like a good candidate for getsockopt() for logs/debugging. > The specification around send_keyid in the RFC is conflicting: > * User must be able to control it I don't see where you read it, care to point it out? I see choosing the current_key by marking the preferred key during an establishment of a connection, but I don't see any "MUST control current_key". We allow changing current_key, but that's actually not something required by RFC, the only thing required is to respect rnext_key that's asked by peer. > * Implementation must respect rnextkeyid in incoming packet > > I solved this apparent conflict by adding a > "TCP_AUTHOPT_FLAG_LOCK_KEYID" flag so that user can choose if it wants > to control the sending key or let it be controlled from the other side. That's exactly violating the above "Implementation must respect rnextkeyid in incoming packet". See RFC5925 (7.5.2.e). [..] > Only two algorithms are defined in RFC5926 and you have to treat one of > them as a special case. I remain convinced that generic support for > arbitrary algorithms is undesirable; it's better for the algorithm to be > specified as an enum. On contrary, I see that as a really big feature. RFC5926 was published in 2010, when sha1 was yet hard to break. These days sha1 is considered insecure. I.e., the first link from Google: > Starting with version 56, released this month, Google Chrome will mark all > SHA-1-signed HTTPS certificates as unsafe. Other major browser vendors > plan to do the same. > "Hopefully these new efforts of Google of making a real-world attack possible > will lead to vendors and infrastructure managers quickly removing SHA-1 from > their products and configurations as, despite it being a deprecated algorithm, > some vendors still sell products that do not support more modern hashing > algorithms or charge an extra cost to do so," [..] So, why limit a new TCP sign feature to already insecure algorithms? One can already use any crypto algorithms for example, in tunnels. And I don't see any benefit in defining new magic macros, only downside. I prefer UAPI that takes crypto algo name as a string, rather than new defined magic number from one of kernel headers. IOW, : strcpy(ao.tcpa_alg_name, "cmac(aes128)"); : setsockopt(sk, IPPROTO_TCP, opt, &ao, sizeof(ao)); is better than : ao.tcp_alg = TCP_AO_CMAC_MAGIC_DEFINE; : setsockopt(sk, IPPROTO_TCP, opt, &ao, sizeof(ao)); Neither I see a point in more patches adding new #define TCP_AO_NEW_ALGO BTW, I had some patches to add testing in fcnal-test.sh and covered the following algorithms, that worked just fine (test changes not included in v1): hmac(sha1) cmac(aes128) hmac(rmd128) hmac(rmd160) hmac(sha512) hmac(sha384) hmac(sha256) hmac(md5) hmac(sha224) hmac(sha3-512) No point in artificially disabling them or introducing new magic #defines. Thanks, Dmitry