Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4081744ybg; Tue, 29 Oct 2019 01:44:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwisoDfhyrQWPXjAGCVGltyt6GqOGmbDpi3w0I9zhH6IvO3lJcRPA3OVebtPpYsVrUZgB7l X-Received: by 2002:a17:906:1e07:: with SMTP id g7mr2096399ejj.256.1572338645671; Tue, 29 Oct 2019 01:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572338645; cv=none; d=google.com; s=arc-20160816; b=j5e5JICa1qaCegI5qO2MD1/c4ORE4GQw28zjMrjG0KMDZc2NehdUgJGrYarmayVlC2 YSXqHQHZ/iqsFyg6T/NBtKa3qr2b6noILCEUyBEaA+hSDa8hMCTEn/iRBYtT+qzaDPa/ oWHt8lrcvjIvhWzD3MaCllwgCRcn5taJ2rvtYQk/Ob5RKB57Ht9k7JW4PPRRnEfQ39tP Fhgz8rBxrCr2AAOCeEZvzU3GWDS4UHlfWlCT3fBl8Z+MwVM/pqvR01/Io/tkWo+NRX9x ZDX+w9muWrLj5cSx718THLkBAxKIjXN39wIX4emqiEhwV+QLY32erMvbtNlCWxFTrUv7 /dUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=RdYAkVElxeFG84Wgj1AokU5Pwm+cT7QdL+c4sJXA2IU=; b=Ceu85c+jd6tsyjOQV+mcSONAFg+Y1yYYHahMulCv3NY6ygGB8Ht1dWQFJHzAyEFLqw TVCwuoZKSbMuyXVu4BTOzLWu8tE2xwMYWaRIyAPMEGXhrdDQ75ZOZ5SlsPETwKXPQ79M 8ZLdXj56RExuuGtkl2Uhky0ZBS/vu5kPTqRRN1ihIMXjDriuUzLe7DV2UVD9idRz6OLk jqU/yfo6SYXcbFMBJotm97e5xseVtaIQuCYSbxXhXKAAitxUsx5vHP8XGgWKFH/9POvt vwqpBMXaBtElrg6bEJobQcKMXDa8KTgtLYHOGDKtojA+B3yc9DB2wP3Uz4DJO62EXMoi Z4mw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q24si7260199ejr.128.2019.10.29.01.43.36; Tue, 29 Oct 2019 01:44:05 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbfJ2InD (ORCPT + 99 others); Tue, 29 Oct 2019 04:43:03 -0400 Received: from mga06.intel.com ([134.134.136.31]:55781 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbfJ2InD (ORCPT ); Tue, 29 Oct 2019 04:43:03 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2019 01:43:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,243,1569308400"; d="scan'208";a="224901941" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.122]) by fmsmga004.fm.intel.com with ESMTP; 29 Oct 2019 01:42:59 -0700 Date: Tue, 29 Oct 2019 10:42:58 +0200 From: Jarkko Sakkinen To: James Bottomley Cc: "Safford, David (GE Global Research, US)" , Ken Goldman , Mimi Zohar , "linux-integrity@vger.kernel.org" , "stable@vger.kernel.org" , "open list:ASYMMETRIC KEYS" , "open list:CRYPTO API" , open list Subject: Re: [PATCH] KEYS: asym_tpm: Switch to get_random_bytes() Message-ID: <20191029084258.GA5649@linux.intel.com> References: <20191008235339.GB13926@linux.intel.com> <20191014190033.GA15552@linux.intel.com> <1571081397.3728.9.camel@HansenPartnership.com> <20191016110031.GE10184@linux.intel.com> <1571229252.3477.7.camel@HansenPartnership.com> <20191016162543.GB6279@linux.intel.com> <1571253029.17520.5.camel@HansenPartnership.com> <20191017180440.GG6667@linux.intel.com> <20191021113939.GA11649@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021113939.GA11649@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Oct 21, 2019 at 02:39:39PM +0300, Jarkko Sakkinen wrote: > On Thu, Oct 17, 2019 at 09:04:40PM +0300, Jarkko Sakkinen wrote: > > On Wed, Oct 16, 2019 at 03:10:29PM -0400, James Bottomley wrote: > > > On Wed, 2019-10-16 at 19:25 +0300, Jarkko Sakkinen wrote: > > > > On Wed, Oct 16, 2019 at 08:34:12AM -0400, James Bottomley wrote: > > > > > reversible ciphers are generally frowned upon in random number > > > > > generation, that's why the krng uses chacha20. In general I think > > > > > we shouldn't try to code our own mixing and instead should get the > > > > > krng to do it for us using whatever the algorithm du jour that the > > > > > crypto guys have blessed is. That's why I proposed adding the TPM > > > > > output to the krng as entropy input and then taking the output of > > > > > the krng. > > > > > > > > It is already registered as hwrng. What else? > > > > > > It only contributes entropy once at start of OS. > > > > Ok. > > > > > > Was the issue that it is only used as seed when the rng is init'd > > > > first? I haven't at this point gone to the internals of krng. > > > > > > Basically it was similar to your xor patch except I got the kernel rng > > > to do the mixing, so it would use the chacha20 cipher at the moment > > > until they decide that's unsafe and change it to something else: > > > > > > https://lore.kernel.org/linux-crypto/1570227068.17537.4.camel@HansenPartnership.com/ > > > > > > It uses add_hwgenerator_randomness() to do the mixing. It also has an > > > unmixed source so that read of the TPM hwrng device works as expected. > > > > Thinking that could this potentially racy? I.e. between the calls > > something else could eat the entropy added? > > Also, what is wrong just taking one value from krng and mixing > it with a value from TPM RNG where needed? That would be non-racy > too. I guess we can move forward with this? /Jarkko