From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E50132237A4D9 for ; Sun, 11 Feb 2018 19:02:36 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2018 19:08:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,499,1511856000"; d="scan'208";a="17008525" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 11 Feb 2018 19:08:25 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 11 Feb 2018 19:08:24 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 11 Feb 2018 19:08:24 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Mon, 12 Feb 2018 11:08:22 +0800 From: "Wu, Jiaxin" To: "Ye, Ting" , "edk2-devel@lists.01.org" CC: Laszlo Ersek , "Kinney, Michael D" , "Zimmer, Vincent" , "Yao, Jiewen" , "Fu, Siyuan" Thread-Topic: [PATCH v2 2/2] NetworkPkg: Read HttpTlsCipherList variable and configure it for HTTPS session. Thread-Index: AQHTouaR6GQj+4OJKkanZLEJQX3I4KOfkOAAgACGhYA= Date: Mon, 12 Feb 2018 03:08:22 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B727416381EB4@SHSMSX103.ccr.corp.intel.com> References: <1518318916-12816-1-git-send-email-jiaxin.wu@intel.com> <1518318916-12816-3-git-send-email-jiaxin.wu@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2RhNWQyNjgtMzY4Yi00MGEzLWExNWItNjZjMThmMGM3ZmY1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkpnMmJWdEVcL3RNSzM0QVVSRk90M3FMNTFLNit1T3dLNGhhNE12YzNpRGprPSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 2/2] NetworkPkg: Read HttpTlsCipherList variable and configure it for HTTPS session. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Feb 2018 03:02:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks the comment, I will integrate it when I commit the patch. > -----Original Message----- > From: Ye, Ting > Sent: Monday, February 12, 2018 11:06 AM > To: Wu, Jiaxin ; edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Kinney, Michael D > ; Zimmer, Vincent > ; Yao, Jiewen ; Fu, > Siyuan > Subject: RE: [PATCH v2 2/2] NetworkPkg: Read HttpTlsCipherList variable a= nd > configure it for HTTPS session. >=20 > Hi Jiaxin, >=20 > In following code, how about use "gEdkiiHttpTlsCipherListGuid" as the > variable GUID as to make it consistent with the variable name? >=20 > + Status =3D gRT->GetVariable ( > + EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE, > + &gHttpTlsCipherListGuid, > + NULL, > + &CipherListSize, > + NULL > + ); >=20 > Others are good to me. > Reviewed-by: Ye Ting >=20 > Best Regards, > Ting >=20 > -----Original Message----- > From: Wu, Jiaxin > Sent: Sunday, February 11, 2018 11:15 AM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Kinney, Michael D > ; Zimmer, Vincent > ; Yao, Jiewen ; Ye, > Ting ; Fu, Siyuan ; Wu, Jiaxin > > Subject: [PATCH v2 2/2] NetworkPkg: Read HttpTlsCipherList variable and > configure it for HTTPS session. >=20 > v2: > * Refine the error handling returned from GetVariable. >=20 > This patch is to read the HttpTlsCipherList variable and configure it for= the > later HTTPS session. >=20 > If the variable is not set by any platform, EFI_NOT_FOUND will be returne= d > from GetVariable service. In such a case, the default CipherList created = in > TlsDxe driver will be used. >=20 > Cc: Laszlo Ersek > Cc: Kinney Michael D > Cc: Zimmer Vincent > Cc: Yao Jiewen > Cc: Ye Ting > Cc: Fu Siyuan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wu Jiaxin > --- > NetworkPkg/HttpDxe/HttpDriver.h | 3 +- > NetworkPkg/HttpDxe/HttpDxe.inf | 3 +- > NetworkPkg/HttpDxe/HttpsSupport.c | 92 > ++++++++++++++++++++++++++++++++++++++- > 3 files changed, 95 insertions(+), 3 deletions(-) >=20 > diff --git a/NetworkPkg/HttpDxe/HttpDriver.h > b/NetworkPkg/HttpDxe/HttpDriver.h index 93a412a..3b7a7a2 100644 > --- a/NetworkPkg/HttpDxe/HttpDriver.h > +++ b/NetworkPkg/HttpDxe/HttpDriver.h > @@ -1,9 +1,9 @@ > /** @file > The header files of the driver binding and service binding protocol fo= r > HttpDxe driver. >=20 > - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2015 - 2018, Intel Corporation. All rights > + reserved.
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>=20 > This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at @@ -59,10 +59,11 @@ // Produced Protocols // #include > >=20 > #include > +#include >=20 > #include >=20 > // > // Driver Version > diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf > b/NetworkPkg/HttpDxe/HttpDxe.inf index 20075f5..56a2472 100644 > --- a/NetworkPkg/HttpDxe/HttpDxe.inf > +++ b/NetworkPkg/HttpDxe/HttpDxe.inf > @@ -1,9 +1,9 @@ > ## @file > # Implementation of EFI HTTP protocol interfaces. > # > -# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved. > +# Copyright (c) 2015 - 2018, Intel Corporation. All rights > +reserved.
> # > # This program and the accompanying materials # are licensed and made > available under the terms and conditions of the BSD License # which > accompanies this distribution. The full text of the license may be found = at # > http://opensource.org/licenses/bsd-license.php. > @@ -72,10 +72,11 @@ > gEfiTlsProtocolGuid ## SOMETIMES_CONSUMES > gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES >=20 > [Guids] > gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES= ## > Variable:L"TlsCaCertificate" > + gHttpTlsCipherListGuid ## SOMETIMES_CONSUMES= ## > Variable:L"HttpTlsCipherList" >=20 > [Pcd] > gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections ## > CONSUMES > gEfiNetworkPkgTokenSpaceGuid.PcdHttpsAuthenticationMode ## > SOMETIMES_CONSUMES > gEfiNetworkPkgTokenSpaceGuid.PcdHttpsHostPublicCert ## > SOMETIMES_CONSUMES > diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c > b/NetworkPkg/HttpDxe/HttpsSupport.c > index 288082a..fbe4087 100644 > --- a/NetworkPkg/HttpDxe/HttpsSupport.c > +++ b/NetworkPkg/HttpDxe/HttpsSupport.c > @@ -1,9 +1,9 @@ > /** @file > Miscellaneous routines specific to Https for HttpDxe driver. >=20 > -Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP
This > program and the accompanying materials are licensed and made available > under the terms and conditions of the BSD License which accompanies this > distribution. The full text of the license may be found at > http://opensource.org/licenses/bsd-license.php > @@ -492,10 +492,91 @@ TlsConfigCertificate ( >=20 > return Status; > } >=20 > /** > + Read the HttpTlsCipherList variable and configure it for HTTPS session= . > + > + @param[in, out] HttpInstance The HTTP instance private data. > + > + @retval EFI_SUCCESS The prefered HTTP TLS CipherList is con= figured. > + @retval EFI_NOT_FOUND Fail to get 'HttpTlsCipherList' variabl= e. > + @retval EFI_INVALID_PARAMETER The contents of variable are invalid. > + @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources. > + > + @retval Others Other error as indicated. > + > +**/ > +EFI_STATUS > +TlsConfigCipherList ( > + IN OUT HTTP_PROTOCOL *HttpInstance > + ) > +{ > + EFI_STATUS Status; > + UINT8 *CipherList; > + UINTN CipherListSize; > + > + CipherList =3D NULL; > + CipherListSize =3D 0; > + > + // > + // Try to read the HttpTlsCipherList variable. > + // > + Status =3D gRT->GetVariable ( > + EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE, > + &gHttpTlsCipherListGuid, > + NULL, > + &CipherListSize, > + NULL > + ); > + ASSERT (EFI_ERROR (Status)); > + if (Status !=3D EFI_BUFFER_TOO_SMALL) { > + return Status; > + } > + > + if (CipherListSize % sizeof (EFI_TLS_CIPHER) !=3D 0) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Allocate buffer and read the config variable. > + // > + CipherList =3D AllocatePool (CipherListSize); if (CipherList =3D=3D N= ULL) > + { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D gRT->GetVariable ( > + EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE, > + &gHttpTlsCipherListGuid, > + NULL, > + &CipherListSize, > + CipherList > + ); > + if (EFI_ERROR (Status)) { > + // > + // GetVariable still error or the variable is corrupted. > + // > + goto ON_EXIT; > + } > + > + ASSERT (CipherList !=3D NULL); > + > + Status =3D HttpInstance->Tls->SetSessionData ( > + HttpInstance->Tls, > + EfiTlsCipherList, > + CipherList, > + CipherListSize > + ); > + > +ON_EXIT: > + FreePool (CipherList); > + > + return Status; > +} > + > +/** > Configure TLS session data. >=20 > @param[in, out] HttpInstance The HTTP instance private data. >=20 > @retval EFI_SUCCESS TLS session data is configured. > @@ -551,10 +632,19 @@ TlsConfigureSession ( > if (EFI_ERROR (Status)) { > return Status; > } >=20 > // > + // Tls Cipher List > + // > + Status =3D TlsConfigCipherList (HttpInstance); if (EFI_ERROR (Status) > + && Status !=3D EFI_NOT_FOUND) { > + DEBUG ((EFI_D_ERROR, "TlsConfigCipherList: return %r error.\n", Stat= us)); > + return Status; > + } > + > + // > // Tls Config Certificate > // > Status =3D TlsConfigCertificate (HttpInstance); > if (EFI_ERROR (Status)) { > DEBUG ((EFI_D_ERROR, "TlsConfigCertificate: return %r error.\n", Sta= tus)); > -- > 1.9.5.msysgit.1