[edk2-devel] [PATCH v1 1/1] CryptoPkg/BaseCryptoLib: Remove unnecessary key generation.

levi.yun yeoreum.yun at arm.com
Tue Jul 18 08:23:32 UTC 2023


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/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