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

Min Xu min.m.xu at intel.com
Thu Jan 26 01:56:40 UTC 2023


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\PrePiMemoryAllocationLib.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 (#99057): https://edk2.groups.io/g/devel/message/99057
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