[edk2-devel] [PATCH V3 3/9] OvmfPkg/IntelTdx: Add SecTdxHelperLib

Yao, Jiewen jiewen.yao at intel.com
Thu Jan 26 02:01:53 UTC 2023


Hey
I don't think it is a good idea to define a context size here, because that will assume the openssl implementation. Please don't do that.

Could you please just use Sha384HashAll() API, if you don't like to allocate memory?

Thank you
Yao, Jiewen

> -----Original Message-----
> From: Xu, Min M <min.m.xu at intel.com>
> Sent: Thursday, January 26, 2023 9:57 AM
> To: devel at edk2.groups.io; kraxel at redhat.com
> Cc: Aktas, Erdem <erdemaktas at google.com>; James Bottomley
> <jejb at linux.ibm.com>; Yao, Jiewen <jiewen.yao at intel.com>; Tom Lendacky
> <thomas.lendacky at amd.com>; Michael Roth <michael.roth at amd.com>
> Subject: RE: [edk2-devel] [PATCH V3 3/9] OvmfPkg/IntelTdx: Add
> SecTdxHelperLib
> 
> On January 25, 2023 8:16 PM, Gerd Hoffmann wrote:
> > > +//
> > > +// SHA512_CTX is defined in <openssl/sha.h> and its size is 216 bytes.
> > > +// It can be built successfully with GCC5 compiler but failed with VS2019.
> > > +// The error code showed in VS2019 is that "openssl/sha.h" cannot be
> found.
> > > +// To overcome this error SHA512_CTX_SIZE is defined.
> > > +//
> > > +#define SHA512_CTX_SIZ  216
> >
> > There is Sha384GetContextSize()
> >
> HashAndExtendToRtmr is designed to be run in very early stage and at that stage
> Memory allocation service is not ready. So we have to declare an array with size
> of SHA512_CTX_SIZE(216).
> 
> Variable-length automatic arrays are allowed in C99.
> https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html So if ovmf is built with
> GCC, then the code below works:
>   UINT8       Sha384Ctx[Sha384GetContextSize ()];
> 
> But unfortunately it is not supported in VS series. (I test it with VS2017)
> Building ...
> tdvf2\EmbeddedPkg\Library\PrePiMemoryAllocationLib\PrePiMemoryAllocation
> Lib.inf [X64]
> tdvf2\OvmfPkg\IntelTdx\TdxHelperLib\SecTdxHelper.c(839): error C2057:
> expected constant expression
> tdvf2\OvmfPkg\IntelTdx\TdxHelperLib\SecTdxHelper.c(839): error C2466:
> cannot allocate an array of constant size 0
> tdvf2\OvmfPkg\IntelTdx\TdxHelperLib\SecTdxHelper.c(839): error C2133:
> 'Sha384Ctx': unknown size
> 
> So Sha384GetContextSize() cannot be used here.
> 
> Thanks
> Min


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99059): https://edk2.groups.io/g/devel/message/99059
Mute This Topic: https://groups.io/mt/96513452/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list