test.cmd 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. @echo off
  2. rem ===========================================================================
  3. rem \brief Testing command-line interface
  4. rem \project bee2evp/cmd
  5. rem \created 2022.06.24
  6. rem \version 2024.06.14
  7. rem \pre The working directory contains zed.csr.
  8. rem ===========================================================================
  9. rem ===========================================================================
  10. rem bee2cmd/ver
  11. rem ===========================================================================
  12. echo ****** Testing bee2cmd/ver...
  13. bee2cmd ver
  14. if %ERRORLEVEL% neq 0 goto Error
  15. bee2cmd ver ver
  16. if %ERRORLEVEL% equ 0 goto Error
  17. echo ****** OK
  18. rem ===========================================================================
  19. rem bee2cmd/bsum
  20. rem ===========================================================================
  21. echo ****** Testing bee2cmd/bsum...
  22. del /q check32 check256 -c 2> nul
  23. bee2cmd bsum -bash31 bee2cmd.exe
  24. if %ERRORLEVEL% equ 0 goto Error
  25. bee2cmd bsum -bash32 bee2cmd.exe test.cmd > check32
  26. if %ERRORLEVEL% neq 0 goto Error
  27. bee2cmd bsum -bash32 -c check32
  28. if %ERRORLEVEL% neq 0 goto Error
  29. bee2cmd bsum bee2cmd.exe test.cmd > check256
  30. if %ERRORLEVEL% neq 0 goto Error
  31. bee2cmd bsum -belt-hash -c check256
  32. if %ERRORLEVEL% neq 0 goto Error
  33. bee2cmd bsum -c check32
  34. if %ERRORLEVEL% equ 0 goto Error
  35. bee2cmd bsum -bash-prg-hash2561 bee2cmd.exe test.cmd > -c
  36. if %ERRORLEVEL% neq 0 goto Error
  37. bee2cmd bsum -bash-prg-hash2561 -c
  38. if %ERRORLEVEL% equ 0 goto Error
  39. bee2cmd bsum -bash-prg-hash2561 -- -c
  40. if %ERRORLEVEL% neq 0 goto Error
  41. bee2cmd bsum -bash-prg-hash2561 -c -- -c
  42. if %ERRORLEVEL% neq 0 goto Error
  43. bee2cmd bsum -bash-prg-hash2562 -c -- -c
  44. if %ERRORLEVEL% equ 0 goto Error
  45. bee2cmd bsum -c -bash-prg-hash2561 -- -c
  46. if %ERRORLEVEL% neq 0 goto Error
  47. bee2cmd bsum -c -bash-prg-hash2561 -c -- -c
  48. if %ERRORLEVEL% equ 0 goto Error
  49. bee2cmd bsum -c -belt-hash -bash-prg-hash2561 -- -c
  50. if %ERRORLEVEL% equ 0 goto Error
  51. bee2cmd bsum -b -c -- -c
  52. if %ERRORLEVEL% equ 0 goto Error
  53. echo ****** OK
  54. rem ===========================================================================
  55. rem bee2cmd/pwd
  56. rem ===========================================================================
  57. echo ****** Testing bee2cmd/pwd...
  58. del /q s1 s2 s3 s4 s5 2> nul
  59. bee2cmd pwd gen pass:zed
  60. if %ERRORLEVEL% equ 0 goto Error
  61. bee2cmd pwd val pass:zed
  62. if %ERRORLEVEL% neq 0 goto Error
  63. bee2cmd pwd val pass:"zed"
  64. if %ERRORLEVEL% neq 0 goto Error
  65. for /f %%i in ('bee2cmd pwd print pass:zed') do (
  66. if "%%i" neq "zed" goto Error
  67. )
  68. bee2cmd pwd gen env:BEE2_CMD_TEST
  69. if %ERRORLEVEL% equ 0 goto Error
  70. set BEE2_CMD_TEST=
  71. bee2cmd pwd val env:BEE2_CMD_TEST
  72. if %ERRORLEVEL% equ 0 goto Error
  73. set BEE2_CMD_TEST=zed
  74. bee2cmd pwd val env:BEE2_CMD_TEST
  75. if %ERRORLEVEL% neq 0 goto Error
  76. for /f %%i in ('bee2cmd pwd print env:BEE2_CMD_TEST') do (
  77. if "%%i" neq "zed" goto Error
  78. )
  79. bee2cmd pwd gen share:"-t2 -t3 -pass pass:zed s1 s2"
  80. if %ERRORLEVEL% equ 0 goto Error
  81. bee2cmd pwd gen share:"-t3 -pass pass:zed s1 s2"
  82. if %ERRORLEVEL% equ 0 goto Error
  83. bee2cmd pwd gen share:"-l -pass pass:zed s1 s2"
  84. if %ERRORLEVEL% equ 0 goto Error
  85. bee2cmd pwd gen share:"-l12 -pass pass:zed s1 s2"
  86. if %ERRORLEVEL% equ 0 goto Error
  87. bee2cmd pwd gen share:"-l128 -l -pass pass:zed s1 s2"
  88. if %ERRORLEVEL% equ 0 goto Error
  89. bee2cmd pwd gen share:"-l128 -l256 -pass pass:zed s1 s2"
  90. if %ERRORLEVEL% equ 0 goto Error
  91. bee2cmd pwd gen share:"-l128 -t3 -crc -pass pass:zed s1 s2 s3 s4 s5"
  92. if %ERRORLEVEL% equ 0 goto Error
  93. bee2cmd pwd gen share:"-l256 -t3 -crc -pass pass:zed s1 s2 s3 s4 s5"
  94. if %ERRORLEVEL% neq 0 goto Error
  95. bee2cmd pwd val share:"-t3 -pass pass:zed s1 s2"
  96. if %ERRORLEVEL% equ 0 goto Error
  97. bee2cmd pwd val share:"-l -pass pass:zed s1 s2"
  98. if %ERRORLEVEL% equ 0 goto Error
  99. bee2cmd pwd val share:"-l12 -pass pass:zed s1 s2"
  100. if %ERRORLEVEL% equ 0 goto Error
  101. bee2cmd pwd val share:"-l128 -l -pass pass:zed s1 s2"
  102. if %ERRORLEVEL% equ 0 goto Error
  103. bee2cmd pwd val share:"-l128 -l256 -pass pass:zed s1 s2"
  104. if %ERRORLEVEL% equ 0 goto Error
  105. bee2cmd pwd val share:"-l128 -pass pass:zed s1 s2"
  106. if %ERRORLEVEL% equ 0 goto Error
  107. bee2cmd pwd val share:"-l256 -pass pass:zed s1 s2 s3"
  108. if %ERRORLEVEL% neq 0 goto Error
  109. bee2cmd pwd val share:"-l256 -crc -pass pass:zed s1 s2 s3"
  110. if %ERRORLEVEL% neq 0 goto Error
  111. bee2cmd pwd val share:"-pass pass:zed s2 s3 s4 s5"
  112. if %ERRORLEVEL% neq 0 goto Error
  113. bee2cmd pwd val share:"-pass pass:zed -crc s2 s3 s4 s5"
  114. if %ERRORLEVEL% neq 0 goto Error
  115. bee2cmd pwd print share:"-l128 -pass pass:zed s5 s1 s3"
  116. if %ERRORLEVEL% equ 0 goto Error
  117. bee2cmd pwd print share:"-l256 -pass pass:zed s2 s1 s5 s3"
  118. if %ERRORLEVEL% neq 0 goto Error
  119. bee2cmd pwd print share:"-pass pass:zed s1 s2 s3 s4 s5"
  120. if %ERRORLEVEL% neq 0 goto Error
  121. del /q ss1 ss2 ss3 2> nul
  122. bee2cmd pwd gen share:"-l192 -pass share:\"-pass pass:zed s1 s2 s3\" ss1 ss2 ss3"
  123. if %ERRORLEVEL% neq 0 goto Error
  124. bee2cmd pwd val share:"-pass share:\"-pass pass:zed s1 s2 s2\" ss1 ss2"
  125. if %ERRORLEVEL% equ 0 goto Error
  126. bee2cmd pwd val share:"-pass share:\"-pass pass:zed s1 s2 s3\" ss1 ss1"
  127. if %ERRORLEVEL% equ 0 goto Error
  128. bee2cmd pwd val share:"-pass share:\"-pass pass:zed s1 s2 s3\" ss2 ss3"
  129. if %ERRORLEVEL% neq 0 goto Error
  130. bee2cmd pwd val share:"-pass -crc share:\"-pass pass:zed s1 s2 s3\" ss2 ss3"
  131. if %ERRORLEVEL% equ 0 goto Error
  132. echo ****** OK
  133. rem ===========================================================================
  134. rem bee2cmd/kg
  135. rem ===========================================================================
  136. echo ****** Testing bee2cmd/kg...
  137. del /q privkey0 privkey1 privkey2 privkey3 pubkey0 pubkey2 pubkey3 2> nul
  138. bee2cmd kg gen -l256 -pass share:"-pass pass:zed s2 s3 s4"
  139. if %ERRORLEVEL% equ 0 goto Error
  140. bee2cmd kg gen -l256 -pass share:"-pass pass:zed s2 s3 s4" -pass pass:zed
  141. if %ERRORLEVEL% equ 0 goto Error
  142. bee2cmd kg gen -l256 -l192 -pass share:"-pass pass:zed s2 s3 s4" privkey0
  143. if %ERRORLEVEL% equ 0 goto Error
  144. bee2cmd kg gen -l256 -pass share:"-pass pass:zed s2 s3 s4" privkey0
  145. if %ERRORLEVEL% neq 0 goto Error
  146. bee2cmd kg val -pass share:"-pass pass:zed s1 s2 s4" privkey0
  147. if %ERRORLEVEL% neq 0 goto Error
  148. bee2cmd kg chp -passin share:"-pass pass:zed s3 s1 s4" -passout pass:"root" privkey0
  149. if %ERRORLEVEL% neq 0 goto Error
  150. bee2cmd kg gen -pass pass:trent -l192 privkey1
  151. if %ERRORLEVEL% neq 0 goto Error
  152. bee2cmd kg print -pass pass:trent privkey1 > pubkey1
  153. if %ERRORLEVEL% neq 0 goto Error
  154. for /f "tokens=1" %%A in (pubkey1) do @echo|set /p="%%A" > pubkey1
  155. for %%A in (pubkey1) do set pubkey1_len=%%~zA
  156. if %pubkey1_len% neq 192 goto Error
  157. bee2cmd kg gen -pass pass:alice privkey2
  158. if %ERRORLEVEL% neq 0 goto Error
  159. bee2cmd kg extr -pass pass:alice privkey2 pubkey2
  160. if %ERRORLEVEL% neq 0 goto Error
  161. for %%A in (pubkey2) do set pubkey2_len=%%~zA
  162. if %pubkey2_len% neq 64 goto Error
  163. bee2cmd kg gen -l96 -pass pass:bob privkey3
  164. if %ERRORLEVEL% neq 0 goto Error
  165. bee2cmd kg extr -pass pass:bob privkey3 pubkey3
  166. if %ERRORLEVEL% neq 0 goto Error
  167. echo ****** OK
  168. rem ===========================================================================
  169. rem bee2cmd/cvc
  170. rem ===========================================================================
  171. echo ****** Testing bee2cmd/cvc...
  172. del /q cert0 req1 cert1 pubkey1 req2 req21 cert2 req3 cert3 2> nul
  173. bee2cmd cvc root -authority BYCA0000 -from 220707 -until 990707 ^
  174. -pass pass:root -eid EEEEEEEEEE -esign 7777 privkey0 cert0
  175. if %ERRORLEVEL% neq 0 goto Error
  176. bee2cmd cvc print cert0
  177. if %ERRORLEVEL% neq 0 goto Error
  178. bee2cmd cvc req -authority BYCA0000 -holder BYCA1000 -from 220711 ^
  179. -until 221231 -pass pass:trent -eid FFFFFFFFFF -esign 7777 privkey1 req1
  180. if %ERRORLEVEL% neq 0 goto Error
  181. bee2cmd cvc print req1
  182. if %ERRORLEVEL% neq 0 goto Error
  183. bee2cmd cvc iss -authority BYCA0000 -pass pass:root privkey0 cert0 req1 cert1
  184. if %ERRORLEVEL% equ 0 goto Error
  185. bee2cmd cvc iss -from 220712 -until 221130 -holder BYCA1023 ^
  186. -eid DDDDDDDDDD -esign BBBB -pass pass:root privkey0 cert0 req1 cert1
  187. if %ERRORLEVEL% neq 0 goto Error
  188. bee2cmd cvc print cert1
  189. if %ERRORLEVEL% neq 0 goto Error
  190. bee2cmd cvc extr cert1 pubkey1
  191. if %ERRORLEVEL% neq 0 goto Error
  192. for %%A in (pubkey1) do set pubkey1_len=%%~zA
  193. if %pubkey1_len% neq 96 goto Error
  194. bee2cmd cvc req -authority BYCA1023 -holder "590082394654" -from 220712 ^
  195. -until 391231 -pass pass:alice -eid 8888888888 -esign 1111 privkey2 req2
  196. if %ERRORLEVEL% neq 0 goto Error
  197. bee2cmd cvc req -authority BYCA1023 -holder "590082394654" -from 000000 ^
  198. -until 000000 -pass pass:alice privkey2 req21
  199. if %ERRORLEVEL% neq 0 goto Error
  200. bee2cmd cvc iss -pass pass:trent privkey1 cert1 req2 cert2
  201. if %ERRORLEVEL% neq 0 goto Error
  202. bee2cmd cvc match -pass pass:alice privkey2 cert2
  203. if %ERRORLEVEL% neq 0 goto Error
  204. bee2cmd cvc match -pass pass:alisa privkey2 cert2
  205. if %ERRORLEVEL% equ 0 goto Error
  206. bee2cmd cvc print cert2
  207. if %ERRORLEVEL% neq 0 goto Error
  208. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd cvc print -from cert1`) do (
  209. set from=%%F
  210. )
  211. if "%from%" neq "220712" goto Error
  212. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd cvc print -until cert1`) do (
  213. set until=%%F
  214. )
  215. if "%until%" neq "221130" goto Error
  216. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd cvc print -eid cert1`) do (
  217. set eid=%%F
  218. )
  219. if "%eid%" neq "DDDDDDDDDD" goto Error
  220. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd cvc print -esign cert1`) do (
  221. set esign=%%F
  222. )
  223. if "%esign%" neq "3333" goto Error
  224. bee2cmd cvc val cert0 cert0
  225. if %ERRORLEVEL% neq 0 goto Error
  226. bee2cmd cvc val -date 220707 cert0 cert1
  227. if %ERRORLEVEL% equ 0 goto Error
  228. bee2cmd cvc val -date 220712 cert0 cert1
  229. if %ERRORLEVEL% neq 0 goto Error
  230. bee2cmd cvc val -date 220707 cert0 cert1 cert2
  231. if %ERRORLEVEL% equ 0 goto Error
  232. bee2cmd cvc val -date 220712 cert0 cert1 cert2
  233. if %ERRORLEVEL% neq 0 goto Error
  234. bee2cmd cvc val -date 220712 cert0 cert1 cert2
  235. if %ERRORLEVEL% neq 0 goto Error
  236. bee2cmd cvc val -date 221201 cert0 cert1 cert2
  237. if %ERRORLEVEL% neq 0 goto Error
  238. bee2cmd cvc val -date 400101 cert0 cert1 cert2
  239. if %ERRORLEVEL% equ 0 goto Error
  240. bee2cmd cvc val -date cert0 cert1 cert2
  241. if %ERRORLEVEL% equ 0 goto Error
  242. bee2cmd cvc val cert0 cert1 cert2
  243. if %ERRORLEVEL% neq 0 goto Error
  244. bee2cmd cvc shorten -pass pass:trent -until 391230 privkey1 cert1 cert2
  245. if %ERRORLEVEL% neq 0 goto Error
  246. bee2cmd cvc val cert0 cert1 cert2
  247. if %ERRORLEVEL% neq 0 goto Error
  248. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd cvc print -until cert2`) do (
  249. set until=%%F
  250. )
  251. if "%until%" neq "391230" goto Error
  252. bee2cmd cvc req -authority BYCA1023 -from 221030 -until 391231 ^
  253. -holder 590082394655 -pass pass:bob privkey3 req3
  254. if %ERRORLEVEL% neq 0 goto Error
  255. bee2cmd cvc print req3
  256. if %ERRORLEVEL% neq 0 goto Error
  257. bee2cmd cvc iss -pass pass:trent privkey1 cert1 req3 cert3
  258. if %ERRORLEVEL% neq 0 goto Error
  259. echo ****** OK
  260. rem ===========================================================================
  261. rem bee2cmd/sig
  262. rem ===========================================================================
  263. echo ****** Testing bee2cmd/sig...
  264. del /q ff ss cert01 cert11 cert21 body sig 2> nul
  265. echo test> ff
  266. echo sig> ss
  267. bee2cmd sig val -pubkey pubkey2 ff ss
  268. if %ERRORLEVEL% equ 0 goto Error
  269. bee2cmd sig val -anchor cert0 ff ss
  270. if %ERRORLEVEL% equ 0 goto Error
  271. bee2cmd sig val -anchor cert2 ff ss
  272. if %ERRORLEVEL% equ 0 goto Error
  273. bee2cmd sig val -pubkey pubkey2 ff ss
  274. if %ERRORLEVEL% equ 0 goto Error
  275. bee2cmd sig val -anchor cert0 ff ff
  276. if %ERRORLEVEL% equ 0 goto Error
  277. bee2cmd sig val -anchor cert2 ff ff
  278. if %ERRORLEVEL% equ 0 goto Error
  279. del /q ss 1> nul
  280. bee2cmd sig sign -certs "cert1 cert2" -date 400101 -pass pass:alice ^
  281. privkey2 ff ss
  282. if %ERRORLEVEL% equ 0 goto Error
  283. bee2cmd sig sign -certs "cert1 cert2" -date 230526 -pass pass:alice ^
  284. privkey2 ff ss
  285. if %ERRORLEVEL% neq 0 goto Error
  286. bee2cmd sig val -pubkey pubkey2 ff ss
  287. if %ERRORLEVEL% neq 0 goto Error
  288. bee2cmd sig val -anchor cert2 ff ss
  289. if %ERRORLEVEL% neq 0 goto Error
  290. bee2cmd sig val -anchor cert1 ff ss
  291. if %ERRORLEVEL% neq 0 goto Error
  292. bee2cmd sig val -anchor cert0 ff ss
  293. if %ERRORLEVEL% equ 0 goto Error
  294. bee2cmd sig sign -certs "cert0 cert1 cert2" -pass pass:alice privkey2 ff ff
  295. if %ERRORLEVEL% neq 0 goto Error
  296. bee2cmd sig val -pubkey pubkey2 ff ff
  297. if %ERRORLEVEL% neq 0 goto Error
  298. bee2cmd sig val -anchor cert2 ff ff
  299. if %ERRORLEVEL% neq 0 goto Error
  300. bee2cmd sig val -anchor cert1 ff ff
  301. if %ERRORLEVEL% neq 0 goto Error
  302. bee2cmd sig val -anchor cert0 ff ff
  303. if %ERRORLEVEL% neq 0 goto Error
  304. bee2cmd sig extr -cert0 ff cert01
  305. if %ERRORLEVEL% neq 0 goto Error
  306. fc /b cert01 cert0 1> nul
  307. if %ERRORLEVEL% neq 0 goto Error
  308. bee2cmd sig extr -cert1 ff cert11
  309. if %ERRORLEVEL% neq 0 goto Error
  310. fc /b cert1 cert11 1> nul
  311. if %ERRORLEVEL% neq 0 goto Error
  312. bee2cmd sig extr -cert2 ff cert21
  313. if %ERRORLEVEL% neq 0 goto Error
  314. fc /b cert2 cert21 1> nul
  315. if %ERRORLEVEL% neq 0 goto Error
  316. bee2cmd sig extr -body ff body
  317. if %ERRORLEVEL% neq 0 goto Error
  318. for /f "tokens=* USEBACKQ" %%F in (`type body`) do (
  319. set body=%%F
  320. )
  321. if "%body%" neq "test" goto Error
  322. bee2cmd sig extr -sig ff sig
  323. if %ERRORLEVEL% neq 0 goto Error
  324. del /q ss body 2> nul
  325. bee2cmd sig sign -certs cert2 -pass pass:alice privkey2 ff ss
  326. if %ERRORLEVEL% neq 0 goto Error
  327. bee2cmd sig val -pubkey pubkey2 ff ss
  328. if %ERRORLEVEL% neq 0 goto Error
  329. bee2cmd sig val -anchor cert2 ff ss
  330. if %ERRORLEVEL% neq 0 goto Error
  331. bee2cmd sig val -anchor cert1 ff ss
  332. if %ERRORLEVEL% equ 0 goto Error
  333. bee2cmd sig extr -body ss body
  334. if %ERRORLEVEL% equ 0 goto Error
  335. bee2cmd sig sign -pass pass:alice -date 230526 privkey2 ff ff
  336. if %ERRORLEVEL% neq 0 goto Error
  337. bee2cmd sig val -pubkey pubkey2 ff ff
  338. if %ERRORLEVEL% neq 0 goto Error
  339. bee2cmd sig val -anchor cert2 ff ff
  340. if %ERRORLEVEL% equ 0 goto Error
  341. bee2cmd sig print ss
  342. if %ERRORLEVEL% neq 0 goto Error
  343. bee2cmd sig print ff
  344. if %ERRORLEVEL% neq 0 goto Error
  345. bee2cmd sig print -date ss
  346. if %ERRORLEVEL% equ 0 goto Error
  347. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd sig print -certc ss`) do (
  348. set certc=%%F
  349. )
  350. if "%certc%" neq "1" goto Error
  351. bee2cmd sig sign -pass pass:bob -certs "cert1 cert3" privkey3 ff ff
  352. if %ERRORLEVEL% neq 0 goto Error
  353. bee2cmd sig val -pubkey pubkey3 ff ff
  354. if %ERRORLEVEL% neq 0 goto Error
  355. bee2cmd sig val -anchor cert1 ff ff
  356. if %ERRORLEVEL% neq 0 goto Error
  357. bee2cmd sig val -anchor cert3 ff ff
  358. if %ERRORLEVEL% neq 0 goto Error
  359. echo ****** OK
  360. rem ===========================================================================
  361. rem bee2cmd/cvr
  362. rem ===========================================================================
  363. echo ****** Testing bee2cmd/cvr...
  364. del /q ring2 cert21 cert31 2> nul
  365. bee2cmd cvr init -pass pass:alice privkey2 cert2 ring2
  366. if %ERRORLEVEL% neq 0 goto Error
  367. bee2cmd cvr add -pass pass:alice privkey2 cert2 cert3 ring2
  368. if %ERRORLEVEL% neq 0 goto Error
  369. bee2cmd cvr add -pass pass:alice privkey2 cert2 cert3 ring2
  370. if %ERRORLEVEL% equ 0 goto Error
  371. bee2cmd cvr val cert2 ring2
  372. if %ERRORLEVEL% neq 0 goto Error
  373. bee2cmd sig val -anchor cert2 ring2 ring2
  374. if %ERRORLEVEL% neq 0 goto Error
  375. bee2cmd cvr find ring2 cert3
  376. if %ERRORLEVEL% neq 0 goto Error
  377. bee2cmd cvr find ring2 cert2
  378. if %ERRORLEVEL% equ 0 goto Error
  379. bee2cmd cvr extr -cert0 ring2 cert31
  380. if %ERRORLEVEL% neq 0 goto Error
  381. fc /b cert31 cert3 1> nul
  382. if %ERRORLEVEL% neq 0 goto Error
  383. bee2cmd sig extr -cert0 ring2 cert21
  384. if %ERRORLEVEL% neq 0 goto Error
  385. fc /b cert21 cert2 1> nul
  386. if %ERRORLEVEL% neq 0 goto Error
  387. bee2cmd cvr print ring2
  388. if %ERRORLEVEL% neq 0 goto Error
  389. bee2cmd cvr print -certc ring2
  390. if %ERRORLEVEL% neq 0 goto Error
  391. bee2cmd sig print ring2
  392. if %ERRORLEVEL% neq 0 goto Error
  393. bee2cmd cvr add -pass pass:alice privkey2 cert2 cert0 ring2
  394. if %ERRORLEVEL% neq 0 goto Error
  395. bee2cmd cvr add -pass pass:alice privkey2 cert2 cert1 ring2
  396. if %ERRORLEVEL% neq 0 goto Error
  397. for /f "tokens=* USEBACKQ" %%F in (`bee2cmd cvr print -certc ring2`) do (
  398. set certc=%%F
  399. )
  400. if "%certc%" neq "3" goto Error
  401. bee2cmd cvr del -pass pass:alice privkey2 cert2 cert1 ring2
  402. if %ERRORLEVEL% neq 0 goto Error
  403. bee2cmd cvr del -pass pass:alice privkey2 cert2 cert0 ring2
  404. if %ERRORLEVEL% neq 0 goto Error
  405. bee2cmd cvr del -pass pass:alice privkey2 cert2 cert0 ring2
  406. if %ERRORLEVEL% equ 0 goto Error
  407. echo ****** OK
  408. rem ===========================================================================
  409. rem bee2cmd/csr
  410. rem ===========================================================================
  411. echo ****** Testing bee2cmd/csr...
  412. del /q zed.sk1 zed.csr1 2> nul
  413. bee2cmd csr val zed.csr
  414. if %ERRORLEVEL% neq 0 goto Error
  415. bee2cmd kg gen -pass pass:zed1 zed.sk1
  416. if %ERRORLEVEL% neq 0 goto Error
  417. bee2cmd csr rewrap -pass pass:zed1 zed.sk1 zed.csr zed.csr1
  418. if %ERRORLEVEL% neq 0 goto Error
  419. bee2cmd csr val zed.csr1
  420. if %ERRORLEVEL% neq 0 goto Error
  421. echo ****** OK
  422. rem ===========================================================================
  423. rem bee2cmd/es
  424. rem ===========================================================================
  425. del /q dd 2> nul
  426. bee2cmd es print
  427. if %ERRORLEVEL% neq 0 goto Error
  428. bee2cmd es read sys 1 dd
  429. if %ERRORLEVEL% neq 0 goto Error
  430. for %%A in (dd) do set dd_len=%%~zA
  431. if %dd_len% neq 1024 goto Error
  432. echo ****** OK
  433. rem ===========================================================================
  434. rem exit
  435. rem ===========================================================================
  436. goto End
  437. if %ERRORLEVEL% equ 0 goto Error
  438. :Error
  439. echo ****** Failed
  440. :End