Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp713745pxf; Thu, 1 Apr 2021 11:33:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4nkjMQGwbnFRkT8+3NFO3FEa9RMwOUdtsx8z4/IkVDpPaihdhCBZyCp9yzJ6pxNBFVrcj X-Received: by 2002:a17:907:c16:: with SMTP id ga22mr10566862ejc.120.1617302039584; Thu, 01 Apr 2021 11:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617302039; cv=none; d=google.com; s=arc-20160816; b=WU+yNOte0xsh5PRU8a3Ijbier6K9NpvCa8zYxPxpVhZcP7c0UBcnBtJ4kmmnKEaQCq QcH2rWhpMj6o1ikdmVqThnkitepGWixF3oZbhBl11FAaWiD0GbwwxewHhhL9+BFCSr9p S13XAmgsgNT1E/ZDI/C0+P3d7RMxKJl9KQRF1Msvwta24iGicqKswGLejos/twFKjO6J pWLu4LyRWMAJ+NZeUOz9gU+npQBmguE++e+8ILW8SydxATRpvkUOk66mOK4gD8Du35eb wxSYr0lDMUmJ7tWdC/ghXu2rb5SU+kZf48aP/eIROlEToFY/HZCmW1oOTstV51HDCo7m KxAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2Cp9yePUaleZTFCY1eGgoqrip9Gcvm0D83eUvoixTKs=; b=gM9EgBd/s31OwSkScHE06vM1OBdTNTk8kKdoHydVbQiy6KGBwZRiKb5vwWZz66mJfB YMUprZK2l7esV0mgJt7x6MjWrgvOlm/rlt1EoyOotbO6P1D2Q2dsyrvfy9dhfFsKQHh1 PxatNAw/uxC9RfYyEHU1LkBuEHMNrjaEvb8mlHFnHJTBuqC0FvtyKtU3Kd3OqKrCyCCF d80yq3Hohsevo4FY79Zfxnsg/cYp66tRqCIlpIW217PdoKK16mKJPBXw6lhB6H84hKwF OYUvuTDc1tsQFbyC8Wwkw6a9ehNnvu68xGr6IXRwZsTxOWDfeOydcAYyPs7pt3N7m5LQ tOMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iUfU1tk4; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si5069169edd.32.2021.04.01.11.33.08; Thu, 01 Apr 2021 11:33:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iUfU1tk4; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236127AbhDAScG (ORCPT + 99 others); Thu, 1 Apr 2021 14:32:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:53242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239990AbhDAS0t (ORCPT ); Thu, 1 Apr 2021 14:26:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DBCF56023C; Thu, 1 Apr 2021 18:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617301609; bh=XM/eKl64AYtF/NjYhxGawQinsb3OUrzVM5Yt/ORJnc8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iUfU1tk4s1agyreSXqTLRnrvXWc+nxCQOErH69opvfdFYdsoEWg3KkBNDPgCuFwkh kxFFooCipCdAUjy1yQZpJ+7ae23TJMUXguBCmTMUVmLeAT/pEpRP11mgNz1EFqrKbn MK2i5goUcObSnNYFwLi3t6fspZqfNL9gm7bdPZRtc4gMbVoknzIdAYBVPwlmz7eX0l EXBa5y9Bm1jZ/UAzVYQwGPwGtKCqtSGZ27mdjKa+DnJvqWwfdMESOo3thUAy5B32cT eMbzuDTT2IEU8qjxDnHspVTP5eaODb/RPTyebX5eL3oXIAzgZ5AN29QOqOoVA7RSEC 3ALbNShPAU1dQ== Date: Thu, 1 Apr 2021 11:26:47 -0700 From: Eric Biggers To: Chris von Recklinghausen Cc: "Rafael J. Wysocki" , Ard Biesheuvel , Simo Sorce , Dexuan Cui , "linux-pm@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: Fix hibernation in FIPS mode? Message-ID: References: <4e95307db43e2f7cc8516e645b81db7db0dd8ad4.camel@redhat.com> <504652e70f0a4e42e4927583b9ed47cd78590329.camel@redhat.com> <2b452865-ca6c-892d-f04e-3e6e2a74b598@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b452865-ca6c-892d-f04e-3e6e2a74b598@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Apr 01, 2021 at 09:54:21AM -0400, Chris von Recklinghausen wrote: > On 4/1/21 9:38 AM, Rafael J. Wysocki wrote: > > On Thu, Apr 1, 2021 at 10:47 AM Ard Biesheuvel wrote: > > > On Tue, 30 Mar 2021 at 21:56, Simo Sorce wrote: > > > > On Tue, 2021-03-30 at 21:45 +0200, Ard Biesheuvel wrote: > > > > > On Tue, 30 Mar 2021 at 20:05, Simo Sorce wrote: > > > > > > On Tue, 2021-03-30 at 16:46 +0200, Rafael J. Wysocki wrote: > > > > > > > On Tue, Mar 30, 2021 at 12:14 AM Dexuan Cui wrote: > > > > > > > > Hi, > > > > > > > > MD5 was marked incompliant with FIPS in 2009: > > > > > > > > a3bef3a31a19 ("crypto: testmgr - Skip algs not flagged fips_allowed in fips mode") > > > > > > > > a1915d51e8e7 ("crypto: testmgr - Mark algs allowed in fips mode") > > > > > > > > > > > > > > > > But hibernation_e820_save() is still using MD5, and fails in FIPS mode > > > > > > > > due to the 2018 patch: > > > > > > > > 749fa17093ff ("PM / hibernate: Check the success of generating md5 digest before hibernation") > > > > > > > > > > > > > > > > As a result, hibernation doesn't work when FIPS is on. > > > > > > > > > > > > > > > > Do you think if hibernation_e820_save() should be changed to use a > > > > > > > > FIPS-compliant algorithm like SHA-1? > > > > > > > I would say yes, it should. > > > > > > > > > > > > > > > PS, currently it looks like FIPS mode is broken in the mainline: > > > > > > > > https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg49414.html > > > > > > FYI, SHA-1 is not a good choice, it is only permitted in HMAC > > > > > > constructions and only for specified uses. If you need to change > > > > > > algorithm you should go straight to SHA-2 or SHA-3 based hashes. > > > > > > > > > > > What is the reason for using a [broken] cryptographic hash here? if > > > > > this is just an integrity check, better use CRC32 > > Not really. > > > > CRC32 is not really sufficient for integrity checking here AFAICS. It > > might be made a fallback option if MD5 is not available, but making it > > the default would be somewhat over the top IMO. > > > Would ghash be a better choice? It produces the same size digest as md5. > > Does anyone have any other suggestions of algorithms to try? > > Thanks, > > Chris > > > > > > > If the integrity check is used exclusively to verify there were no > > > > accidental changes and is not used as a security measure, by all means > > > > I agree that using crc32 is a better idea. > > > > > > > Looking at 62a03defeabd58f74e07ca030d6c21e069d4d88e which introduced > > > this, it is only a best effort check which is simply omitted if md5 > > > happens to be unavailable, so there is definitely no need for crypto > > > here. > > Yes, it is about integrity checking only. No, CRC32 is not equivalent > > to MD5 in that respect AFAICS. > > If you need to detect intentional changes (ensure authenticity, not just integrity) then you need a cryptographic MAC, such as HMAC-SHA256. If you only need to detect accidental changes (ensure integrity-only), then a checksum such as CRC-32 or xxHash64 is sufficient. A cryptographic hash function such as SHA-256 would also be sufficient, though much slower. Using a broken cryptographic hash function such as MD5 doesn't make sense because it is broken (so doesn't actually provide cryptographic security), and is much slower than a checksum. If the 1 in 4 billion collision rate of a CRC-32 isn't sufficient, then use CRC-64 or xxHash64 for a 1 in 2^64 collision rate. Don't use GHASH, as it is neither a checksum nor a cryptographic hash function. - Eric