"Fossies" - the Fresh Open Source Software Archive

Member "Tests/bench.bat" (10 Oct 2018, 12131 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) MS DOS Batch source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 @echo off
    2 
    3 setlocal
    4 
    5 call :freedrive mydriveletter && goto :cont
    6 echo ERROR: No free drive letter found.
    7 goto :exit
    8 :cont
    9 
   10 echo Using drive letter %mydriveletter%: for our tests
   11 echo.
   12 
   13 IF NOT EXIST test.sha512.hc GOTO :whirlpool
   14 
   15 rem Get start time:
   16 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
   17    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
   18 )
   19 
   20 rem Mount SHA-512 container (Normal)
   21 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha512.hc /hash sha512 /l %mydriveletter% /password test /q /silent /m ro
   22 
   23 rem Get end time:
   24 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
   25    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
   26 )
   27 
   28 rem Get elapsed time:
   29 set /A elapsed=end-start
   30 
   31 rem Show elapsed time:
   32 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
   33 if %hh% lss 10 set hh=0%hh%
   34 if %mm% lss 10 set mm=0%mm%
   35 if %ss% lss 10 set ss=0%ss%
   36 if %cc% lss 10 set cc=0%cc%
   37 echo SHA-512 (Normal) = %hh%:%mm%:%ss%,%cc%
   38 
   39 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
   40 
   41 rem Get start time:
   42 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
   43    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
   44 )
   45 
   46 rem Mount SHA-512 container (Hidden)
   47 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha512.hc /hash sha512 /l %mydriveletter% /password testhidden /q /silent /m ro
   48 
   49 rem Get end time:
   50 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
   51    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
   52 )
   53 
   54 rem Get elapsed time:
   55 set /A elapsed=end-start
   56 
   57 rem Show elapsed time:
   58 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
   59 if %hh% lss 10 set hh=0%hh%
   60 if %mm% lss 10 set mm=0%mm%
   61 if %ss% lss 10 set ss=0%ss%
   62 if %cc% lss 10 set cc=0%cc%
   63 echo SHA-512 (Hidden) = %hh%:%mm%:%ss%,%cc%
   64 echo.
   65 
   66 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
   67 
   68 :whirlpool
   69 
   70 IF NOT EXIST test.whirlpool.hc GOTO :sha256
   71 
   72 rem Get start time:
   73 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
   74    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
   75 )
   76 
   77 rem Mount Whirlpool container (Normal).
   78 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.whirlpool.hc /hash whirlpool /l %mydriveletter% /password test /q /silent /m ro
   79 
   80 rem Get end time:
   81 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
   82    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
   83 )
   84 
   85 rem Get elapsed time:
   86 set /A elapsed=end-start
   87 
   88 rem Show elapsed time:
   89 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
   90 if %hh% lss 10 set hh=0%hh%
   91 if %mm% lss 10 set mm=0%mm%
   92 if %ss% lss 10 set ss=0%ss%
   93 if %cc% lss 10 set cc=0%cc%
   94 echo Whirlpool (Normal) = %hh%:%mm%:%ss%,%cc%
   95 
   96 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
   97 
   98 rem Get start time:
   99 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  100    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  101 )
  102 
  103 rem Mount Whirlpool container (Hidden).
  104 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.whirlpool.hc /hash whirlpool /l %mydriveletter% /password testhidden /q /silent /m ro
  105 
  106 rem Get end time:
  107 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  108    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  109 )
  110 
  111 rem Get elapsed time:
  112 set /A elapsed=end-start
  113 
  114 rem Show elapsed time:
  115 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  116 if %hh% lss 10 set hh=0%hh%
  117 if %mm% lss 10 set mm=0%mm%
  118 if %ss% lss 10 set ss=0%ss%
  119 if %cc% lss 10 set cc=0%cc%
  120 echo Whirlpool (Hidden) = %hh%:%mm%:%ss%,%cc%
  121 echo.
  122 
  123 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  124 
  125 :sha256
  126 
  127 IF NOT EXIST test.sha256.hc GOTO :ripemd160
  128 
  129 rem Get start time:
  130 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  131    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  132 )
  133 
  134 rem Mount SHA-256 container (Normal)
  135 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha256.hc /hash sha256 /l %mydriveletter% /password test /q /silent /m ro
  136 
  137 rem Get end time:
  138 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  139    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  140 )
  141 
  142 rem Get elapsed time:
  143 set /A elapsed=end-start
  144 
  145 rem Show elapsed time:
  146 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  147 if %hh% lss 10 set hh=0%hh%
  148 if %mm% lss 10 set mm=0%mm%
  149 if %ss% lss 10 set ss=0%ss%
  150 if %cc% lss 10 set cc=0%cc%
  151 echo SHA-256 (Normal) = %hh%:%mm%:%ss%,%cc%
  152 
  153 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  154 
  155 rem Get start time:
  156 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  157    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  158 )
  159 
  160 rem Mount SHA-256 container (Hidden)
  161 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha256.hc /hash sha256 /l %mydriveletter% /password testhidden /q /silent /m ro
  162 
  163 rem Get end time:
  164 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  165    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  166 )
  167 
  168 rem Get elapsed time:
  169 set /A elapsed=end-start
  170 
  171 rem Show elapsed time:
  172 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  173 if %hh% lss 10 set hh=0%hh%
  174 if %mm% lss 10 set mm=0%mm%
  175 if %ss% lss 10 set ss=0%ss%
  176 if %cc% lss 10 set cc=0%cc%
  177 echo SHA-256 (Hidden) = %hh%:%mm%:%ss%,%cc%
  178 echo.
  179 
  180 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  181 
  182 :ripemd160
  183 
  184 IF NOT EXIST test.ripemd160.hc GOTO :streebog
  185 
  186 rem Get start time:
  187 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  188    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  189 )
  190 
  191 rem Mount RIPEMD-160 container (Normal)
  192 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.ripemd160.hc /hash ripemd160 /l %mydriveletter% /password test /q /silent /m ro
  193 
  194 rem Get end time:
  195 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  196    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  197 )
  198 
  199 rem Get elapsed time:
  200 set /A elapsed=end-start
  201 
  202 rem Show elapsed time:
  203 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  204 if %hh% lss 10 set hh=0%hh%
  205 if %mm% lss 10 set mm=0%mm%
  206 if %ss% lss 10 set ss=0%ss%
  207 if %cc% lss 10 set cc=0%cc%
  208 echo RIPEMD-160 (Normal) = %hh%:%mm%:%ss%,%cc%
  209 
  210 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  211 
  212 rem Get start time:
  213 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  214    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  215 )
  216 
  217 rem Mount RIPEMD-160 container (Hidden)
  218 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.ripemd160.hc /hash ripemd160 /l %mydriveletter% /password testhidden /q /silent /m ro
  219 
  220 rem Get end time:
  221 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  222    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  223 )
  224 
  225 rem Get elapsed time:
  226 set /A elapsed=end-start
  227 
  228 rem Show elapsed time:
  229 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  230 if %hh% lss 10 set hh=0%hh%
  231 if %mm% lss 10 set mm=0%mm%
  232 if %ss% lss 10 set ss=0%ss%
  233 if %cc% lss 10 set cc=0%cc%
  234 echo RIPEMD-160 (Hidden) = %hh%:%mm%:%ss%,%cc%
  235 echo.
  236 
  237 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  238 
  239 :streebog
  240 
  241 IF NOT EXIST test.streebog.hc GOTO :autodetect
  242 
  243 rem Get start time:
  244 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  245    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  246 )
  247 
  248 rem Mount Streebog container (Normal)
  249 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.streebog.hc /hash streebog /l %mydriveletter% /password test /q /silent /m ro
  250 
  251 rem Get end time:
  252 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  253    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  254 )
  255 
  256 rem Get elapsed time:
  257 set /A elapsed=end-start
  258 
  259 rem Show elapsed time:
  260 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  261 if %hh% lss 10 set hh=0%hh%
  262 if %mm% lss 10 set mm=0%mm%
  263 if %ss% lss 10 set ss=0%ss%
  264 if %cc% lss 10 set cc=0%cc%
  265 echo Streebog (Normal) = %hh%:%mm%:%ss%,%cc%
  266 
  267 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  268 
  269 rem Get start time:
  270 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  271    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  272 )
  273 
  274 rem Mount Streebog container (Hidden)
  275 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.streebog.hc /hash streebog /l %mydriveletter% /password testhidden /q /silent /m ro
  276 
  277 rem Get end time:
  278 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  279    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  280 )
  281 
  282 rem Get elapsed time:
  283 set /A elapsed=end-start
  284 
  285 rem Show elapsed time:
  286 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  287 if %hh% lss 10 set hh=0%hh%
  288 if %mm% lss 10 set mm=0%mm%
  289 if %ss% lss 10 set ss=0%ss%
  290 if %cc% lss 10 set cc=0%cc%
  291 echo Streebog (Hidden) = %hh%:%mm%:%ss%,%cc%
  292 echo.
  293 
  294 "c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
  295 
  296 :autodetect
  297 
  298 call :availablevolume testvolume && goto :contautodetect
  299 goto :exit
  300 :contautodetect
  301 
  302 rem Get start time:
  303 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  304    set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  305 )
  306 
  307 rem Try to mount with a wrong password and PRF autodetection
  308 "c:\Program Files\VeraCrypt\veracrypt.exe" /volume %testvolume% /l %mydriveletter% /password wrongpassword /q /silent /m ro
  309 
  310 rem Get end time:
  311 for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
  312    set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
  313 )
  314 
  315 rem Get elapsed time:
  316 set /A elapsed=end-start
  317 
  318 rem Show elapsed time:
  319 set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
  320 if %hh% lss 10 set hh=0%hh%
  321 if %mm% lss 10 set mm=0%mm%
  322 if %ss% lss 10 set ss=0%ss%
  323 if %cc% lss 10 set cc=0%cc%
  324 echo Wrong Password (PRF Auto-detection)= %hh%:%mm%:%ss%,%cc%
  325 echo.
  326 
  327 
  328 goto :exit
  329 
  330 rem Finds a free drive letter.
  331 rem
  332 rem Parameters:
  333 rem     %1 = Output variable name.
  334 rem
  335 rem Example:
  336 rem     call :freedrive mydriveletter && goto :cont
  337 rem     echo ERROR: No free drive letter found.
  338 rem     goto :EOF
  339 rem     :cont
  340 rem     echo Found drive letter: %mydriveletter%
  341 :freedrive
  342 setlocal EnableDelayedExpansion
  343 set exitcode=0
  344 set "output_var=%~1"
  345 for %%i in (C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (
  346     set "drive=%%i:"
  347     rem If 'subst' fails, the drive letter is already in use.
  348     rem This way we can even detect optical drives that have a drive
  349     rem letter but no media in them, a case that goes undetected when
  350     rem using 'if exist'.
  351     subst !drive! %SystemDrive%\ >nul
  352     if !errorlevel! == 0 (
  353         subst !drive! /d >nul
  354         set "drive=%%i"
  355         goto :freedrive0
  356     )
  357 )
  358 set exitcode=1
  359 set drive=
  360 :freedrive0
  361 endlocal & set "%output_var%=%drive%" & exit /b %exitcode%
  362 
  363 :availablevolume
  364 setlocal EnableDelayedExpansion
  365 set exitcode=0
  366 set "output_var=%~1"
  367 for %%i in (test.sha512.hc,test.sha256.hc,test.whirlpool.hc,test.ripemd160.hc) do (
  368     if exist %%i (
  369         set "volume=%%i"
  370         goto :availablevolume0
  371     )
  372 )
  373 set exitcode=1
  374 set volume=
  375 :availablevolume0
  376 endlocal & set "%output_var%=%volume%" & exit /b %exitcode%
  377 
  378 :exit
  379 
  380 pause