public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
@ 2016-11-16 13:57 Star Zeng
  2016-11-17  3:18 ` Zhang, Chao B
  0 siblings, 1 reply; 3+ messages in thread
From: Star Zeng @ 2016-11-16 13:57 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Chao Zhang

In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned
Buffer should be real copied DigestList count.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..caa370c94381 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,10 @@ CopyDigestListToBuffer (
 {
   UINTN  Index;
   UINT16 DigestSize;
+  UINT32 *DigestListCount;
 
-  CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));
+  DigestListCount = (UINT32 *) Buffer;
+  *DigestListCount = 0;
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
   for (Index = 0; Index < DigestList->count; Index++) {
     if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) {
@@ -243,6 +245,7 @@ CopyDigestListToBuffer (
     DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
     CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
     Buffer = (UINT8 *)Buffer + DigestSize;
+    (*DigestListCount)++;
   }
 
   return Buffer;
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
  2016-11-16 13:57 [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer() Star Zeng
@ 2016-11-17  3:18 ` Zhang, Chao B
  2016-11-17  8:06   ` Zeng, Star
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Chao B @ 2016-11-17  3:18 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen

Hi Star:
  Please use WtiteUnaligned32 to update hash count. Others are good to me.





Thanks & Best regards
Chao Zhang

-----Original Message-----
From: Zeng, Star 
Sent: Wednesday, November 16, 2016 9:58 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star; Yao, Jiewen; Zhang, Chao B
Subject: [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()

In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned
Buffer should be real copied DigestList count.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..caa370c94381 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,10 @@ CopyDigestListToBuffer (
 {
   UINTN  Index;
   UINT16 DigestSize;
+  UINT32 *DigestListCount;
 
-  CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));
+  DigestListCount = (UINT32 *) Buffer;
+  *DigestListCount = 0;
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
   for (Index = 0; Index < DigestList->count; Index++) {
     if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) {
@@ -243,6 +245,7 @@ CopyDigestListToBuffer (
     DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
     CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
     Buffer = (UINT8 *)Buffer + DigestSize;
+    (*DigestListCount)++;
   }
 
   return Buffer;
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
  2016-11-17  3:18 ` Zhang, Chao B
@ 2016-11-17  8:06   ` Zeng, Star
  0 siblings, 0 replies; 3+ messages in thread
From: Zeng, Star @ 2016-11-17  8:06 UTC (permalink / raw)
  To: Zhang, Chao B, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Zeng, Star

Chao,

Great comments, just sent out V2 patch, please help review it.

Thanks,
Star
-----Original Message-----
From: Zhang, Chao B 
Sent: Thursday, November 17, 2016 11:19 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>
Subject: RE: [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()

Hi Star:
  Please use WtiteUnaligned32 to update hash count. Others are good to me.





Thanks & Best regards
Chao Zhang

-----Original Message-----
From: Zeng, Star
Sent: Wednesday, November 16, 2016 9:58 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star; Yao, Jiewen; Zhang, Chao B
Subject: [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()

In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned Buffer should be real copied DigestList count.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..caa370c94381 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,10 @@ CopyDigestListToBuffer (  {
   UINTN  Index;
   UINT16 DigestSize;
+  UINT32 *DigestListCount;
 
-  CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));
+  DigestListCount = (UINT32 *) Buffer;
+  *DigestListCount = 0;
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
   for (Index = 0; Index < DigestList->count; Index++) {
     if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) { @@ -243,6 +245,7 @@ CopyDigestListToBuffer (
     DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
     CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
     Buffer = (UINT8 *)Buffer + DigestSize;
+    (*DigestListCount)++;
   }
 
   return Buffer;
--
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-17  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16 13:57 [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer() Star Zeng
2016-11-17  3:18 ` Zhang, Chao B
2016-11-17  8:06   ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox