public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jiewen Yao <jiewen.yao@intel.com>
To: edk2-devel@lists.01.org
Cc: Chao Zhang <chao.b.zhang@intel.com>, Qin Long <qin.long@intel.com>
Subject: [PATCH 1/2] SecurityPkg/FmpAuthLib: Add PublicKeyDataLength check
Date: Thu, 22 Dec 2016 13:00:28 +0800	[thread overview]
Message-ID: <1482382829-12168-2-git-send-email-jiewen.yao@intel.com> (raw)
In-Reply-To: <1482382829-12168-1-git-send-email-jiewen.yao@intel.com>

Add PublicKeyDataLength check to be multiple SHA256_DIGEST_SIZE
to avoid caller make mistake, or platform mis-configuration.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Qin Long <qin.long@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
---
 SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.c b/SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.c
index d113d58..4b2556c 100644
--- a/SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.c
+++ b/SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.c
@@ -306,6 +306,11 @@ AuthenticateFmpImage (
     return RETURN_UNSUPPORTED;
   }
 
+  if ((PublicKeyDataLength % SHA256_DIGEST_SIZE) != 0) {
+    DEBUG ((DEBUG_ERROR, "PublicKeyDataLength is not multiple SHA256 size\n"));
+    return RETURN_UNSUPPORTED;
+  }
+
   if (ImageSize < sizeof(EFI_FIRMWARE_IMAGE_AUTHENTICATION)) {
     DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - ImageSize too small\n"));
     return RETURN_INVALID_PARAMETER;
-- 
2.7.4.windows.1



  reply	other threads:[~2016-12-22  5:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22  5:00 [PATCH 0/2] Add check for PublicKeyDataLength Jiewen Yao
2016-12-22  5:00 ` Jiewen Yao [this message]
2016-12-22  5:14   ` [PATCH 1/2] SecurityPkg/FmpAuthLib: Add PublicKeyDataLength check Long, Qin
2016-12-22  5:00 ` [PATCH 2/2] SignedCapsulePkg/SystemCapsuleLib: Add ASSERT check for PCD Jiewen Yao
2016-12-22  5:15   ` Long, Qin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482382829-12168-2-git-send-email-jiewen.yao@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox