From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 666168212C for ; Tue, 21 Feb 2017 00:25:27 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 21 Feb 2017 00:25:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,188,1484035200"; d="scan'208";a="68273171" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 21 Feb 2017 00:25:27 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 21 Feb 2017 00:25:27 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 21 Feb 2017 00:25:26 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0248.002; Tue, 21 Feb 2017 16:25:24 +0800 From: "Zhang, Chao B" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Long, Qin" Thread-Topic: [PATCH] SecurityPkg/TpmCommandLib: Add Tpm2ReadPublic. Thread-Index: AQHSgux+5kOiCPh1aEm3P84kTOmmHaFzMh+w Date: Tue, 21 Feb 2017 08:25:23 +0000 Message-ID: References: <1486655516-11504-1-git-send-email-jiewen.yao@intel.com> In-Reply-To: <1486655516-11504-1-git-send-email-jiewen.yao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg/TpmCommandLib: Add Tpm2ReadPublic. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Feb 2017 08:25:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Chao Zhang -----Original Message----- From: Yao, Jiewen=20 Sent: Thursday, February 9, 2017 11:52 PM To: edk2-devel@lists.01.org Cc: Zhang, Chao B ; Long, Qin ;= Yao, Jiewen Subject: [PATCH] SecurityPkg/TpmCommandLib: Add Tpm2ReadPublic. Cc: Chao Zhang Cc: Long Qin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yao Jiewen --- SecurityPkg/Include/Library/Tpm2CommandLib.h | 22 +- SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf | 3 +- SecurityPkg/Library/Tpm2CommandLib/Tpm2Object.c | 346 ++++++++++++++= ++++++ 3 files changed, 369 insertions(+), 2 deletions(-) diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Inc= lude/Library/Tpm2CommandLib.h index f7a04f2..80ada73 100644 --- a/SecurityPkg/Include/Library/Tpm2CommandLib.h +++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h @@ -1,7 +1,7 @@ /** @file This library is used by other modules to send TPM2 command. =20 -Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -959,6 +95= 9,26 @@ Tpm2PolicyGetDigest ( OUT TPM2B_DIGEST *PolicyHash ); =20 +/** + This command allows access to the public area of a loaded object. + + @param[in] ObjectHandle TPM handle of an object + @param[out] OutPublic Structure containing the public area= of an object + @param[out] Name Name of the object + @param[out] QualifiedName The Qualified Name of the object + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_DEVICE_ERROR Unexpected device behavior. +**/ +EFI_STATUS +EFIAPI +Tpm2ReadPublic ( + IN TPMI_DH_OBJECT ObjectHandle, + OUT TPM2B_PUBLIC *OutPublic, + OUT TPM2B_NAME *Name, + OUT TPM2B_NAME *QualifiedName + ); + // // Help function // diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf b/Securi= tyPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf index 740af3f..481a878 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf @@ -3,7 +3,7 @@ # # This library is used by other modules to send TPM 2.0 command. # -# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2013 - 2017, Intel Corporation. All rights=20 +reserved.
# This program and the accompanying materials # are licensed and made ava= ilable under the terms and conditions of the BSD License # which accompani= es this distribution. The full text of the license may be found at @@ -40,6= +40,7 @@ Tpm2EnhancedAuthorization.c Tpm2Test.c Tpm2DictionaryAttack.c + Tpm2Object.c Tpm2Miscellaneous.c Tpm2Help.c =20 diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Object.c b/SecurityPkg/= Library/Tpm2CommandLib/Tpm2Object.c new file mode 100644 index 0000000..e070ff2 --- /dev/null +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Object.c @@ -0,0 +1,346 @@ +/** @file + Implement TPM2 Object related command. + +Copyright (c) 2017, Intel Corporation. All rights reserved.
This=20 +program and the accompanying materials are licensed and made available=20 +under the terms and conditions of the BSD License which accompanies=20 +this distribution. The full text of the license may be found at=20 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,=20 +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. + +**/ + +#include +#include +#include +#include +#include +#include + +#pragma pack(1) + +typedef struct { + TPM2_COMMAND_HEADER Header; + TPMI_DH_OBJECT ObjectHandle; +} TPM2_READ_PUBLIC_COMMAND; + +typedef struct { + TPM2_RESPONSE_HEADER Header; + TPM2B_PUBLIC OutPublic; + TPM2B_NAME Name; + TPM2B_NAME QualifiedName; +} TPM2_READ_PUBLIC_RESPONSE; + +#pragma pack() + +/** + This command allows access to the public area of a loaded object. + + @param[in] ObjectHandle TPM handle of an object + @param[out] OutPublic Structure containing the public area= of an object + @param[out] Name Name of the object + @param[out] QualifiedName The Qualified Name of the object + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_DEVICE_ERROR Unexpected device behavior. +**/ +EFI_STATUS +EFIAPI +Tpm2ReadPublic ( + IN TPMI_DH_OBJECT ObjectHandle, + OUT TPM2B_PUBLIC *OutPublic, + OUT TPM2B_NAME *Name, + OUT TPM2B_NAME *QualifiedName + ) +{ + EFI_STATUS Status; + TPM2_READ_PUBLIC_COMMAND SendBuffer; + TPM2_READ_PUBLIC_RESPONSE RecvBuffer; + UINT32 SendBufferSize; + UINT32 RecvBufferSize; + TPM_RC ResponseCode; + UINT8 *Buffer; + UINT16 OutPublicSize; + UINT16 NameSize; + UINT16 QualifiedNameSize; + + // + // Construct command + // + SendBuffer.Header.tag =3D SwapBytes16(TPM_ST_NO_SESSIONS); =20 + SendBuffer.Header.commandCode =3D SwapBytes32(TPM_CC_ReadPublic); + + SendBuffer.ObjectHandle =3D SwapBytes32 (ObjectHandle); + + SendBufferSize =3D (UINT32) sizeof (SendBuffer); =20 + SendBuffer.Header.paramSize =3D SwapBytes32 (SendBufferSize); + + // + // send Tpm command + // + RecvBufferSize =3D sizeof (RecvBuffer); Status =3D Tpm2SubmitCommand=20 + (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8=20 + *)&RecvBuffer); if (EFI_ERROR (Status)) { + return Status; + } + + if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { + DEBUG ((DEBUG_ERROR, "Tpm2ReadPublic - RecvBufferSize Error - %x\n", R= ecvBufferSize)); + return EFI_DEVICE_ERROR; + } + ResponseCode =3D SwapBytes32(RecvBuffer.Header.responseCode); + if (ResponseCode !=3D TPM_RC_SUCCESS) { + DEBUG ((DEBUG_ERROR, "Tpm2ReadPublic - responseCode - %x\n",=20 + SwapBytes32(RecvBuffer.Header.responseCode))); + } + switch (ResponseCode) { + case TPM_RC_SUCCESS: + // return data + break; + case TPM_RC_SEQUENCE: + // objectHandle references a sequence object + return EFI_INVALID_PARAMETER; + default: + return EFI_DEVICE_ERROR; + } + + // + // Basic check + // + OutPublicSize =3D SwapBytes16 (RecvBuffer.OutPublic.size); NameSize =3D= =20 + SwapBytes16 (ReadUnaligned16 ((UINT16 *)((UINT8 *)&RecvBuffer + sizeof(TP= M2_RESPONSE_HEADER) + + sizeof(UINT16) + OutPublicSize))); =20 + QualifiedNameSize =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)((UINT8 *)&= RecvBuffer + sizeof(TPM2_RESPONSE_HEADER) + + sizeof(UINT16) + OutPublicSize + + sizeof(UINT16) + NameSize))); + + if (RecvBufferSize !=3D sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + = OutPublicSize + sizeof(UINT16) + NameSize + sizeof(UINT16) + QualifiedNameS= ize) { + DEBUG ((DEBUG_ERROR, "Tpm2ReadPublic - RecvBufferSize %x Error - OutPu= blicSize %x, NameSize %x, QualifiedNameSize %x\n", RecvBufferSize, OutPubli= cSize, NameSize, QualifiedNameSize)); + return EFI_DEVICE_ERROR; + } + + // + // Return the response + // + Buffer =3D (UINT8 *)&RecvBuffer.OutPublic; CopyMem (OutPublic,=20 + &RecvBuffer.OutPublic, sizeof(UINT16) + OutPublicSize); =20 + OutPublic->size =3D OutPublicSize; OutPublic->publicArea.type =3D=20 + SwapBytes16 (OutPublic->publicArea.type); =20 + OutPublic->publicArea.nameAlg =3D SwapBytes16=20 + (OutPublic->publicArea.nameAlg); + WriteUnaligned32 ((UINT32 *)&OutPublic->publicArea.objectAttributes,=20 + SwapBytes32 (ReadUnaligned32 ((UINT32=20 + *)&OutPublic->publicArea.objectAttributes))); + Buffer =3D (UINT8 *)&RecvBuffer.OutPublic.publicArea.authPolicy; + OutPublic->publicArea.authPolicy.size =3D SwapBytes16 (ReadUnaligned16=20 + ((UINT16 *)Buffer)); Buffer +=3D sizeof(UINT16); CopyMem=20 + (OutPublic->publicArea.authPolicy.buffer, Buffer,=20 + OutPublic->publicArea.authPolicy.size); + Buffer +=3D OutPublic->publicArea.authPolicy.size; + + // TPMU_PUBLIC_PARMS + switch (OutPublic->publicArea.type) { case TPM_ALG_KEYEDHASH: + OutPublic->publicArea.parameters.keyedHashDetail.scheme.scheme =3D Swa= pBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.keyedHashDetail.scheme.scheme= ) { + case TPM_ALG_HMAC: + OutPublic->publicArea.parameters.keyedHashDetail.scheme.details.hmac= .hashAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_XOR: + OutPublic->publicArea.parameters.keyedHashDetail.scheme.details.xor.= hashAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.keyedHashDetail.scheme.details.xor.= kdf =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + default: + return EFI_UNSUPPORTED; + } + case TPM_ALG_SYMCIPHER: + OutPublic->publicArea.parameters.symDetail.algorithm =3D SwapBytes16 (= ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.symDetail.algorithm) { + case TPM_ALG_AES: + OutPublic->publicArea.parameters.symDetail.keyBits.aes =3D SwapBytes= 16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.symDetail.mode.aes =3D SwapBytes16 = (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_SM4: + OutPublic->publicArea.parameters.symDetail.keyBits.SM4 =3D SwapBytes= 16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.symDetail.mode.SM4 =3D SwapBytes16 = (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_XOR: + OutPublic->publicArea.parameters.symDetail.keyBits.xor =3D SwapBytes= 16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_NULL: + break; + default: + return EFI_UNSUPPORTED; + } + break; + case TPM_ALG_RSA: + OutPublic->publicArea.parameters.rsaDetail.symmetric.algorithm =3D Swa= pBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.rsaDetail.symmetric.algorithm= ) { + case TPM_ALG_AES: + OutPublic->publicArea.parameters.rsaDetail.symmetric.keyBits.aes =3D= SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.rsaDetail.symmetric.mode.aes =3D Sw= apBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_SM4: + OutPublic->publicArea.parameters.rsaDetail.symmetric.keyBits.SM4 =3D= SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.rsaDetail.symmetric.mode.SM4 =3D Sw= apBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_NULL: + break; + default: + return EFI_UNSUPPORTED; + } + OutPublic->publicArea.parameters.rsaDetail.scheme.scheme =3D SwapBytes= 16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.rsaDetail.scheme.scheme) { + case TPM_ALG_RSASSA: + OutPublic->publicArea.parameters.rsaDetail.scheme.details.rsassa.has= hAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_RSAPSS: + OutPublic->publicArea.parameters.rsaDetail.scheme.details.rsapss.has= hAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_RSAES: + break; + case TPM_ALG_OAEP: + OutPublic->publicArea.parameters.rsaDetail.scheme.details.oaep.hashA= lg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_NULL: + break; + default: + return EFI_UNSUPPORTED; + } + OutPublic->publicArea.parameters.rsaDetail.keyBits =3D SwapBytes16 (Re= adUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.rsaDetail.exponent =3D SwapBytes16 (R= eadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT32); + break; + case TPM_ALG_ECC: + OutPublic->publicArea.parameters.eccDetail.symmetric.algorithm =3D Swa= pBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.eccDetail.symmetric.algorithm= ) { + case TPM_ALG_AES: + OutPublic->publicArea.parameters.eccDetail.symmetric.keyBits.aes =3D= SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.eccDetail.symmetric.mode.aes =3D Sw= apBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_SM4: + OutPublic->publicArea.parameters.eccDetail.symmetric.keyBits.SM4 =3D= SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.eccDetail.symmetric.mode.SM4 =3D Sw= apBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_NULL: + break; + default: + return EFI_UNSUPPORTED; + } + OutPublic->publicArea.parameters.eccDetail.scheme.scheme =3D SwapBytes= 16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.eccDetail.scheme.scheme) { + case TPM_ALG_ECDSA: + OutPublic->publicArea.parameters.eccDetail.scheme.details.ecdsa.hash= Alg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_ECDAA: + OutPublic->publicArea.parameters.eccDetail.scheme.details.ecdaa.hash= Alg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_ECSCHNORR: + OutPublic->publicArea.parameters.eccDetail.scheme.details.ecSchnorr.= hashAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_ECDH: + break; + case TPM_ALG_NULL: + break; + default: + return EFI_UNSUPPORTED; + } + OutPublic->publicArea.parameters.eccDetail.curveID =3D SwapBytes16 (Re= adUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + OutPublic->publicArea.parameters.eccDetail.kdf.scheme =3D SwapBytes16 = (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + switch (OutPublic->publicArea.parameters.eccDetail.kdf.scheme) { + case TPM_ALG_MGF1: + OutPublic->publicArea.parameters.eccDetail.kdf.details.mgf1.hashAlg = =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_KDF1_SP800_108: + OutPublic->publicArea.parameters.eccDetail.kdf.details.kdf1_sp800_10= 8.hashAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_KDF1_SP800_56a: + OutPublic->publicArea.parameters.eccDetail.kdf.details.kdf1_SP800_56= a.hashAlg =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_KDF2: + OutPublic->publicArea.parameters.eccDetail.kdf.details.kdf2.hashAlg = =3D SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + break; + case TPM_ALG_NULL: + break; + default: + return EFI_UNSUPPORTED; + } + break; + default: + return EFI_UNSUPPORTED; + } + + // TPMU_PUBLIC_ID + switch (OutPublic->publicArea.type) { case TPM_ALG_KEYEDHASH: + OutPublic->publicArea.unique.keyedHash.size =3D SwapBytes16 (ReadUnali= gned16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + CopyMem (OutPublic->publicArea.unique.keyedHash.buffer, Buffer, OutPub= lic->publicArea.unique.keyedHash.size); + Buffer +=3D OutPublic->publicArea.unique.keyedHash.size; + break; + case TPM_ALG_SYMCIPHER: + OutPublic->publicArea.unique.sym.size =3D SwapBytes16 (ReadUnaligned16= ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + CopyMem (OutPublic->publicArea.unique.sym.buffer, Buffer, OutPublic->p= ublicArea.unique.sym.size); + Buffer +=3D OutPublic->publicArea.unique.sym.size; + break; + case TPM_ALG_RSA: + OutPublic->publicArea.unique.rsa.size =3D SwapBytes16 (ReadUnaligned16= ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + CopyMem (OutPublic->publicArea.unique.rsa.buffer, Buffer, OutPublic->p= ublicArea.unique.rsa.size); + Buffer +=3D OutPublic->publicArea.unique.rsa.size; + break; + case TPM_ALG_ECC: + OutPublic->publicArea.unique.ecc.x.size =3D SwapBytes16 (ReadUnaligned= 16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + CopyMem (OutPublic->publicArea.unique.ecc.x.buffer, Buffer, OutPublic-= >publicArea.unique.ecc.x.size); + Buffer +=3D OutPublic->publicArea.unique.ecc.x.size; + OutPublic->publicArea.unique.ecc.y.size =3D SwapBytes16 (ReadUnaligned= 16 ((UINT16 *)Buffer)); + Buffer +=3D sizeof(UINT16); + CopyMem (OutPublic->publicArea.unique.ecc.y.buffer, Buffer, OutPublic-= >publicArea.unique.ecc.y.size); + Buffer +=3D OutPublic->publicArea.unique.ecc.y.size; + break; + default: + return EFI_UNSUPPORTED; + } + + CopyMem (Name->name, (UINT8 *)&RecvBuffer +=20 + sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + OutPublicSize +=20 + sizeof(UINT16), NameSize); Name->size =3D NameSize; + + CopyMem (QualifiedName->name, (UINT8 *)&RecvBuffer +=20 + sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + OutPublicSize +=20 + sizeof(UINT16) + NameSize + sizeof(UINT16), QualifiedNameSize); =20 + QualifiedName->size =3D QualifiedNameSize; + + return EFI_SUCCESS; +} -- 2.7.4.windows.1