fipsdist.pl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # FIPS distribution filter.
  2. # Takes tarball listing and removes unnecessary files and directories.
  3. #
  4. my $objs = "";
  5. foreach (split / /, "FIPS_EX_OBJ AES_ENC BN_ASM DES_ENC SHA1_ASM_OBJ MODES_ASM_OBJ")
  6. {
  7. $objs .= " $ENV{$_}";
  8. }
  9. my $noec2m = 0;
  10. my @objlist = split / /, $objs;
  11. foreach (@objlist) { $tarobjs{"$1.c"} = 1 if /([^\/]+).o$/};
  12. $tarobjs{"ncbc_enc.c"} = 1;
  13. $tarobjs{"mem_clr.c"} = 1;
  14. $tarobjs{"ppccap.c"} = 1;
  15. $tarobjs{"sparcv9cap.c"} = 1;
  16. $tarobjs{"armcap.c"} = 1;
  17. foreach (split / /, $ENV{LINKDIRS} ) { $cdirs{$_} = 1 };
  18. $cdirs{perlasm} = 1;
  19. $noec2m = 1 if (exists $ENV{NOEC2M});
  20. if ($noec2m)
  21. {
  22. delete $tarobjs{"bn_gf2m.c"};
  23. delete $tarobjs{"ec2_mult.c"};
  24. delete $tarobjs{"ec2_smpl.c"};
  25. }
  26. my %keep =
  27. (
  28. "Makefile.fips" => 1,
  29. "Makefile.shared" => 1,
  30. "README.FIPS" => 1,
  31. "README.ECC" => 1,
  32. "e_os.h" => 1,
  33. "e_os2.h" => 1,
  34. "Configure" => 1,
  35. "config" => 1,
  36. );
  37. while (<STDIN>)
  38. {
  39. chomp;
  40. # Keep top level files in list
  41. if (!/\// && -f $_)
  42. {
  43. next unless exists $keep{$_};
  44. }
  45. else
  46. {
  47. next unless (/^(fips\/|crypto|util|test|include|ms|c6x|iOS)/);
  48. }
  49. if (/^crypto\/([^\/]+)/)
  50. {
  51. # Skip unused directories under crypto/
  52. next if -d "crypto/$1" && !exists $cdirs{$1};
  53. # Skip GF2m assembly language perl scripts
  54. next if $noec2m && /gf2m\.pl/;
  55. next if /vpaes-\w*\.pl/;
  56. # Keep assembly language dir, Makefile or certain extensions
  57. if (!/\/asm\// && !/\/Makefile$/ && !/\.(in|pl|h|S)$/)
  58. {
  59. # If C source file must be on list.
  60. next if !/(\w+\.c)$/ || !exists $tarobjs{$1};
  61. }
  62. }
  63. if (/^test\//)
  64. {
  65. next unless /Makefile/ || /dummytest.c/ || /fips_algvs.c/ ;
  66. }
  67. print "$_\n";
  68. }
  69. exit 1;