From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.12078.1597331700237286732 for ; Thu, 13 Aug 2020 08:15:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ieRg6L9E; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: jiewen.yao@intel.com) IronPort-SDR: WoxX0mVqvrtDvNNrjlg/QVWUqg5xqjEbL+5Uym6eiL7YkBsNf2P8Um7klOzu4/4A15ekzjgmhK LY5OGvr/e4Kg== X-IronPort-AV: E=McAfee;i="6000,8403,9712"; a="155358966" X-IronPort-AV: E=Sophos;i="5.76,308,1592895600"; d="scan'208";a="155358966" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2020 08:14:59 -0700 IronPort-SDR: DDLOqCm4ASLSkFawOzmSZaYWyfm8IObXyILh36jR+bBMDPpntpJLvP/9CCol0UUIl2gDxAoZXn BhdTb/3ftKmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,308,1592895600"; d="scan'208";a="327593632" Received: from orsmsx602-2.jf.intel.com (HELO ORSMSX602.amr.corp.intel.com) ([10.22.229.82]) by fmsmga002.fm.intel.com with ESMTP; 13 Aug 2020 08:14:59 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Aug 2020 08:14:58 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Aug 2020 08:14:58 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 13 Aug 2020 08:14:58 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.170) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 13 Aug 2020 08:14:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N3GFp7daooUPqUArr4akpCknWI/Qphu5d80bCwWuvbRqiXnjUWDoEy240WamgYtAIK+nxyVaWH2aScjQqhHCDAHo2GLiqwascOGpoywh0lcOOT6gdYLFtGRzW7cpWiSnte5Yfx5xi/IitSom2iQuUjMtUw+AAQVqM2PiMZseCZ8CiDLmCKiEyF5tNj+1ukZCWdGxGqr6l5K8WqjB+F/Fcax7mqysKr8KI4901psVSD+9DuvuT/dZVKjkvVhLIOVjNO5Pmt22rHO4D06YRdDwU1gogV5xje9TE9mX2wXkkNF7cqtn/u+o7JfqXPw3L+nJ5XCsB2fwoK81OPpiTqpizg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6MySLC5G7Dj/eP3hwMvumscYcC7V0E8eB7mMbs4Mh/M=; b=A7rwE6ZX1gNpPDA1tSFXtl6iZjFDnVNfmKf7fmyCFmZzrjjc8P78BWiI0S62B9cxbFpjsq3IsJoSfEuqo9Ttp3/sDrbIDFTS2qc2R3dRqWNBywhNYLc2fmijk5i06BwarXpR9wIxPrsUpCDp2NE9kcheU2quxU57Phm9IZ6eLviTisfrgCSHVxJfwiycM3LYAorGcl7hCycC/gKLGVLaW5Ef9alG0ruCdNEo2slWAIMzgQUfPlyRUA7sj5dtbOeshLhDFE0cFPtH8ACQiH8HFP4/LaoPNcWjA98Xm45dRsYmmFJdFbUY8ySQtLFi/zHNuHEpI71hO75z238Xugw1Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6MySLC5G7Dj/eP3hwMvumscYcC7V0E8eB7mMbs4Mh/M=; b=ieRg6L9EA4Rm4rDjmtIioLIWXI6WE/v0zrEezFSFACoFU8iwB0P9o1jlX5Z3nPQTvxW3BlmdmDHPxWF+q5IgXiFzngtDbxPoFNMThrA8u8VzXoC2AzGYvVBD3xbhHVj78Z1B7JJyoFr0Behgb6x3iQC/HIU+NF7jazSedrNo9sQ= Received: from CY4PR11MB1288.namprd11.prod.outlook.com (2603:10b6:903:23::8) by CY4PR1101MB2166.namprd11.prod.outlook.com (2603:10b6:910:1e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Thu, 13 Aug 2020 15:14:56 +0000 Received: from CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::163:9209:a92d:812]) by CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::163:9209:a92d:812%6]) with mapi id 15.20.3283.018; Thu, 13 Aug 2020 15:14:56 +0000 From: "Yao, Jiewen" To: "matthewfcarlson@gmail.com" , "devel@edk2.groups.io" CC: Ard Biesheuvel , Anthony Perard , "Wang, Jian J" , "Julien Grall" , "Justen, Jordan L" , Laszlo Ersek , "Gao, Liming" , "Leif Lindholm" , "Kinney, Michael D" , "Lu, XiaoyuX" , "Liu, Zhiguang" , Sean Brogan Subject: Re: [PATCH v6 0/5] Use RngLib instead of TimerLib for OpensslLib Thread-Topic: [PATCH v6 0/5] Use RngLib instead of TimerLib for OpensslLib Thread-Index: AQHWcPoMs0y6OOlg4Ue1Pda09XwX86k2JexA Date: Thu, 13 Aug 2020 15:14:56 +0000 Message-ID: References: <20200812224338.287-1-matthewfcarlson@gmail.com> In-Reply-To: <20200812224338.287-1-matthewfcarlson@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGM1MWY5NTctZjdiYi00YTFmLTljZTMtZjNjZTI1ZGIyMTU1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRmpQSXluT2RJUlwvNklGVUNLZGVVOGh5aUUyK1Z1NEdqU053UFZwclJEV3lQSG11dVlGclJPMGlhbDFwVHgxVFYifQ== x-ctpclassification: CTP_NT dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.198] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 097a75c6-fcd2-49c6-e1c1-08d83f9ba363 x-ms-traffictypediagnostic: CY4PR1101MB2166: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qeqNYuPXb+tmrZBxQ8mpAJSkLCr8z9uKy6deYj9OsBgPQW3Pg7SQDwkrdD2NlS8GrSXolE2mtqWXyKqwjIhOVsMx85JCXogNEAJ2HzB7PD6gusK/+ks05DDKZEi+HRWNPB+8jNkvQT+7Er2lpo7N1zJQfIsNlJn7IOd/vKCz4+VK5NOLE2sF7M8bG+MVVOaV4nDVE33roMRTF+K7SDKp8vGJT382bjpLylSJ5HQOPtfZZjif0odUPc5/810P1nsQDS2j5dSQyVuE7JPyDW4qzSRZeIAWXW/r9n0YGHur+yyRYyyrjOYGHPJOz4wa8IYVpw72tVq/5WesthG7azTX1P8svcVVjPlC41l8zhs6oMQWpsHv5071TppHD92Ppj4nc8wHEI1f9eFaaVFzLXoQSQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1288.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(39860400002)(136003)(376002)(346002)(396003)(71200400001)(8936002)(5660300002)(966005)(9686003)(86362001)(83380400001)(55016002)(2906002)(19627235002)(186003)(54906003)(66476007)(66556008)(66946007)(64756008)(110136005)(66446008)(33656002)(52536014)(53546011)(4326008)(7696005)(8676002)(478600001)(26005)(316002)(76116006)(6506007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: moE6pWw4rIS2MlUMKiJDQr9B3F4oBqbiyS6mJW3zqmI7R9Mgf99S5BmnVNnFDs/nQcRBGX1gUvXPpR9UvQvgQ9O8Eseg2dK7kGSTB2svLgzgi0qw4JXcxWAA/rFc54rQ6ZQjyeKPLBx22iUoSEH7ZYI21RhhqpeMaVfff7BwNSWM3FUAoPgy/H6NEetiwExYhuxJ/TCgM+B/ENNP10+PLZKx8MM9pq84Xxs31SlHazIkDf1/O7WFebRU/y5FgAmxY4IPrEqB/XxZSPXZ+BpIN+EJdZjdJc/lXr9P8i2UAWW3kAqm5vJcXYb66x0CqffZXtGfLjOZ7EzujL/U7R4hS1r5hkv6rl9+4LhW7nxfviHqqrdQdoknitdzuYjcd2DDBdUjT1kW2eTEXEHeZ4RMcEVhk5sBZKesXkCRKeZ5NzbjY0FzoBqK6JpCy2Adxkcbwo9Ythqc1hvOWFSyPqQBXHaxdhyr/m4QWgC8Yio6JW9Ompx2IaqUZkEcen6QNcZzj+0UzrXHYTk6ohVXAvIMIkq4eXWeBq/g/UUPB+kYYATC4CW2ANLsMJZDvc1wiVCHGUpBslYibZoshU6FEkacJJ+wvFL85K1Qw21wASMwDoWP7MKsNwb9L5ubUVaRVo7211V78hhGxvmZcnhTOB4T8Q== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1288.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 097a75c6-fcd2-49c6-e1c1-08d83f9ba363 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Aug 2020 15:14:56.4658 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ekrhB57W1GGRiorTBw3G4XH5zzQLnVz1vOAQzoXIxQbbRzVCvw1FvQvpW0QcXnpz7wrlpoyOSusS5TZkWU5GVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2166 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks Matthew. I am OK, if you want to address the RDSEED in follow-up patch series. Would you please file a new Bugzilla to record this, so we won't lose the i= nformation ? > -----Original Message----- > From: matthewfcarlson@gmail.com > Sent: Thursday, August 13, 2020 6:44 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Anthony Perard > ; Yao, Jiewen ; Wang, > Jian J ; Julien Grall ; Justen, Jo= rdan L > ; Laszlo Ersek ; Gao, Limin= g > ; Leif Lindholm ; Kinney, Michae= l D > ; Lu, XiaoyuX ; Liu, > Zhiguang ; Sean Brogan > ; Matthew Carlson > > Subject: [PATCH v6 0/5] Use RngLib instead of TimerLib for OpensslLib >=20 > From: Matthew Carlson >=20 > Hello all, >=20 > This patch contains a fix for Bugzilla 1871. > There's been a good bit of community discussion around the topic, > so below follows a general overview of the discussion and what this patch= does. >=20 > Back in Devel message#40590 (https://edk2.groups.io/g/devel/message/40590= ) > around the patch series that updates OpenSSL to 1.1.1b, a comment was mad= e > that suggested that platforms be in charge of the entropy/randomness that > is provided to OpenSSL as currently the entropry source seems to be a > hand-rolled random number generator that uses the PerformanceCounter from > TimerLib. This causes OpenSSL to depend on TimerLib, which is often platf= orm > specific. In addition to being a potentially weaker source of randomness, > this also poses a challenge to compile BaseCryptLibOnProtocol with a plat= form- > agnostic version of TimerLib that works universally. >=20 > The solution here is to allow platform to specify their source of entropy= in > addition to providing two new RngLibs: one that uses the TimerLib as well= as > one that uses RngProtocol to provide randomness. Then the decision to use > RDRAND or other entropy sources is up to the platform. Mixing various ent= ropy > sources is the onus of the platform. It has been suggested on Devel#40590= and > BZ#1871 that there should be mixing of the PerformanceCounter and RDRAND > using > something similar to the yarrow alogirthm that FreeBSD uses for example. = This > patch series doesn't offer an RngLib that offers that sort of mixing as t= he > ultimate source of random is defined by the platform. >=20 > This patch series offers three benefits: > 1. Dependency reduction: Removes the need for a platform specific timer > library. We publish a single binary used on numerous platforms for > crypto and the introduced timer lib dependency caused issues because we > could not fulfill our platform needs with one library instance. >=20 > 2. Code maintenance: Removing this additional code and leveraging an exis= ting > library within Edk2 means less code to maintain. >=20 > 3. Platform defined quality: A platform can choose which instance to use = and > the implications of that instance. >=20 > This patch series seeks to address five seperate issues. > 1) Use RngLib interface to generate random entropy in rand_pool > 2) Remove dependency on TimerLib in OpensslLib > 3) Add a new version of RngLib implemented by TimerLib > 4) Add a new version of RngLib implemented by EFI_RNG_PROTOCOL > 5) Add RngLib to platforms in EDK2 such as ArmVirtPkg and OvmfPkg >=20 > Since this changes the dependencies of OpenSSL, this has the potential of= being > a breaking change for platforms in edk2-platforms. The easiest solution i= s just > to use the RngLib that uses the TimerLib as this closely mimics the behav= ior of > OpenSSL prior to this patch series. There is also a null version of RngLi= b for > CI environments that need this change > (https://edk2.groups.io/g/devel/message/50432). Though it should be point= ed > out > that in CI environments, the null version of BaseCryptLib or OpenSSL shou= ld be > used. >=20 > In addition, it has been suggested that > 1) Add AsmRdSeed to BaseLib. > 2) Update BaseRngLib to use AsmRdSeed() for the random number, > if RdSeed is supported (CPUID BIT18) >=20 > However, this is largely out of scope for this particular patch series an= d > will likely need to be in a follow-up series later. >=20 > It is my understanding that the OpenSSL code uses the values provided as = a > randomness pool rather than a seed or random numbers itself, so the > requirements for randomness are not quite as stringent as other applicati= ons. >=20 > For the ArmVirtPkg and OvmfPkg platforms, the patch series here just adds= in > the TimerLib based RngLib as that is similar to the functionality of befo= re. > It is added as a common library so any custom RngLib defined in the DSC > should take precedence over the TimerLibRngLib. >=20 > Ref: https://github.com/tianocore/edk2/pull/845 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 >=20 > Cc: Ard Biesheuvel > Cc: Anthony Perard > Cc: Jiewen Yao > Cc: Jian J Wang > Cc: Julien Grall > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Liming Gao > Cc: Leif Lindholm > Cc: Michael D Kinney > Cc: Xiaoyu Lu > Cc: Zhiguang Liu > Cc: Sean Brogan >=20 > Signed-off-by: Matthew Carlson >=20 >=20 > Matthew Carlson (5): > MdePkg: TimerRngLib: Added RngLib that uses TimerLib > MdePkg: BaseRngLibDxe: Add RngLib that uses RngDxe > OvmfPkg: Add RngLib based on TimerLib for Crypto > ArmVirtPkg: Add RngLib based on TimerLib for CryptoPkg > CryptoPkg: OpensslLib: Use RngLib to generate entropy in rand_pool >=20 > CryptoPkg/Library/OpensslLib/rand_pool.c | 203 ++-------= ----------- > CryptoPkg/Library/OpensslLib/rand_pool_noise.c | 29 --- > CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c | 43 ----- > MdePkg/Library/BaseRngLibDxe/RngDxeLib.c | 200 > +++++++++++++++++++ > MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c | 187 > ++++++++++++++++++ > ArmVirtPkg/ArmVirt.dsc.inc | 1 + > CryptoPkg/CryptoPkg.dsc | 1 + > CryptoPkg/Library/OpensslLib/OpensslLib.inf | 15 +- > CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 15 +- > CryptoPkg/Library/OpensslLib/rand_pool_noise.h | 29 --- > MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf | 38 ++++ > MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 40 ++++ > MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni | 17 ++ > MdePkg/MdePkg.dsc | 5 +- > OvmfPkg/Bhyve/BhyvePkgX64.dsc | 1 + > OvmfPkg/OvmfPkgIa32.dsc | 1 + > OvmfPkg/OvmfPkgIa32X64.dsc | 1 + > OvmfPkg/OvmfPkgX64.dsc | 1 + > OvmfPkg/OvmfXen.dsc | 1 + > 19 files changed, 514 insertions(+), 314 deletions(-) > delete mode 100644 CryptoPkg/Library/OpensslLib/rand_pool_noise.c > delete mode 100644 CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c > create mode 100644 MdePkg/Library/BaseRngLibDxe/RngDxeLib.c > create mode 100644 MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c > delete mode 100644 CryptoPkg/Library/OpensslLib/rand_pool_noise.h > create mode 100644 MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf > create mode 100644 > MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf > create mode 100644 > MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni >=20 > -- > 2.27.0.windows.1