From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.44]) by mx.groups.io with SMTP id smtpd.web11.4761.1666686219928862052 for ; Tue, 25 Oct 2022 01:23:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=ib2dnG5o; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.243.44, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ub6DRrrogmuCzw4R6I8Oabnycobd3D1TCqojnUxVKA+SxZc+mZ4K0WW03xvWTjgtdQHFlfuTcMoLTB1CTA49v6EL3bmoXM3hkLZoQJb9RNSpmsLfdlrtM2KS0yjyV1UePlk9XtrQ+s4UQTrmlAwS5NJlMQZAONsO8FWegW3XMs+v8N1PrOFkzA2ikQM9OSHfhjZOP8FbXgyAKsxwKn6oLdJn0olo9Qrn+9/W8a5DTxgBbGup+cPBqWaPb9cPlekECwLlmSbPc5UhteQZ1ybsQ/wyuKShuvVepTPjb89lJFwEelJeNjxvBIC7lnWPM8aOGQW0HNM5OCisqh4JE8tecg== 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=R+W/3/otGyBU0rOYg17icYs5j5vnCnlRr5uj8v4YOQU=; b=ZtW5SJ6MJ0a6uKvd9NIHIZQkdVxZGnYH8r0GPhgbebRW/ZJIXu/5LZ/PEXDYCeskvwYRwXe0TRlJKs6ImFFQx19CaJxayQNP6iuhXGahLeYOzwuasvfzJKLPOUN5vcHa8XerWOjLfilYbOb+lmTmzPDX7CoK/ljB+jxDOMqicOrJAiR99tf+GQ5cD01XBcMJ4sPQBjt63u7z9+zC02ecDY/r615SWEtlVjnpxqeBqnBbqucZHCSgxGeJYVQqPGi/IUfCDK5d288TokNJ5/MpqIJKq42V9ekGyg2MaP4KdvPU2u+xeL2C0t2WiM6IrOk8Ffp8RZHT8ll5HNcJi17T9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R+W/3/otGyBU0rOYg17icYs5j5vnCnlRr5uj8v4YOQU=; b=ib2dnG5o/9S35tl4PmXValvJJ24y43amPoqAaPQgnPU46OQxgzvxPB/icGPHW34ntmCrfIqidevnBMNj8qsqmpL5EwOdmVqwsZhOJKJQ9WVoxX+4a8RYbg4qFXP7gcb9LMFzm4iyqADc50LWyHJxzQqp96ynpWYSIwrcMAr1bTP4aiPnZslZXMLdn/acpGFoO6W8P+SPw8yqS9aTgtZuKkFQOfgev7FOwEwFhOO5h/VdOzMKbERexj0uAWsQF/8cnMMZfT/x7IT+b9ZRDpmAZbilKeMJsng3hRqKz83cXO98jVavfD/Thr/UM+Tc2ttqNvWCVVuF9VCknIU28z8A7A== Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by PH7PR12MB5617.namprd12.prod.outlook.com (2603:10b6:510:133::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 25 Oct 2022 08:23:37 +0000 Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::7fe8:da93:95dc:6657]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::7fe8:da93:95dc:6657%6]) with mapi id 15.20.5723.033; Tue, 25 Oct 2022 08:23:36 +0000 From: "Nickle Wang" To: "devel@edk2.groups.io" , "abner.chang@amd.com" CC: Nick Ramirez , Igor Kulchytskyy Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation Thread-Topic: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation Thread-Index: AQHY5C9PGUTe6vZyy0GPSakTdTeet64ZvY7ggAUNBrA= Date: Tue, 25 Oct 2022 08:23:36 +0000 Message-ID: References: <20221020025434.29969-1-nicklew@nvidia.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-10-22T06:54:31Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=f317d2a2-540a-4f78-af60-076270a05f0a; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|PH7PR12MB5617:EE_ x-ms-office365-filtering-correlation-id: c329b39e-e699-461d-ef36-08dab662369f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QKC9PYYw+8tS3698Ksh2gEQ9uIzl3OX+bUpRU6W63Q+6ZL32ylQDD/vN3gVhrjCwcrS41cZiFTYgcN8eF6dYH7pXBfoIizuvJoW/1ZSKKo+MrAflp7r0UqpGX8RZbQ0ZeMAWhcJc9dqfDbFELREweyKIr2FuoLLlbBZW3HKb0wMlvfSoSOm5k+n55kyCdFRfJhO2CMF1a4lEa1zn3/bTcZsrDfvL9kwjf/mEJasvQFi4go78Ip7YfDHfpi3QmTR7K7zoEtZEFyM7HJFk/D4St0w0nupLKw7LhifKn3uYwwy647wdTjNvf5e2mo6GquZSgZ5XoKVLLwA9A9G6WixpdRrYgw8iikqs+7QXDM7CnyEVFSyU3nwrsnBKw8fb/gHn1GeqrO65lim1+vjppVeJodZ1SOWAthYpmmK3P1RX5IqvdNNqcJxmzIpEx6a4PJivPMb7SotSHG3/vrmMG7qTcql6zrtF2TU5jgKrR+18v7kzBZjGhZqdYREOPnVyVFqoZCk4Ewxa9oss6Cg47UsWLzkt+YfzoLWKlGQgoEpByfakb6UbMd0FAS7IPWxdgIQS/30z0d7d67hTXm1ynonOtD96NcV5fT6RlNbxNVnPVW1vMhfN5lscUsyNrgxu/tTUmOWD3ejNLvKq7bMulXBcPZRKiDQ7NZYJgBn4Je32LAkxZhNwlKBFjv8EgiusDonsh/uzWZqMr3X2c6jFdfB35NCxwxsmK6XnojJVshcy8y/d4w4BGhkiVl8ogx8dDo+e3gkUfRYfu2Tmcz9Y4M7MovMA6ZQf+Q9OZB/3hoV1Gr8= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR12MB7031.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199015)(6506007)(54906003)(71200400001)(53546011)(66899015)(41300700001)(110136005)(5660300002)(966005)(66446008)(52536014)(8676002)(64756008)(76116006)(26005)(9686003)(4326008)(66476007)(66556008)(8936002)(478600001)(30864003)(122000001)(7696005)(66946007)(316002)(83380400001)(38070700005)(186003)(2906002)(19627235002)(86362001)(38100700002)(33656002)(55016003)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BDGqLwfdJo4WAa3pMPJ7NCiywVYQS1W5YRDMg7C/zmiORRPUdTSYBuPt5+Uw?= =?us-ascii?Q?9J3P+kxzBZ1PtOll/VL3OKGES6Bjd+sKCLJrm0R5Mi+r/06w2Xdioq5YNcFe?= =?us-ascii?Q?q0MwUnu0ulVKq+rsqQbDOW+m852PgbRomSsWqlwRpP9QKTZMt+KtBrfbY9Pi?= =?us-ascii?Q?FEkqy7c7NQ+SvRomdxQ9+iTETG4F0e4ddKYanCvEiH5debZomPOz3R5Y/+iN?= =?us-ascii?Q?EIKF90KOxgWN6Fjfmne/GcQA0w8v6gKYI3TlxPUWmH//tKJNDNX4oPL/tLsM?= =?us-ascii?Q?fixDX0pYo4vKcVUbwi+HlT3Tk9RCChm81mJ5UcMKzMVjrvRsUHUoSvmbebcr?= =?us-ascii?Q?WuMdn7oObkNVclzicu+SyYSAYOX7GdzX56/33E4NqBK+kgWGDNPJBwQYyvy8?= =?us-ascii?Q?thMUHxIjO6XrcuLkiKWTvKUg8QTFinPPrCnRQJgd2eg/Ez+9/cIFLsyPptPT?= =?us-ascii?Q?yt8Pw8PpLCOYtnq3nIQJsnVOza47P+5umvmO/L1QXvjFaOoHW8KFcayA38gg?= =?us-ascii?Q?S5HH32KvkgLr2W8OKBPzGiNEiLbTZVmFnncRD/4+PnOB/XHtz2T9AVJ95lOu?= =?us-ascii?Q?k5haaoORZNVAz8rAT7aJbhX+jVOOY44NoSWb4yY/H5EXXpUSGTAQyDOPUxwH?= =?us-ascii?Q?k08ieSe55gUCrrz1F5q8butycnU5CRkZkRXO2mbLoSwaRISWWJ2jmsphdWga?= =?us-ascii?Q?sno5htSXY772SP1QPUWRUAKkeIzNVPcpJgONVouUBTtNcb8Nbdmtwer0ilp7?= =?us-ascii?Q?dpKzUP81EjPIHvI1Foukoqa84KYONeKecy7IpcVUGrRoOgyTeQudKaKkvF4B?= =?us-ascii?Q?hKrMr9Qgdu5AJmSp+T3rMUAbr6jif993dh8XuiUzc4f/OxSl7vKFnDMCtwT+?= =?us-ascii?Q?ebw/o4Jtg5AGM2fREO6tJkNNc4Z1iRc+hifuRRG6tATR3wYDOvzKI0zHCq1D?= =?us-ascii?Q?zn1scTKMLLatSBt1JLPEH/Cy2NSlX57TrlSmw+AoOC3xGhPiLIeaBhV52ldo?= =?us-ascii?Q?601EH1fIaBDD0yipkL8Xsp0qCih65fOkFRLyq5lrhvvzPyxmyCY3qcx0YVk9?= =?us-ascii?Q?vhZGhz0msl0I0nmSozTOp+33+WllUcFjDUIavotZ4CDaUjS7Y4twJQoR6UxK?= =?us-ascii?Q?GNFgzSlJ3CGXA2rzgYAWohErle5VZpV3RPCoZ642MXaMDN+av6AgtrphFGqH?= =?us-ascii?Q?QJCymoertkYxzB4fZagPQGvsiPFXqz5P/6gSXUqMyDHgbwh5yD5b2P6CyhFw?= =?us-ascii?Q?LQBpAUemVeHG2Q1lT3bduA+wHSvWp2m1eyU0RkdGSyaH3YHHDjE1PgXvYflH?= =?us-ascii?Q?4NMZhDvRkaSFPsPTEc0Ysw/9U0ZsiFH/yXZ/GAG3NTae0dmxWUnGG+zn++Xn?= =?us-ascii?Q?L/qA+0i50rAQC4A2SJImAgw9TuCl6Nj/AnKhWm7gA9XqbUSr7ukSjTBm3Mws?= =?us-ascii?Q?uwBnVr7naQC2gDU7jKLAYZvarQHJnPiqdjx57y1+fgPmnt6jrzKo2VH6w+ts?= =?us-ascii?Q?H4jRa4QwTSeVLeJHzQbsspzze14LYPJjN29mil3Y/oG30gLcQogeKzr73LG+?= =?us-ascii?Q?I2X5zkUeNZb1H14x0e+51E6YWImuB11u5oD7tEqY?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c329b39e-e699-461d-ef36-08dab662369f X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2022 08:23:36.5691 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 57pBExXz6NP/Syjj8KhC08SdIdnRpZNJf5bORj9fIiaYLyOtbbZvf2a4+JpiOZ6tltX1K/dcaXQxa3IYuw5RgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5617 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for your review comments, Abner! I will update new version patch lat= er. The CI build error will be handled together. > please add Igor as reviewer too Sure! > + *UserId =3D AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE); =20 > + if [Chang, Abner] Allocation memory with the size (USERNAME_MAX_LENGTH + 1) for both BootUse= rname and BootstrapPassword? Because the maximum number of characters def= ined in the spec is USERNAME_MAX_LENGTH for the user/password. Yes, the additional one byte is for NULL terminator. USERNAME_MAX_LENGTH is= defined as 16 and follow host interface specification. Regards, Nickle -----Original Message----- From: devel@edk2.groups.io On Behalf Of Chang, Abner= via groups.io Sent: Saturday, October 22, 2022 3:01 PM To: Nickle Wang ; devel@edk2.groups.io Cc: Nick Ramirez ; Igor Kulchytskyy Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: = IPMI implementation External email: Use caution opening links or attachments [AMD Official Use Only - General] Hi Nickle, please add Igor as reviewer too. My comments is in below, > -----Original Message----- > From: Nickle Wang > Sent: Thursday, October 20, 2022 10:55 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Nick Ramirez=20 > > Subject: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI=20 > implementation > > Caution: This message originated from an External Source. Use proper=20 > caution when opening attachments, clicking links, or responding. > > > This library follows Redfish Host Interface specification and use IPMI=20 > command to get bootstrap account credential(NetFn 2Ch, Command 02h) from = BMC. > RedfishHostInterfaceDxe will use this credential for the following=20 > communication between BIOS and BMC. > > Cc: Abner Chang > Cc: Nick Ramirez > Signed-off-by: Nickle Wang > --- > .../RedfishPlatformCredentialLib.c | 273 ++++++++++++++++++ > .../RedfishPlatformCredentialLib.h | 75 +++++ > .../RedfishPlatformCredentialLib.inf | 37 +++ [Chang, Abner] Could we name this library RedfishPlatformCredentialIpmi so the naming styl= e is consistent with RedfishPlatformCredentialNull? > 3 files changed, 385 insertions(+) > create mode 100644 > RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredential= Lib. > c > create mode 100644 > RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredential= Lib. > h > create mode 100644 > RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent > ialLib.i > nf > > diff --git > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede > ntialLi > b.c > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede > ntialLi > b.c > new file mode 100644 > index 0000000000..23a15ab1fa > --- /dev/null > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformC > +++ re > +++ dentialLib.c > @@ -0,0 +1,273 @@ > +/** @file > +* > +* Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent [Chang, Abner] We can have "@par Revision Reference:" in the file header to point out the= spec. https://www.dmtf.org/sites/default/files/standards/documents/DSP0270_1.3.0.= pdf > +* > +**/ > + > +#include "RedfishPlatformCredentialLib.h" > + > +// > +// Global flag of controlling credential service // BOOLEAN=20 > +mRedfishServiceStopped =3D FALSE; > + > +/** > + Notify the Redfish service provide to stop provide configuration=20 > +service to this > platform. > + > + This function should be called when the platfrom is about to leave=20 > + the safe > environment. > + It will notify the Redfish service provider to abort all logined=20 > + session, and prohibit further login with original auth info. > + GetAuthInfo() will return EFI_UNSUPPORTED once this function is return= ed. > + > + @param[in] This Pointer to > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance. > + @param[in] ServiceStopType Reason of stopping Redfish service. > + > + @retval EFI_SUCCESS Service has been stoped successfully. > + @retval EFI_INVALID_PARAMETER This is NULL. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibStopRedfishService ( > + IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, > + IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType > + ) > +{ > + EFI_STATUS Status; > + > + if ((ServiceStopType <=3D ServiceStopTypeNone) || (ServiceStopType >= =3D > ServiceStopTypeMax)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Raise flag first > + // > + mRedfishServiceStopped =3D TRUE; > + > + // > + // Notify BMC to disable credential bootstrapping support. > + // > + Status =3D GetBootstrapAccountCredentials (TRUE, NULL, NULL); if=20 > + (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: fail to disable bootstrap credential:=20 > + %r\n", > __FUNCTION__, Status)); > + return Status; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + Notification of Exit Boot Service. > + > + @param[in] This Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL. > +**/ > +VOID > +EFIAPI > +LibCredentialExitBootServicesNotify ( > + IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This > + ) > +{ > + // > + // Stop the credential support when system is about to enter OS. > + // > + LibStopRedfishService (This, ServiceStopTypeExitBootService); } > + > +/** > + Notification of End of DXe. > + > + @param[in] This Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL. > +**/ > +VOID > +EFIAPI > +LibCredentialEndOfDxeNotify ( > + IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This > + ) > +{ > + // > + // Do nothing now. > + // We can stop credential support when system reach end-of-dxe for=20 > +security > reason. > + // > +} > + > +/** > + Function to retrieve temporary use credentials for the UEFI redfish=20 > +client [Chang, Abner] We miss the functionality to disable bootstrap credential service in the fu= nction description. > + > + @param[in] DisableBootstrapControl > + TRUE - Tell the BMC to disable the= bootstrap credential > + service to ensure no one el= se gains credentials > + FALSE Allow the bootstrap=20 > + credential service to continue @param[out] BootstrapUsername > + A pointer to a UTF-8 encoded=20 > + string for the credential > username > + When DisableBootstrapControl is=20 > + TRUE, this pointer can be NULL > + > + @param[out] BootstrapPassword > + A pointer to a UTF-8 encoded=20 > + string for the credential > password > + When DisableBootstrapControl is=20 > + TRUE, this pointer can be NULL > + > + @retval EFI_SUCCESS Credentials were successfully fetc= hed and > returned > + @retval EFI_INVALID_PARAMETER BootstrapUsername or > BootstrapPassword is NULL when DisableBootstrapControl > + is set to FALSE > + @retval EFI_DEVICE_ERROR An IPMI failure occurred [Chang, Abner] The return status should also include the status of disabling bootstrap cre= dential. > +**/ > +EFI_STATUS > +GetBootstrapAccountCredentials ( > + IN BOOLEAN DisableBootstrapControl, > + IN OUT CHAR8 *BootstrapUsername, OPTIONAL > + IN OUT CHAR8 *BootstrapPassword OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA CommandData; > + IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE ResponseData; > + UINT32 ResponseSize; > + > + if (!PcdGetBool (PcdIpmiFeatureEnable)) { > + DEBUG ((DEBUG_ERROR, "%a: IPMI is not enabled! Unable to fetch=20 > + Redfish > credentials\n", __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + // > + // NULL buffer check > + // > + if (!DisableBootstrapControl && ((BootstrapUsername =3D=3D NULL) || > (BootstrapPassword =3D=3D NULL))) { > + return EFI_INVALID_PARAMETER; > + } > + > + DEBUG ((DEBUG_VERBOSE, "%a: Disable bootstrap control: 0x%x\n",=20 > + __FUNCTION__, DisableBootstrapControl)); > + > + // > + // IPMI callout to NetFn 2C, command 02 > + // Request data: > + // Byte 1: REDFISH_IPMI_GROUP_EXTENSION > + // Byte 2: DisableBootstrapControl > + // > + CommandData.GroupExtensionId =3D REDFISH_IPMI_GROUP_EXTENSION; > + CommandData.DisableBootstrapControl =3D (DisableBootstrapControl ? > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE : > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE); > + > + ResponseSize =3D sizeof (ResponseData); > + > + // > + // Response data: > + // Byte 1 : Completion code > + // Byte 2 : REDFISH_IPMI_GROUP_EXTENSION > + // Byte 3-18 : Username > + // Byte 19-34: Password > + // > + Status =3D IpmiSubmitCommand ( > + IPMI_NETFN_GROUP_EXT, > + REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD, > + (UINT8 *)&CommandData, > + sizeof (CommandData), > + (UINT8 *)&ResponseData, > + &ResponseSize > + ); > + > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: IPMI transaction failure. Returning\n", > __FUNCTION__)); > + ASSERT_EFI_ERROR (Status); > + return Status; > + } else { > + if (ResponseData.CompletionCode !=3D IPMI_COMP_CODE_NORMAL) { > + if (ResponseData.CompletionCode =3D=3D > REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED) { > + DEBUG ((DEBUG_ERROR, "%a: bootstrap credential support was > disabled\n", __FUNCTION__)); > + return EFI_ACCESS_DENIED; > + } > + > + DEBUG ((DEBUG_ERROR, "%a: Completion code =3D 0x%x. Returning\n", > __FUNCTION__, ResponseData.CompletionCode)); > + return EFI_PROTOCOL_ERROR; > + } else if (ResponseData.GroupExtensionId !=3D > REDFISH_IPMI_GROUP_EXTENSION) { > + DEBUG ((DEBUG_ERROR, "%a: Group Extension Response =3D 0x%x. > Returning\n", __FUNCTION__, ResponseData.GroupExtensionId)); > + return EFI_DEVICE_ERROR; > + } else { > + if (BootstrapUsername !=3D NULL) { > + CopyMem (BootstrapUsername, ResponseData.Username, > USERNAME_MAX_LENGTH); > + // > + // Manually append null-terminator in case 16 characters=20 > + username > returned. > + // > + BootstrapUsername[USERNAME_MAX_LENGTH] =3D '\0'; > + } > + > + if (BootstrapPassword !=3D NULL) { > + CopyMem (BootstrapPassword, ResponseData.Password, > PASSWORD_MAX_LENGTH); > + // > + // Manually append null-terminator in case 16 characters=20 > + password > returned. > + // > + BootstrapPassword[PASSWORD_MAX_LENGTH] =3D '\0'; > + } > + } > + } > + > + return Status; > +} > + > +/** > + Retrieve platform's Redfish authentication information. > + > + This functions returns the Redfish authentication method together=20 > + with the user Id and password. > + - For AuthMethodNone, the UserId and Password could be used for=20 > + HTTP > header authentication > + as defined by RFC7235. > + - For AuthMethodRedfishSession, the UserId and Password could be=20 > + used for > Redfish > + session login as defined by Redfish API specification (DSP0266). > + > + Callers are responsible for and freeing the returned string storage. > + > + @param[in] This Pointer to > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance. > + @param[out] AuthMethod Type of Redfish authentication method= . > + @param[out] UserId The pointer to store the returned Use= rId string. > + @param[out] Password The pointer to store the returned Pas= sword > string. > + > + @retval EFI_SUCCESS Get the authentication information su= ccessfully. > + @retval EFI_ACCESS_DENIED SecureBoot is disabled after EndOfDxe= . > + @retval EFI_INVALID_PARAMETER This or AuthMethod or UserId or > Password is NULL. > + @retval EFI_OUT_OF_RESOURCES There are not enough memory resources= . > + @retval EFI_UNSUPPORTED Unsupported authentication method is > found. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibCredentialGetAuthInfo ( > + IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, > + OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, > + OUT CHAR8 **UserId, > + OUT CHAR8 **Password > + ) > +{ > + EFI_STATUS Status; > + > + if ((AuthMethod =3D=3D NULL) || (UserId =3D=3D NULL) || (Password =3D= =3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + *UserId =3D NULL; > + *Password =3D NULL; > + > + if (mRedfishServiceStopped) { > + DEBUG ((DEBUG_ERROR, "%a: credential service is stopped due to=20 > + security > reason\n", __FUNCTION__)); > + return EFI_ACCESS_DENIED; > + } > + > + *AuthMethod =3D AuthMethodHttpBasic; > + > + *UserId =3D AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE); =20 > + if [Chang, Abner] Allocation memory with the size (USERNAME_MAX_LENGTH + 1) for both BootUse= rname and BootstrapPassword? Because the maximum number of characters def= ined in the spec is USERNAME_MAX_LENGTH for the user/password. > + (*UserId =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + *Password =3D AllocateZeroPool (sizeof (CHAR8) * PASSWORD_MAX_SIZE);= =20 > + if (*Password =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D GetBootstrapAccountCredentials (FALSE, *UserId,=20 > + *Password); if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: fail to get bootstrap credential:=20 > + %r\n", > __FUNCTION__, Status)); > + return Status; > + } > + > + return EFI_SUCCESS; > +} > diff --git > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede > ntialLi > b.h > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede > ntialLi > b.h > new file mode 100644 > index 0000000000..5b448e01be > --- /dev/null > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformC > +++ re > +++ dentialLib.h > @@ -0,0 +1,75 @@ > +/** @file > +* > +* Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent > +* > +**/ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include #include=20 > + > + > +#define REDFISH_IPMI_GROUP_EXTENSION 0x52 > +#define REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD 0x02 > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE 0xA5 > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE 0x00 > +#define REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED > 0x80 > + > +// > +// Per Redfish Host Interface Specification 1.3, The maximum lenght=20 > +of // username and password is 16 characters long. > +// > +#define USERNAME_MAX_LENGTH 16 > +#define PASSWORD_MAX_LENGTH 16 > +#define USERNAME_MAX_SIZE (USERNAME_MAX_LENGTH + 1) // NULL > terminator > +#define PASSWORD_MAX_SIZE (PASSWORD_MAX_LENGTH + 1) // NULL > terminator > + > +#pragma pack(1) > +/// > +/// The definition of IPMI command to get bootstrap account=20 > +credentials /// typedef struct { > + UINT8 GroupExtensionId; > + UINT8 DisableBootstrapControl; > +} IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA; > + > +/// > +/// The response data of getting bootstrap credential /// typedef=20 > +struct { > + UINT8 CompletionCode; > + UINT8 GroupExtensionId; > + CHAR8 Username[USERNAME_MAX_LENGTH]; > + CHAR8 Password[PASSWORD_MAX_LENGTH]; > +} IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE; > + > +#pragma pack() > + > +/** > + Function to retrieve temporary use credentials for the UEFI redfish=20 > +client [Chang, Abner] We miss the functionality to disable bootstrap credential service in the fu= nction description. > + > + @param[in] DisableBootstrapControl > + TRUE - Tell the BMC to disable the= bootstrap credential > + service to ensure no one el= se gains credentials > + FALSE Allow the bootstrap=20 > + credential service to continue @param[out] BootstrapUsername > + A pointer to a UTF-8 encoded=20 > + string for the credential username > + > + @param[out] BootstrapPassword > + A pointer to a UTF-8 encoded=20 > + string for the credential password > + > + @retval EFI_SUCCESS Credentials were successfully fetc= hed and > returned [Chang, Abner] Or the bootstrap credential service is disabled successfully, right? > + @retval EFI_DEVICE_ERROR An IPMI failure occurred > +**/ > +EFI_STATUS > +GetBootstrapAccountCredentials ( > + IN BOOLEAN DisableBootstrapControl, > + IN OUT CHAR8 *BootstrapUsername, > + IN OUT CHAR8 *BootstrapPassword > + ); > diff --git > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede > ntialLi > b.inf > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede > ntialLi > b.inf > new file mode 100644 > index 0000000000..a990d28363 > --- /dev/null > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformC > +++ re > +++ dentialLib.inf > @@ -0,0 +1,37 @@ > +## @file > +# > +# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## > + > +[Defines] > + INF_VERSION =3D 0x0001000b > + BASE_NAME =3D RedfishPlatformCredentialLib > + FILE_GUID =3D 9C45D622-4C66-417F-814C-F76246D9723= 3 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RedfishPlatformCredentialLib > + > +[Sources] > + RedfishPlatformCredentialLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + IpmiFeaturePkg/IpmiFeaturePkg.dec [Chang, Abner] Could you please add a comment to the reference of IpmiFeaturePkg? We have= to give customers a notice that the dependence of "edk2-platforms/Features= /Intel/OutOfBandManagement/". They have to add the path to PACKAGES_PATH. Y= ou also have to skip this dependence in the RedfishPkg.yaml to avoid the CI= error. Another thing is I propose to move out IpmiFeaturePkg from edk2-platforms/F= eatures/Intel/OutOfBandManagement to edk2-platforms/Features/ManageabilityP= kg that also provides the implementation of PLDM/MCTP/IPMI/KCS. I had an = initial talk with IpmiFeaturePkg owner and get the positive response on thi= s proposal. I will kick off the discussion on the dev mailing list. That is= to say this module may need a little bit change later, however that is goo= d to me having this implementation now. Thanks Abner > + > +[LibraryClasses] > + UefiLib > + DebugLib > + IpmiBaseLib > + MemoryAllocationLib > + BaseMemoryLib > + > +[Pcd] > + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable > + > +[Depex] > + TRUE > -- > 2.17.1