public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "levi.yun" <yeoreum.yun@arm.com>
To: "Li, Yi1" <yi1.li@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"Lu, Xiaoyu1" <xiaoyu1.lu@intel.com>,
	"Jiang, Guomin" <guomin.jiang@intel.com>,
	"sami.mujawar@arm.com" <sami.mujawar@arm.com>,
	"pierre.gondois@arm.com" <pierre.gondois@arm.com>,
	"nd@arm.com" <nd@arm.com>
Subject: Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/BaseCryptoLib: Remove unnecessary key generation.
Date: Tue, 18 Jul 2023 09:23:32 +0100	[thread overview]
Message-ID: <96c24531-d8da-551e-f23f-f2fdb4b905a6@arm.com> (raw)
In-Reply-To: <SJ1PR11MB622754A7F0F94A834CE0C804C538A@SJ1PR11MB6227.namprd11.prod.outlook.com>

Hi Li!

On 18/07/2023 07:03, Li, Yi1 wrote:
> Hi,
>
> This function has a special use case: when the input PublicKey array is NULL and size is 0, the function will generate EC keypair and update context, and fill PublicKeySize with non-zero keysize to indicate success.
>
> (CryptEc.c  L492)
>    if ((PublicKey == NULL) && (*PublicKeySize != 0)) {
>      return FALSE;
>    }

Thanks to make me know :)

IIUC, That special case could be used with EcGetPubKey.

>
> I recommend the below changes:
>
>    HalfSize = (EC_GROUP_get_degree (Group) + 7) / 8;
>
> +  if ((PublicKey != NULL) && (*PublicKeySize < HalfSize * 2)) {
> +    *PublicKeySize = HalfSize * 2;
> +    return FALSE;
> +  }
>    // Assume RAND_seed was called
>    if (EC_KEY_generate_key (EcKey) != 1) {
>      return FALSE;
>    }
>
> -  if (*PublicKeySize < HalfSize * 2) {
> + // If PublicKey is NULL and PublicKeySize is 0, return TRUE and fill PublicKeySize with correct Key size.
> + if (*PublicKeySize == 0) {
>      *PublicKeySize = HalfSize * 2;
> -   return FALSE;
> +   return TRUE;
>    }

Look good to me But it would be better to set key size above of If clause.

I'll send the patch again :)


Many thanks.

--------

Sincerely,

Levi.


IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106983): https://edk2.groups.io/g/devel/message/106983
Mute This Topic: https://groups.io/mt/100191693/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      reply	other threads:[~2023-07-18  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17  9:54 [edk2-devel] [PATCH v1 1/1] CryptoPkg/BaseCryptoLib: Remove unnecessary key generation levi.yun
2023-07-18  6:03 ` Li, Yi
2023-07-18  8:23   ` levi.yun [this message]

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=96c24531-d8da-551e-f23f-f2fdb4b905a6@arm.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