Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.1 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM crypto.cmd
  5. REM Applies MAC and signature to a list of crypto components
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. if defined _CPCMAGIC goto CPCBegin
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. sub Usage { print<<USAGE; exit(1) }
  20. crypto [-l <language>]
  21. Applies MAC and signature to a list of crypto components
  22. USAGE
  23. parseargs('?' => \&Usage);
  24. # *** NEXT FEW LINES ARE TEMPLATE ***
  25. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  26. __END__
  27. :CPCBegin
  28. set _CPCMAGIC=
  29. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  30. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  31. REM
  32. REM Based on the postbuild environment, determine the appropriate
  33. REM signature processing to be done.
  34. REM
  35. if "1" == "%enigma%" if "1" == "%vaultsign%" (
  36. call errmsg "Both ENIGMA and VAULTSIGN options are set. Please enable only one."
  37. goto :EOF
  38. )
  39. if "1" == "%enigma%" (
  40. REM Check for binplaced marker file to verify that
  41. REM advapi32.dll was built with the Test Key enabled.
  42. if not exist %_NTPOSTBLD%\dump\advapi_enigma.txt (
  43. call errmsg "ENIGMA is set, but advapi32.dll was built without the Test Key enabled."
  44. goto :EOF
  45. )
  46. REM Will check for valid test key signature resources
  47. set ShowSigCmd=showsig
  48. REM The binary will be signed by this script
  49. set DoEnigmaSign=1
  50. ) else if "1" == "%vaultsign%" (
  51. REM Check for binplaced marker file to verify that
  52. REM advapi32.dll was built to require Vault Signatures.
  53. if not exist %_NTPOSTBLD%\dump\advapi_vaultsign.txt (
  54. call errmsg "VAULTSIGN is set, but advapi32.dll was not built with that option."
  55. goto :EOF
  56. )
  57. REM Will check for valid MS vault key signature resource
  58. set ShowSigCmd=showsig -t
  59. ) else set ShowSigCmd=
  60. REM MS Software CSPs
  61. call :SignFile dssenh.dll MAC
  62. call :SignFile rsaenh.dll MAC
  63. REM Smart Card CSPs
  64. call :SignFile gpkcsp.dll
  65. call :SignFile slbcsp.dll
  66. call :SignFile sccbase.dll
  67. goto :EOF
  68. :SignFile
  69. set image=%_NTPOSTBLD%\%1
  70. REM
  71. REM Check if signing is turned on
  72. REM
  73. if "1" == "%vaultsign%" (
  74. call logmsg "Performing signature check on vault signed CSP"
  75. goto :CheckSignature
  76. )
  77. REM imagecfg can't be called with ExecuteCmd since it does not set error values
  78. call logmsg "Executing imagecfg -n %Image%"
  79. imagecfg -n %Image%
  80. REM
  81. REM check if we have to apply a MAC
  82. REM
  83. if "%2" == "MAC" (
  84. call logmsg "Executing maccsp s %Image%"
  85. maccsp s %Image%
  86. )
  87. if not "1" == "%enigma%" (
  88. call logmsg "Not test signing %Image% (CSP test signing is turned off)"
  89. goto :CheckSignature
  90. )
  91. call ExecuteCmd "signcsp %Image%"
  92. if errorlevel 1 (
  93. call errmsg "signcsp %Image% failed (Check access to CryptoServer)"
  94. goto :EOF
  95. )
  96. :CheckSignature
  97. if "" == "%ShowSigCmd%" (
  98. call logmsg "Not checking signature of %Image% (no signature checking options enabled)"
  99. goto :EOF
  100. )
  101. call ExecuteCmd "%ShowSigCmd% %Image%"
  102. :end