Leaked source code of windows server 2003
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.

257 lines
7.7 KiB

  1. @echo off
  2. @rem ======================================================================
  3. @rem ======================================================================
  4. @rem
  5. @rem Microsoft Windows
  6. @rem
  7. @rem Copyright (c) Microsoft Corporation, 1996 - 1997
  8. @rem
  9. @rem File: signfiles.bat
  10. @rem
  11. @rem Contents: Microsoft PRS Signing Utilities
  12. @rem
  13. @rem History: 20-Aug-1997 pberkman created
  14. @rem
  15. @rem ======================================================================
  16. @rem ======================================================================
  17. @SETLOCAL ENABLEEXTENSIONS
  18. @rem ======================================================================
  19. @rem defaults
  20. @rem ======================================================================
  21. @set __TSURL=http://timestamp.verisign.com/scripts/timstamp.dll
  22. @set __TSTRIES=4
  23. @set __IESIGNSPC=IEBetaPub.spc
  24. @set __IESIGNPVK=IEBetaPub.pvk
  25. @set __USESPYRUS=
  26. @set __USEIETESTCERT=
  27. @set __CHECK=
  28. @set __TEST=
  29. @set __KEYNAME=
  30. @set __SPCFILE=
  31. @set __PROVNAME=
  32. @set __PROVTYPE=
  33. @set __JAVAPARAMS=
  34. @set __CALLFROMSTART=
  35. @rem ======================================================================
  36. @rem check command line
  37. @rem ======================================================================
  38. :CheckCmdLine
  39. @if "%1" == "" @goto Initialize
  40. @if /I "%1" == "-?" @goto HelpMe
  41. @if /I "%1" == "/?" @goto HelpMe
  42. @if /I "%1" == "-v" @echo on
  43. @if /I "%1" == "/v" @echo on
  44. @if /I "%1" == "-T" @set __TEST=TRUE
  45. @if /I "%1" == "/T" @set __TEST=TRUE
  46. @if /I "%1" == "-C" @set __CHECK=TRUE
  47. @if /I "%1" == "/C" @set __CHECK=TRUE
  48. @if /I "%1" == "-!" @set __CALLFROMSTART=TRUE
  49. @if /I "%1" == "/!" @set __CALLFROMSTART=TRUE
  50. @if /I "%1" == "-S" @set __USESPYRUS=TRUE
  51. @if /I "%1" == "/S" @set __USESPYRUS=TRUE
  52. @shift
  53. @goto CheckCmdLine
  54. @rem ======================================================================
  55. @rem need help!
  56. @rem ======================================================================
  57. :HelpMe
  58. @echo Usage: %0 [-v, -c, -t]
  59. @echo parameters (optional)
  60. @echo -v: verbose
  61. @echo -c: run chktrust on each file
  62. @echo -t: use test sign
  63. @goto end_signfiles
  64. @rem ======================================================================
  65. @rem initialization and variable checks
  66. @rem ======================================================================
  67. :Initialize
  68. @if not exist "%__INPUTFILE%" goto ERRNoListFile
  69. @if "%__CALLFROMSTART%" == "" @echo Processing ...
  70. @if "%__CALLFROMSTART%" == "" @set __OLDPATH=%PATH%
  71. @if "%__CALLFROMSTART%" == "" @set PATH=\CryptSDK\Bin;%PATH%
  72. @if "%__CALLFROMSTART%" == "" @set __INPUTFILE=LIST.TXT
  73. @if "%__CALLFROMSTART%" == "TRUE" @set __IESIGNPVK=..\%__IESIGNPVK%
  74. @if "%__CALLFROMSTART%" == "TRUE" @set __IESIGNSPC=..\%__IESIGNSPC%
  75. @if "%COMPUTERNAME%" == "" @set COMPUTERNAME=TEST
  76. prsparse "%__INPUTFILE%" "%COMPUTERNAME%.TXT"
  77. @if "%__TEST%" == "TRUE" @goto SetupTest
  78. @goto SetupHardware
  79. @rem ======================================================================
  80. @rem the following are relevant to the Hardware set up.
  81. @rem ======================================================================
  82. :SetupHardware
  83. :SpyrusBox
  84. @if NOT "%__USESPYRUS%" == "TRUE" @goto BBNBox
  85. @set __KEYNAME=MSInternal
  86. @set __SPCFILE=..\MSInternal.SPC
  87. @set __PROVNAME=SPYRUS Lynks RSA/DES/CAST3 CSP v1.5
  88. @set __PROVTYPE=10
  89. @goto ForLoop
  90. :BBNBox
  91. @set __KEYNAME=Nehemiah
  92. @set __SPCFILE=..\NEHEMIAH.SPC
  93. @set __PROVNAME=BBN SafeKeyper Crypto Provider V0.1
  94. @set __PROVTYPE=2
  95. @goto ForLoop
  96. @rem ======================================================================
  97. @rem the following are relevant to the test set up.
  98. @rem ======================================================================
  99. :SetupTest
  100. @set __KEYNAME=__MS TEST
  101. @set __SPCFILE=%COMPUTERNAME%.spc
  102. @set __PROVNAME=Microsoft Base Cryptographic Provider v1.0
  103. @set __PROVTYPE=1
  104. @if exist %__IESIGNPVK% @goto SetupTestIE
  105. @if exist "%COMPUTERNAME%.cer" del /q "%COMPUTERNAME%.cer"
  106. @if exist %__SPCFILE% del /q %__SPCFILE%
  107. makecert -sk "%__KEYNAME%" -n "CN=__MS Test" "%COMPUTERNAME%.cer"
  108. cert2spc "%COMPUTERNAME%.cer" "%__SPCFILE%
  109. setreg -q 1 TRUE
  110. @goto ForLoop
  111. @rem ======================================================================
  112. @rem the following are relevant to the test set up for IE.
  113. @rem ======================================================================
  114. :SetupTestIE
  115. @set __USEIETESTCERT=TRUE
  116. @goto ForLoop
  117. @rem ======================================================================
  118. @rem
  119. @rem format:
  120. @rem set comment character (eol) to ';'.
  121. @rem set the field delimiter to ','.
  122. @rem goal:
  123. @rem %i/1: file to be signed
  124. @rem %j/2: file description
  125. @rem %k/3: file more info URL
  126. @rem %l/4: JAVA permisions
  127. @rem %m/5: PRS attributes
  128. @rem
  129. @rem ======================================================================
  130. :ForLoop
  131. FOR /F "eol=; delims=, tokens=1,2,3,4*" %%i IN (%COMPUTERNAME%.TXT) DO call :DoSign %%i %%j %%k %%l %%m
  132. @goto FinishedOK
  133. @rem ======================================================================
  134. @rem do the actual signing
  135. @rem ======================================================================
  136. :DoSign
  137. @if not exist "%1" goto ErrNoFileToSign
  138. @set __ATTRPARAMS=-j prsattr.dll -jp %5
  139. @if NOT "%4" == "" @set __ATTRPARAMS=%__ATTRPARAMS% -j javasign.dll -jp %4
  140. @echo ......name: %1
  141. @echo ......desc: %2
  142. @echo .......url: %3
  143. @echo ......java: %4
  144. @echo .......prs: %5
  145. @if "%__USEIETESTCERT%" == "" signcode -tr %__TSTRIES% -tw 5 -spc "%__SPCFILE%" -k "%__KEYNAME%" -p "%__PROVNAME%" -y %__PROVTYPE% -n %2 -i %3 -t "%__TSURL%" %__ATTRPARAMS% %1
  146. @if NOT "%__USEIETESTCERT%" == "" signcode -tr %__TSTRIES% -tw 5 -spc %__IESIGNSPC% -v %__IESIGNPVK% -n %2 -i %3 -t "%__TSURL%" %__ATTRPARAMS% %1
  147. @if "__CHECK" == "TRUE" chktrust %1
  148. @goto :EOF
  149. @rem ======================================================================
  150. @rem errors
  151. @rem ======================================================================
  152. :ErrNoFileToSign
  153. @echo ERROR:
  154. @echo file to sign not found ("%1"). FATAL!
  155. @goto end_signfiles
  156. :ErrNoListFile
  157. @echo ERROR:
  158. @echo no %__INPUTFILE% file found. FATAL!
  159. goto end_signfiles
  160. @rem ======================================================================
  161. @rem final processing for each file in the TXT file
  162. @rem ======================================================================
  163. :FinishedOK
  164. @if exist "%COMPUTERNAME%.TXT" del /q "%COMPUTERNAME%.TXT"
  165. @if exist "%COMPUTERNAME%.SPC" del /q "%COMPUTERNAME%.SPC"
  166. @if exist "%COMPUTERNAME%.CER" del /q "%COMPUTERNAME%.CER"
  167. @goto end_signfiles
  168. @rem ======================================================================
  169. @rem end
  170. @rem ======================================================================
  171. :end_signfiles
  172. @if "%__CALLFROMSTART%" == "" @set PATH=%__OLDPATH%
  173. @ENDLOCAL