Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1397993ybi; Sat, 8 Jun 2019 08:52:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo86Bqj9fdHHV7p/KBqY5QADtv7Zxu7zHl8/jEVJpwA4oGSNtPMU7vyeONYYcB8AVIHEfs X-Received: by 2002:a17:902:8ec7:: with SMTP id x7mr20399146plo.50.1560009126127; Sat, 08 Jun 2019 08:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560009126; cv=none; d=google.com; s=arc-20160816; b=AEya5E1PB1UxYLyBKpVqiY2DFh5TmmjauwqWl9i0a+7j3Pzv882m2cFvkhe/mxuwnU 73lWyBttYtzNZUD/9shy7lW204pKDqQmtvr8P7gxnyFdd96nKnPFu1pxqhqg15hd4BID lbn7JnZ4LsRcLBRnWbKA6N6uDZUiurjF6Y9/LhVJpxUF8iOkLfH9zyI0HiQ9zG1VRYoi v64uD/RDSVMQhIUq7QuyFr660g3NnmZ/Gvwo2VevCJc/k1M9a0a6CRxLUuZsoTv2Ssgr 2cMnKqTxvv603ESRWYVYfs9ksnm7wNKA45F3/WUSnaReF+bnFjhPtPW6QHqAyAofXMd+ 3hrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6hKpkFL1XfxDKGwehxlIu+lQy2Itff4tWF+Dz7nbA5Y=; b=PwEdgDPG9eEz9AquUkhbqGu4tgyyIqeIB/04D91LgPfkJjPO+jQoWPAza7Me+hEF85 21Aj8drEgs6S+jTgusmFAOZbzcbxtQqcADXfNoFPyjqw24F5qrJUDu97YANv2RtAPyZh gmDwONMO9Fcu+3D5k0FzbC5TmJdjFtq2sRR2JdbCJgGbEBxfkHc76bT3dDy64mOVCtLg SCFYv2bOa8lJkJ8oqfQM49Gqhpi31tjRidAPSkIjAQuU0zhWyVlwwUUAY2Szi5QNoaIH DPUdGrplPluByAji+Lhow5ydm5qXfH94RAngVNE54xTN5zLMv9NTfHUnCsxUnw9822uj Lqhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G427dAGF; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si5454503pfd.210.2019.06.08.08.51.42; Sat, 08 Jun 2019 08:52:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G427dAGF; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbfFHPvg (ORCPT + 99 others); Sat, 8 Jun 2019 11:51:36 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:37556 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbfFHPvg (ORCPT ); Sat, 8 Jun 2019 11:51:36 -0400 Received: by mail-it1-f194.google.com with SMTP id x22so7299769itl.2 for ; Sat, 08 Jun 2019 08:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6hKpkFL1XfxDKGwehxlIu+lQy2Itff4tWF+Dz7nbA5Y=; b=G427dAGFEGx349h3blBiwORFKD+GZBU2DsXkxAJST2pWyX+PHTykQuwP++jTYeI6Fb fsTnuHYoTjSTcQbZoPwb/hu6yy6s3fj5QApXqz8IGeDcaNHehpeLneiHptcOAs6VUlRO PjgzmMkzuy/qREToTSYvY/kkGit+pX0axQch7w4ytSgoL1vBhl7YiLdEhp1/mMKsZiZZ lbH7SRrVy4i4jcmdkzHv8A7QgKbzCqV0Johmv3Uc7dnF3qtdyc2p5ymdYpsKk8srXD9M fhoW+6nfvjFe41sCAcRb1gCC0Qx+J8vc+Z3J+wAg22X5yrhDyatZ6S2Afwma4jMUYfRQ Q+uw== 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=6hKpkFL1XfxDKGwehxlIu+lQy2Itff4tWF+Dz7nbA5Y=; b=EShkFzNBAOb64oqpAV1hidP/iuDHE+2NhJwr7aXC6PBCIjJKQ8S+RkLThx4yZq81md 92jq/GulbcYAmT8HrNJVDYdQOixxxbA5NGoNpH2BR9N6EnSfG/MVWn0ZHFozALhxO31Y NAmDRCu7AxUtmqoryAyxdtqmWyjLKFEpctnU/7juRHSprXKD5WA2VX3Bv1uRV9LsDroc 9oVzXCqIUIHrQtqVvh9aLrmxTFq3hA5zVhDevH46bdXQSz0acF+tkSXDxgWYZ9C9kkgN T+VDH4ESS5zvXV2sfTjnPWRk4C5fF3VcEehBJ+QwEm9iWhRVrJy1YasFhsgL5IuFYNmL F5Zg== X-Gm-Message-State: APjAAAUVWGLLN3yYMbhEw62h9x/BYvZ9i+poX1bM0v7SZV/o/S1G1sMf FGhWYFFUCG8zBLt0IG2zNmY+4iZDBWQc11dfUW6pYQ== X-Received: by 2002:a05:660c:44a:: with SMTP id d10mr7371332itl.153.1560009095347; Sat, 08 Jun 2019 08:51:35 -0700 (PDT) MIME-Version: 1.0 References: <20190607144944.13485-1-ard.biesheuvel@linaro.org> <20190607175947.GB648@sol.localdomain> <97BB95F6-4A4C-4984-9EAB-6069E19B4A4F@holtmann.org> <20190607211514.GD648@sol.localdomain> <20190607214120.GE648@sol.localdomain> <78298612-a36b-deaa-1510-94cf0001af9d@gmail.com> <20190607224040.GG648@sol.localdomain> <61e1cd8a-4891-4e37-417e-1c31cd95a278@gmail.com> In-Reply-To: From: Ard Biesheuvel Date: Sat, 8 Jun 2019 17:51:20 +0200 Message-ID: Subject: Re: [RFC PATCH 0/3] move WEP implementation to skcipher interface To: Sandy Harris Cc: Denis Kenzior , Eric Biggers , Marcel Holtmann , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Herbert Xu , Johannes Berg , "open list:NFC SUBSYSTEM" , "David S. Miller" Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sat, 8 Jun 2019 at 16:37, Ard Biesheuvel wrote: > > On Sat, 8 Jun 2019 at 15:03, Sandy Harris wrote: > > > > First off, it is not clear we should implement WEP at all since it is > > fatally flawed. This has been known for about a decade, there have > > been at least two better algorithms added to the standards, & the only > > reason anyone would need WEP today would be to connect to an old > > router in an obviously insecure way. > > https://www.schneier.com/blog/archives/2007/04/breaking_wep_in.html > > https://www.tomshardware.com/reviews/wireless-security-hack,2981-4.html > > > > Twenty years ago the FreeS/WAN project implemented IPsec for Linux & > > deliberately did not include things like single DES which were known > > to be insecure: > > https://www.freeswan.org/freeswan_trees/freeswan-1.99/doc/compat.html#dropped > > I think a similar policy was would be a fine idea for the kernel today > > & WEP is hopelessly insecure. > > > > It is actually pretty clear that we should implement WEP, simply > because we already do. We all know how broken it is, but that does not > mean we should be the ones policing its use. People may have good > reasons to stick with WEP in their particular use case, or maybe they > have bad reasons, but the bottom line is that it does not really > matter: if it works today, we can't just remove it. > > What we can do is make the existing code less of an eyesore than it > already is, and in the context of what I want to achieve for the > crypto API, this involves moving it from the cipher API to something > else. > > > > > As I am attempting to explain, ecb(arc4) does not implement this API correctly > > > > because it updates the *key* after each operation, not the IV. I doubt this is > > > > documented anywhere, but this can only be changed if people aren't relying on it > > > > already. > > > > It is more the case that the API does not apply to arc4, or more > > generally to stream ciphers, than that "ecb(arc4) does not implement > > this API correctly". > > > > ECB (electronic code book) is a mode of operation for block ciphers > > https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation > > Stream ciphers do not have those modes. > > > > This is exactly the point Eric was making. Our skcipher abstraction > deals with stream ciphers fine, but the way the arc4 code is exposed > as ecb(arc4) and updates the key in the process makes absolutely no > sense. > > > For that matter, not all block cipher modes use an IV. The very common > > CBC mode -- the only mode used in IPsec, for example -- does, but > > others including ECB do not. I do not know of any mode that ever > > updates the IV. CBC uses the IV with the first block & on all other > > blocks uses the ciphertext from the previous block the same way; one > > might call that updating the IV I suppose, but I do not see why one > > would want to. > > > > If you want to split up a CBC transformation into several invocations > of the underlying API, then the last ciphertext block of the first > call serves as the IV for the next call. Arguing that we should not be > calling this an IV serves little purpose, since the code already > treats it exactly the same. In fact, our CTS template relies on this > feature as well, so a CBC implementation that does not return the last > ciphertext block in the IV buffer is broken wrt our API requirements. > > > > It sounds to me like it was broken and should be fixed. So our vote / > > > preference is to have ARC4 fixed to follow the proper semantics. > > > > As I see it, those are clearly not "he proper semantics" for a stream > > cipher & the question of forcing it into them should not even arise. > > > > One alternative would be to drop arc4. That would make sense if WEP is > > the only usage & we elect to drop WEP. One could also argue the arc4 > > itself is insecure & should go, but I'm not sure that is accurate. > > Certainly there have been some published attacks & other stream > > ciphers are now generally preferrred, but I have not followed things > > closely enough to know if RC$ should be considered fatally flawed. > > > > A better choice might be to change the interface, defining a new > > interface for stream ciphers and/or generalising the interface so it > > works for either stream ciphers or block ciphers. > > Dropping WEP is out of the question, and apparently, there are > userspace dependencies on the ecb(arc4) cipher as well, so > unfortunately, we have already painted ourselves into a corner here. > > skcipher works fine for block ciphers wrapped in CTR mode, and for > chacha/salsa as well, so I don't think there is a problem with the API > for other stream ciphers we care about. Calling the rc4 skcipher > 'ecb(arc4)' was obviously a mistake, but it seems we're stuck with > that as well :-( As it turns out, we have other users of ecb(arc4) in the MPPE code, the kerberos code and some realtek code in the staging tree. More interestingly, the code this series changes was recently converted from skcipher to cipher, while I am doing the opposite. Given Eric's analysis that few of these users actually take advantage of the crypto API (i.e., they all use the sync variety and hardcode the algo name), we can simplify them to use library calls instead. The only remaining skcipher user would be the Kerberos code, which dynamically instantiates skciphers with a parameterized algo name.