Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pV5SZ-0004yw-Uk for mharc-grub-devel@gnu.org; Thu, 23 Feb 2023 01:52:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pV5SX-0004yh-0y for grub-devel@gnu.org; Thu, 23 Feb 2023 01:52:05 -0500 Received: from mail-vi1eur02on2050.outbound.protection.outlook.com ([40.107.241.50] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pV5SS-0005nZ-Td for grub-devel@gnu.org; Thu, 23 Feb 2023 01:52:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIfScvQXfSnuaxk0k1GG21/q6o+00Wh9yLpkGZ2BtpyAB+VwETncXsXSdKKSBmA2fgAjiy1pbIiw0cXzAdf3sBfbYVJcJJANEh6EY/gkMOxd0N05sL3m8uJpo+aHXOLW2Nt4OawUBaf848tqchIJxjjDtiRDS9BTOyK3NKMxQ/LlbyR2BB8m+0gPS6os24hhPflu4sY2q5xkKsgBCmU44s+Wm0o9GXPJxwy9iryh1IeaOPrwM0R5RYJrbqhA2m6yzr/UWCz5MFVHCUi/dKlvRt24xcXMqArl2uG1JDcRg/Po4+5zHOhXCwfIsjwQl+HRak0hsHeL4MSJEK52CwUVgw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xrg43N+wZjcjsu55LNA42ZEwilYhSb6LCYoPhUPixK8=; b=Q/ngWPqHu2V606Hkh6jpRu+mIv5nLjXouZ1zGP8FemHXyIBCzV0Dc0KR1UHsZK2Ptn6hbYup8DYlkxxEGZdyP+QCinPIEqcTH8BY0S+QW5DpSQxHFRXcT3rL70HaNa9BngXPw7X8EOKmaESZO2IJVa8mapCjdwUVb6/N4rJs9Fk3S9Rt9AEoJtjQnxZ7Eys843wf9X3WfkZXC8DHHzRGQ9h/CIXlYksC1ZYmXAVA1yBbKI8/Por9PoebNW4cEphTeEfPS8XcqDQkJwm4SZVWCDIxn9VtxYeGtMqzTxyWQy+wPwB3fylN8xp62lZZ0+ie3hxo/t3dZiHspy3wbyNvGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xrg43N+wZjcjsu55LNA42ZEwilYhSb6LCYoPhUPixK8=; b=ZFAWa5PKtf6Fr2H1b9QHFxBOJptTfnl2m2zN6gVVP9vGliA9IThV+M0D1OBAHI1fPJTBvzRppbSIBSwvlBDMdQnL6dzCOnYsz7/BNvtHKIbrjHR4Gl7VcbQzJWe9xnwAvoTBNBgTdkW5tSJTwUm5spFym9DvLPII61hFtSshTcHl037QNSGI5CrK4VCkYYEZG9OBh1A2q08O2eD+VJwA6k4U6n4U9gwS0A4/iIrPE8hBBuklJeSrRh88uO7Be/Bp/K4ciz/n/2ngpsUb+9unWbDziNc3tFnYIxWWMQh88YXAqnfbUUZgA+SzX4CJW4mdwAI2bOThtKUw7QHoWS2EPw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DBBPR04MB6140.eurprd04.prod.outlook.com (2603:10a6:10:c7::18) by DU0PR04MB9586.eurprd04.prod.outlook.com (2603:10a6:10:31e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.18; Thu, 23 Feb 2023 06:51:53 +0000 Received: from DBBPR04MB6140.eurprd04.prod.outlook.com ([fe80::688f:bc10:59e2:772a]) by DBBPR04MB6140.eurprd04.prod.outlook.com ([fe80::688f:bc10:59e2:772a%6]) with mapi id 15.20.6134.021; Thu, 23 Feb 2023 06:51:53 +0000 Date: Thu, 23 Feb 2023 14:51:45 +0800 From: Gary Lin To: James Bottomley Cc: The development of GNU GRUB , 'Hernan Gatta ' , 'Daniel Kiper ' , shkhisti@microsoft.com, jaskaran.khurana@microsoft.com, christopher.co@microsoft.com, daniel.mihai@microsoft.com, rharwood@redhat.com, jaredz@redhat.com, development@efficientek.com, mchang@suse.com Subject: Re: [PATCH 03/14] protectors: Add TPM2 Key Protector Message-ID: <20230223065145.chldk2v3yharsdy7@GaryLaptop> References: <20230222070054.5122-1-glin@suse.com> <20230222070054.5122-4-glin@suse.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: FR3P281CA0025.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::23) To DBBPR04MB6140.eurprd04.prod.outlook.com (2603:10a6:10:c7::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6140:EE_|DU0PR04MB9586:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f81dbb5-62a5-4124-d017-08db156a71ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NdY6UEwuQKRfqb/hfc5MPD+jktnkjCVJf7WZ0WQ9fmMzP1B1VW0F1VDKa54OzO3Bw5p4U9+wixvC+2277H1PeL0hkKW2Ndt4NfTOvwfj1jRC4Z/PJZ3DM8N+BqDDsih+gQtrHCT5HeJgC1A6mLW9pgZHR9FopLa2Wo8OywzW1jIx0ejQlvhcbbJcvoaMN9wGbEXPNrJvwh1yKRy7EMX7tMsE27k2hvCxUJlCJ4uawhUgUXoanpXYQQYi77J0q/G19jdvXdo6GKOHI8P/JvI8JFAd0oNFsBpFBBJG0aECWfyqiHlf0vRvu14P63F/MkWtZvt693e6d5GsPRmvZfdDx4lUz3E5OJZyeu7S3pGfDGgCyS5ZTR4+d72wu95qeRJpA2NFYudjSwPyoLEn9BOdBrSOF/btyL0byXS2PePJrgcD3fg7LZ4Ym4CheagovKo7CFxg/kEeVjOn5cv+FJUAkkmtBv7H2xmJmE5qbKzAy2S+9jKxiQnupTlkKfvySWe+qan6asi5sQM44+LFBPmjfIlwfdJx2qYttsE3O4tgsIlS/d0DjPlR9Wa10+EvEPfRs79lFp2+CijIczW06If2iskrn0O4l6NbnI0pLgsekNIjsK/FO4KSGx7e+fNHnRFY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB6140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(7916004)(39860400002)(396003)(346002)(376002)(366004)(136003)(451199018)(33716001)(5660300002)(2906002)(107886003)(41300700001)(7416002)(54906003)(8936002)(6486002)(186003)(4326008)(6506007)(316002)(478600001)(66946007)(8676002)(1076003)(66476007)(6916009)(9686003)(26005)(6666004)(66556008)(38100700002)(86362001)(6512007)(966005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?cpgtpxmnNTksm+cUzs5dPW1stldNpmquCQOIfgKjz1k6//8GHOAxLkXaKD?= =?iso-8859-1?Q?r/cz8qVcFDPmnunimNGJIDUcyWaOZkjWxepnt8SsnhDR+UElwqFWa/Ua67?= =?iso-8859-1?Q?jWxGJ8uaCKh3J43RTfVf77UT4bYnG8Co0jZcHgoze8IUtURwYdonfRTiOH?= =?iso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+ksIOC/FG5NJ4AwnDarVPHt?= =?iso-8859-1?Q?L9BRyhJ7fJudvJDI7T1MGKFhYZwoBoArMWmI6Taw5BhDhjY5Vlc4EvECpM?= =?iso-8859-1?Q?FkO161U4eEGm8Ymxi6Z4YDpCEr9vGPiL97q8tiuylxfmrZAgD0zvSX4r3z?= =?iso-8859-1?Q?azCoVNTF7CNIAWFvIJSVtafQ8Xnb3hFlGbmVRvZ/5Rl+K3ic7NeNUCcous?= =?iso-8859-1?Q?blCCFqFwpSS2WC7lMghjda5UXGM36I+KZQNiZgpyeaPd+sOFuDUS2c9n06?= =?iso-8859-1?Q?YD538AG0+D2naEQBiE2zUU/sHXa/7ybxIAhGs5U6lJVYK2XYQlW/F/ORLM?= =?iso-8859-1?Q?RpF+SeVGOsOlVm1+6mTOcOiB5QSmUHiSC6dYM8SfWW0p7o0fApcbjLvsef?= =?iso-8859-1?Q?1sYTteUqbd+P5ZJ7M+TYXZsw1nbwttUicCucC4XgSUqJIvWq5DcAPTMRPm?= =?iso-8859-1?Q?5n6OkQlRhtcRvgWYgg6Xkn006tF9AE4CiD0dm4xstY/dv+Id01PE8xH4MK?= =?iso-8859-1?Q?DRDT5w09Gmtw64iYDlJSMbIp9iWIMqlgv128Mb3yl3Asu2OzaK6Mt7eL4L?= =?iso-8859-1?Q?nk7/qFAq7q4HpRbvFspdbtMImYeX/rATUG?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f81dbb5-62a5-4124-d017-08db156a71ba X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 06:51:52.6060 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XWSjdwTrKIBcqjn4vwiq3VDUMbPmcma1mYOQ+x12Vb077lM5p0ZmbBmU607QcCGu X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9586 Received-SPF: pass client-ip=40.107.241.50; envelope-from=GLin@suse.com; helo=EUR02-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2023 06:52:06 -0000 On Wed, Feb 22, 2023 at 07:41:38AM -0500, James Bottomley wrote: > On Wed, 2023-02-22 at 15:00 +0800, Gary Lin via Grub-devel wrote: > > +GRUB_MOD_INIT (tpm2) > > +{ > > +  grub_tpm2_protector_init_cmd = > > +    grub_register_extcmd ("tpm2_key_protector_init", > > +                         grub_tpm2_protector_init_cmd_handler, 0, > > +                         N_("[-m mode] " > > +                            "[-p pcr_list] " > > +                            "[-b pcr_bank] " > > +                            "[-k sealed_key_file_path] " > > +                            "[-s srk_handle] " > > +                            "[-a asymmetric_key_type] " > > +                            "[-n nv_index]"), > > +                         N_("Initialize the TPM2 key protector."), > > +                         grub_tpm2_protector_init_cmd_options); > > +  grub_tpm2_protector_clear_cmd = > > +    grub_register_extcmd ("tpm2_key_protector_clear", > > +                         grub_tpm2_protector_clear_cmd_handler, 0, > > NULL, > > +                         N_("Clear the TPM2 key protector if > > previously initialized."), > > +                         NULL); > > +  grub_key_protector_register (&grub_tpm2_key_protector); > > Hang on, we've spend ages standardising the format of TPM key files: > > https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.html > > And every major TPM based key system uses this format, so a key file > created by any TPM2 cryptosystem can be read by any other (meaning you > can use any crypotosystem tools to manage the key). What you're doing > here just reinvents a non-standard format and creates a load of > parameters that the user needs to know here, but are part of the key > format standard, so you not only need to remember a load of information > not in your key file, but you have to have a non-standard tool to > create the key in the first place. > Thanks for the spec. I'm not aware of that such format already existed. Hernan's patch intuitively combines the public the private parts into one file and provides the tool, util/grub-protect.c, to seal the password. This certainly can be improved. > Even if you want to keep your own tool to create keys, what about > interoperability with the kernel? The kernel's TPM key subsystem > (trusted keys) also speaks the above format > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/security/keys/trusted-keys/tpm2key.asn1 > > so you wouldn't be able to send this key down to day dm-crypt as a > trusted key, you'd have to create two separate key files to do that. > The sealed key file would be in be in ESP which is accessible to the normal users. For safety, the key will be sealed against the PCR state before loading the kernel, and the key file cannot be unsealed in OS. Instead, we plan to synthesize an initrd with the unsealed key in "/etc/cryptsetup-keys.d/" and prepend it, so that the crypttab daemon can decrypt the disk right the way. Gary Lin