public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Li, Yi1" <yi1.li@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
	"Lu, Xiaoyu1" <xiaoyu1.lu@intel.com>,
	"Jiang, Guomin" <guomin.jiang@intel.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [PATCH 1/3] CryptoPkg: Update process_files.pl to automatically add PCD config option
Date: Mon, 9 May 2022 03:23:11 +0000	[thread overview]
Message-ID: <MW4PR11MB5872E9E9288BB27EDBD084A08CC69@MW4PR11MB5872.namprd11.prod.outlook.com> (raw)
In-Reply-To: <ea90c043834bf117236dcdd221a3b889d62d06a8.1652066029.git.yi1.li@intel.com>

Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: Li, Yi1 <yi1.li@intel.com>
> Sent: Monday, May 9, 2022 11:19 AM
> To: devel@edk2.groups.io
> Cc: Li, Yi1 <yi1.li@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian
> J <jian.j.wang@intel.com>; Lu, Xiaoyu1 <xiaoyu1.lu@intel.com>; Jiang, Guomin
> <guomin.jiang@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
> Subject: [PATCH 1/3] CryptoPkg: Update process_files.pl to automatically add
> PCD config option
> 
> Recommend from Gerd:
> (2) Keep the EC config option, but update process_files.pl to
>   automatically add the PcdEcEnabled config option handling
>   to the files it generates.
> 
> When remove 'no-ec' from openssl configure list, will automatically remove
> 'OPENSSL_NO_EC', 'OPENSSL_NO_ECDH', 'OPENSSL_NO_ECDSA',
> 'OPENSSL_NO_TLS1_3',
> form header, and add '/ec/.', '/sm2/.' files to INF files.
> 
> Signed-off-by: Yi Li <yi1.li@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
> Cc: Guomin Jiang <guomin.jiang@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  CryptoPkg/Library/OpensslLib/process_files.pl | 67 ++++++++++++++++++-
>  1 file changed, 65 insertions(+), 2 deletions(-)
> 
> diff --git a/CryptoPkg/Library/OpensslLib/process_files.pl
> b/CryptoPkg/Library/OpensslLib/process_files.pl
> index 2ebfbbbca0de..2849f5d9aed0 100755
> --- a/CryptoPkg/Library/OpensslLib/process_files.pl
> +++ b/CryptoPkg/Library/OpensslLib/process_files.pl
> @@ -81,6 +81,19 @@ my $uefi_config;
>  my $extension;
>  my $arch;
>  my @inf;
> +#
> +# Use PCD to conditionally enable certain openssl features.
> +# $conditional_feature contains fetures_names:pcd_name pairs
> +# of conditional features.
> +# @conditional_feature_dir contains relative_path:pcd_name pairs
> +# of conditional features in openssl, MUST correspond to the content
> +# in $conditional_feature.
> +#
> +# Configure list [openssl_configuratio : new_define_list : new_file_list : pcd]
> +# 1. no-ec : {NO_EC, NO_ECDH, NO_ECDSA, NO_TLS1_3, NO_SM2} : {/ec/,
> /sm2/} : PcdEcEnabled
> +#
> +my %conditional_feature = ("EC"=>"PcdEcEnabled", "ECDH"=>"PcdEcEnabled",
> "ECDSA"=>"PcdEcEnabled", "TLS1_3"=>"PcdEcEnabled",
> "SM2"=>"PcdEcEnabled");
> +my %conditional_feature_dir = ("/ec/"=>"PcdEcEnabled",
> "/sm2/"=>"PcdEcEnabled");
> 
>  BEGIN {
>      $inf_file = "OpensslLib.inf";
> @@ -282,7 +295,13 @@ foreach my $product ((@{$unified_info{libraries}},
>                  push @sslfilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";
>                  next;
>              }
> -            push @cryptofilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";
> +            push @cryptofilelist, '  $(OPENSSL_PATH)/' . $s;
> +            foreach (keys(%conditional_feature_dir)) {
> +                if ($s =~ $_) {
> +                    push @cryptofilelist, '      |*|*|*|gEfiCryptoPkgTokenSpaceGuid.' .
> $conditional_feature_dir{$_};
> +                }
> +            }
> +            push @cryptofilelist, "\r\n";
>          }
>      }
>  }
> @@ -311,7 +330,13 @@ foreach (@headers){
>      push @sslfilelist, '  $(OPENSSL_PATH)/' . $_ . "\r\n";
>      next;
>    }
> -  push @cryptofilelist, '  $(OPENSSL_PATH)/' . $_ . "\r\n";
> +  push @cryptofilelist, '  $(OPENSSL_PATH)/' . $_;
> +  foreach my $conditional_key (keys(%conditional_feature_dir)) {
> +    if ($_ =~ $conditional_key) {
> +        push @cryptofilelist, '      |*|*|*|gEfiCryptoPkgTokenSpaceGuid.' .
> $conditional_feature_dir{$conditional_key};
> +    }
> +  }
> +  push @cryptofilelist, "\r\n";
>  }
> 
> 
> @@ -430,6 +455,44 @@ system(
>      die "Cannot copy dso_conf.h!";
>  print "Done!\n";
> 
> +#
> +# Add conditional feature to opensslconf.h
> +#
> +my $conf_file = "../Include/openssl/opensslconf.h";
> +my @conf_raw = ();
> +my @conditional_define = ();
> +print "\n--> Updating $conf_file ... ";
> +
> +foreach my $feature_name (keys(%conditional_feature)) {
> +    push @conditional_define, "#if !FixedPcdGetBool
> ($conditional_feature{$feature_name})\r\n";
> +    push @conditional_define, "# ifndef OPENSSL_NO_$feature_name\r\n";
> +    push @conditional_define, "#  define OPENSSL_NO_$feature_name\r\n";
> +    push @conditional_define, "# endif\r\n#endif\r\n";
> +}
> +
> +open( FD, "<" . $conf_file ) ||
> +    die $conf_file;
> +foreach (<FD>) {
> +    # Insert conditional define to the begin of opensslconf.h
> +    if ($_ =~ "#ifdef OPENSSL_ALGORITHM_DEFINES") {
> +        push @conf_raw, @conditional_define;
> +    }
> +    push @conf_raw, $_;
> +    if ($_ =~ "<openssl/opensslv.h>") {
> +        push @conf_raw, "#include <Library/PcdLib.h>\r\n";
> +    }
> +}
> +close(FD) ||
> +    die $conf_file;
> +
> +open( FD, ">" . $conf_file ) ||
> +    die $conf_file;
> +print( FD @conf_raw ) ||
> +    die $conf_file;
> +close(FD) ||
> +    die $conf_file;
> +print "Done!\n";
> +
>  print "\nProcessing Files Done!\n";
> 
>  exit(0);
> --
> 2.31.1.windows.1


  reply	other threads:[~2022-05-09  3:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1652066029.git.yi1.li@intel.com>
2022-05-09  3:19 ` [PATCH 1/3] CryptoPkg: Update process_files.pl to automatically add PCD config option yi1 li
2022-05-09  3:23   ` Yao, Jiewen [this message]
2022-05-09  9:34   ` Gerd Hoffmann
2022-05-09  9:58     ` [edk2-devel] " yi1 li
2022-05-09  3:19 ` [PATCH 2/3] CryptoPkg/openssl: disable codestyle checks for generated files yi1 li
2022-05-09  3:23   ` Yao, Jiewen
2022-05-09  3:19 ` [PATCH 3/3] CryptoPkg/openssl: update " yi1 li
2022-05-09  3:25   ` Yao, Jiewen
2022-05-09  3:34     ` yi1 li
2022-05-09  9:38     ` Gerd Hoffmann
2022-05-09 10:05       ` [edk2-devel] " yi1 li
2022-05-09 10:26         ` Gerd Hoffmann

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=MW4PR11MB5872E9E9288BB27EDBD084A08CC69@MW4PR11MB5872.namprd11.prod.outlook.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