From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1046451AbdDXGGT (ORCPT ); Mon, 24 Apr 2017 02:06:19 -0400 Received: from mail-yw0-f175.google.com ([209.85.161.175]:33294 "EHLO mail-yw0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1046434AbdDXGGL (ORCPT ); Mon, 24 Apr 2017 02:06:11 -0400 MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] In-Reply-To: References: <1492693983-8175-1-git-send-email-gilad@benyossef.com> <1492693983-8175-7-git-send-email-gilad@benyossef.com> <6020947.G2hzgUSCE3@positron.chronox.de> From: Gilad Ben-Yossef Date: Mon, 24 Apr 2017 09:06:09 +0300 Message-ID: Subject: Re: [PATCH v2 6/9] staging: ccree: add FIPS support To: =?UTF-8?Q?Stephan_M=C3=BCller?= Cc: Herbert Xu , "David S. Miller" , Rob Herring , Mark Rutland , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, Linux kernel mailing list , Gilad Ben-Yossef , Binoy Jayan , Ofir Drang , Stuart Yoder Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v3O66Qpw000606 On Sun, Apr 23, 2017 at 12:48 PM, Gilad Ben-Yossef wrote: > Hi, > > Thank you for the review. > > On Thu, Apr 20, 2017 at 4:39 PM, Stephan Müller wrote: > >>> +/* The function verifies that tdes keys are not weak.*/ >>> +static int ssi_fips_verify_3des_keys(const u8 *key, unsigned int keylen) >>> +{ >>> +#ifdef CCREE_FIPS_SUPPORT >>> + tdes_keys_t *tdes_key = (tdes_keys_t*)key; >>> + >>> + /* verify key1 != key2 and key3 != key2*/ >> >> I do not think that this check is necessary. There is no FIPS requirement or >> IG that mandates this (unlike the XTS key check). >> >> If there would be such requirement, we would need a common service function >> for all TDES implementations Well, it turns out there is and we do :-) This is from crypto/des_generic.c: /* * RFC2451: * * For DES-EDE3, there is no known need to reject weak or * complementation keys. Any weakness is obviated by the use of * multiple keys. * * However, if the first two or last two independent 64-bit keys are * equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the * same as DES. Implementers MUST reject keys that exhibit this * property. * */ int __des3_ede_setkey(u32 *expkey, u32 *flags, const u8 *key, unsigned int keylen) However, this does not check that k1 == k3. In this case DES3 becomes 2DES (2-keys TDEA), the use of which was dropped post 2015 by NIST Special Publication 800-131A*. Would it be acceptable if I offer a patch adding this check to __des3_ede_setkey() and use that in the ccree driver? * http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar1.pdf Many thanks, Gilad -- Gilad Ben-Yossef Chief Coffee Drinker "If you take a class in large-scale robotics, can you end up in a situation where the homework eats your dog?" -- Jean-Baptiste Queru