renewcerts.sh 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. #!/bin/bash
  2. # renewcerts.sh
  3. #
  4. # renews the following certs:
  5. # client-cert.pem
  6. # client-cert.der
  7. # client-ecc-cert.pem
  8. # client-ecc-cert.der
  9. # ca-cert.pem
  10. # ca-cert.der
  11. # ca-ecc-cert.pem
  12. # ca-ecc-cert.der
  13. # ca-ecc384-cert.pem
  14. # ca-ecc384-cert.der
  15. # server-cert.pem
  16. # server-cert.der
  17. # server-ecc-rsa.pem
  18. # server-ecc.pem
  19. # 1024/client-cert.der
  20. # 1024/client-cert.pem
  21. # server-ecc-comp.pem
  22. # client-ca.pem
  23. # test/digsigku.pem
  24. # ecc-privOnlyCert.pem
  25. # updates the following crls:
  26. # crl/cliCrl.pem
  27. # crl/crl.pem
  28. # crl/crl.revoked
  29. # crl/eccCliCRL.pem
  30. # crl/eccSrvCRL.pem
  31. # if HAVE_NTRU
  32. # ntru-cert.pem
  33. # ntru-key.raw
  34. ###############################################################################
  35. ######################## FUNCTIONS SECTION ####################################
  36. ###############################################################################
  37. #the function that will be called when we are ready to renew the certs.
  38. function run_renewcerts(){
  39. cd certs/
  40. echo ""
  41. #move the custom cnf into our working directory
  42. cp renewcerts/wolfssl.cnf wolfssl.cnf
  43. # To generate these all in sha1 add the flag "-sha1" on appropriate lines
  44. # That is all lines beginning with: "openssl req"
  45. ############################################################
  46. #### update the self-signed (2048-bit) client-cert.pem #####
  47. ############################################################
  48. echo "Updating 2048-bit client-cert.pem"
  49. echo ""
  50. #pipe the following arguments to openssl req...
  51. echo -e "US\nMontana\nBozeman\nwolfSSL_2048\nProgramming-2048\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key client-key.pem -nodes -out client-cert.csr
  52. openssl x509 -req -in client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey client-key.pem -out client-cert.pem
  53. rm client-cert.csr
  54. openssl x509 -in client-cert.pem -text > tmp.pem
  55. mv tmp.pem client-cert.pem
  56. ############################################################
  57. #### update the self-signed (3072-bit) client-cert.pem #####
  58. ############################################################
  59. echo "Updating 3072-bit client-cert.pem"
  60. echo ""
  61. #pipe the following arguments to openssl req...
  62. echo -e "US\nMontana\nBozeman\nwolfSSL_3072\nProgramming-3072\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -newkey rsa:3072 -keyout client-key-3072.pem -nodes -out client-cert-3072.csr
  63. openssl x509 -req -in client-cert-3072.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey client-key-3072.pem -out client-cert-3072.pem
  64. rm client-cert-3072.csr
  65. openssl x509 -in client-cert-3072.pem -text > tmp.pem
  66. mv tmp.pem client-cert-3072.pem
  67. ############################################################
  68. #### update the self-signed (1024-bit) client-cert.pem #####
  69. ############################################################
  70. echo "Updating 1024-bit client-cert.pem"
  71. echo ""
  72. #pipe the following arguments to openssl req...
  73. echo -e "US\nMontana\nBozeman\nwolfSSL_1024\nProgramming-1024\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key \1024/client-key.pem -nodes -out \1024/client-cert.csr
  74. openssl x509 -req -in \1024/client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey \1024/client-key.pem -out \1024/client-cert.pem
  75. rm \1024/client-cert.csr
  76. openssl x509 -in \1024/client-cert.pem -text > \1024/tmp.pem
  77. mv \1024/tmp.pem \1024/client-cert.pem
  78. ############################################################
  79. ########## update the self-signed ca-cert.pem ##############
  80. ############################################################
  81. echo "Updating ca-cert.pem"
  82. echo ""
  83. #pipe the following arguments to openssl req...
  84. echo -e "US\nMontana\nBozeman\nSawtooth\nConsulting\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ca-key.pem -nodes -out ca-cert.csr
  85. openssl x509 -req -in ca-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ca-key.pem -out ca-cert.pem
  86. rm ca-cert.csr
  87. openssl x509 -in ca-cert.pem -text > tmp.pem
  88. mv tmp.pem ca-cert.pem
  89. ############################################################
  90. ########## update the self-signed ca-ecc-cert.pem ##########
  91. ############################################################
  92. echo "Updating ca-ecc-cert.pem"
  93. echo ""
  94. #pipe the following arguments to openssl req...
  95. echo -e "US\nWashington\nSeattle\nwolfSSL\nDevelopment\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ca-ecc-key.pem -nodes -out ca-ecc-cert.csr
  96. openssl x509 -req -in ca-ecc-cert.csr -days 1000 -extfile wolfssl.cnf -extensions ca_ecc_cert -signkey ca-ecc-key.pem -out ca-ecc-cert.pem
  97. rm ca-ecc-cert.csr
  98. openssl x509 -in ca-ecc-cert.pem -text > tmp.pem
  99. mv tmp.pem ca-ecc-cert.pem
  100. ############################################################
  101. ########## update the self-signed ca-ecc384-cert.pem #######
  102. ############################################################
  103. echo "Updating ca-ecc384-cert.pem"
  104. echo ""
  105. #pipe the following arguments to openssl req...
  106. echo -e "US\nWashington\nSeattle\nwolfSSL\nDevelopment\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ca-ecc384-key.pem -nodes -sha384 -out ca-ecc384-cert.csr
  107. openssl x509 -req -in ca-ecc384-cert.csr -days 1000 -extfile wolfssl.cnf -extensions ca_ecc_cert -signkey ca-ecc384-key.pem -sha384 -out ca-ecc384-cert.pem
  108. rm ca-ecc384-cert.csr
  109. openssl x509 -in ca-ecc384-cert.pem -text > tmp.pem
  110. mv tmp.pem ca-ecc384-cert.pem
  111. ############################################################
  112. ##### update the self-signed (1024-bit) ca-cert.pem ########
  113. ############################################################
  114. echo "Updating 1024-bit ca-cert.pem"
  115. echo ""
  116. #pipe the following arguments to openssl req...
  117. echo -e "US\nMontana\nBozeman\nSawtooth\nConsulting_1024\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key \1024/ca-key.pem -nodes -sha1 -out \1024/ca-cert.csr
  118. openssl x509 -req -in \1024/ca-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey \1024/ca-key.pem -out \1024/ca-cert.pem
  119. rm \1024/ca-cert.csr
  120. openssl x509 -in \1024/ca-cert.pem -text > \1024/tmp.pem
  121. mv \1024/tmp.pem \1024/ca-cert.pem
  122. ###########################################################
  123. ########## update and sign server-cert.pem ################
  124. ###########################################################
  125. echo "Updating server-cert.pem"
  126. echo ""
  127. #pipe the following arguments to openssl req...
  128. echo -e "US\nMontana\nBozeman\nwolfSSL\nSupport\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key server-key.pem -nodes > server-req.pem
  129. openssl x509 -req -in server-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
  130. rm server-req.pem
  131. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  132. openssl x509 -in server-cert.pem -text > srv_tmp.pem
  133. mv srv_tmp.pem server-cert.pem
  134. cat ca_tmp.pem >> server-cert.pem
  135. rm ca_tmp.pem
  136. ###########################################################
  137. ########## update and sign server-revoked-key.pem #########
  138. ###########################################################
  139. echo "Updating server-revoked-cert.pem"
  140. echo ""
  141. #pipe the following arguments to openssl req...
  142. echo -e "US\nMontana\nBozeman\nwolfSSL_revoked\nSupport_revoked\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key server-revoked-key.pem -nodes > server-revoked-req.pem
  143. openssl x509 -req -in server-revoked-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 02 > server-revoked-cert.pem
  144. rm server-revoked-req.pem
  145. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  146. openssl x509 -in server-revoked-cert.pem -text > srv_tmp.pem
  147. mv srv_tmp.pem server-revoked-cert.pem
  148. cat ca_tmp.pem >> server-revoked-cert.pem
  149. rm ca_tmp.pem
  150. ###########################################################
  151. ########## update and sign server-duplicate-policy.pem ####
  152. ###########################################################
  153. echo "Updating server-duplicate-policy.pem"
  154. echo ""
  155. #pipe the following arguments to openssl req...
  156. echo -e "US\nMontana\nBozeman\nwolfSSL\ntesting duplicate policy\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key server-key.pem -nodes > ./test/server-duplicate-policy-req.pem
  157. openssl x509 -req -in ./test/server-duplicate-policy-req.pem -extfile wolfssl.cnf -extensions policy_test -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 02 > ./test/server-duplicate-policy.pem
  158. rm ./test/server-duplicate-policy-req.pem
  159. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  160. openssl x509 -in ./test/server-duplicate-policy.pem -text > srv_tmp.pem
  161. mv srv_tmp.pem ./test/server-duplicate-policy.pem
  162. cat ca_tmp.pem >> ./test/server-duplicate-policy.pem
  163. rm ca_tmp.pem
  164. ###########################################################
  165. #### update and sign (1024-bit) server-cert.pem ###########
  166. ###########################################################
  167. echo "Updating 1024-bit server-cert.pem"
  168. echo ""
  169. #pipe the following arguments to openssl req...
  170. echo -e "US\nMontana\nBozeman\nwolfSSL\nSupport_1024\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key \1024/server-key.pem -nodes -sha1 > \1024/server-req.pem
  171. openssl x509 -req -in \1024/server-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA \1024/ca-cert.pem -CAkey \1024/ca-key.pem -set_serial 01 > \1024/server-cert.pem
  172. rm \1024/server-req.pem
  173. openssl x509 -in \1024/ca-cert.pem -text > \1024/ca_tmp.pem
  174. openssl x509 -in \1024/server-cert.pem -text > \1024/srv_tmp.pem
  175. mv \1024/srv_tmp.pem \1024/server-cert.pem
  176. cat \1024/ca_tmp.pem >> \1024/server-cert.pem
  177. rm \1024/ca_tmp.pem
  178. ############################################################
  179. ########## update and sign the server-ecc-rsa.pem ##########
  180. ############################################################
  181. echo "Updating server-ecc-rsa.pem"
  182. echo ""
  183. echo -e "US\nMontana\nBozeman\nElliptic - RSAsig\nECC-RSAsig\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ecc-key.pem -nodes > server-ecc-req.pem
  184. openssl x509 -req -in server-ecc-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-ecc-rsa.pem
  185. rm server-ecc-req.pem
  186. openssl x509 -in server-ecc-rsa.pem -text > tmp.pem
  187. mv tmp.pem server-ecc-rsa.pem
  188. ############################################################
  189. ####### update the self-signed client-ecc-cert.pem #########
  190. ############################################################
  191. echo "Updating client-ecc-cert.pem"
  192. echo ""
  193. #pipe the following arguments to openssl req...
  194. echo -e "US\nOregon\nSalem\nClient ECC\nFast\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ecc-client-key.pem -nodes -out client-ecc-cert.csr
  195. openssl x509 -req -in client-ecc-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ecc-client-key.pem -out client-ecc-cert.pem
  196. rm client-ecc-cert.csr
  197. openssl x509 -in client-ecc-cert.pem -text > tmp.pem
  198. mv tmp.pem client-ecc-cert.pem
  199. ############################################################
  200. ########## update the server-ecc.pem #######################
  201. ############################################################
  202. echo "Updating server-ecc.pem"
  203. echo ""
  204. #pipe the following arguments to openssl req...
  205. echo -e "US\nWashington\nSeattle\nEliptic\nECC\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ecc-key.pem -nodes -out server-ecc.csr
  206. openssl x509 -req -in server-ecc.csr -days 1000 -extfile wolfssl.cnf -extensions server_ecc -CAfile ca-ecc-cert.pem -CAkey ca-ecc-key.pem -out server-ecc.pem
  207. rm server-ecc.csr
  208. openssl x509 -in server-ecc.pem -text > tmp.pem
  209. mv tmp.pem server-ecc.pem
  210. ############################################################
  211. ###### update the self-signed server-ecc-comp.pem ##########
  212. ############################################################
  213. echo "Updating server-ecc-comp.pem"
  214. echo ""
  215. #pipe the following arguments to openssl req...
  216. echo -e "US\nMontana\nBozeman\nElliptic - comp\nServer ECC-comp\nwww.wolfssl.com\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ecc-key-comp.pem -nodes -out server-ecc-comp.csr
  217. openssl x509 -req -in server-ecc-comp.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ecc-key-comp.pem -out server-ecc-comp.pem
  218. rm server-ecc-comp.csr
  219. openssl x509 -in server-ecc-comp.pem -text > tmp.pem
  220. mv tmp.pem server-ecc-comp.pem
  221. ############################################################
  222. ############## create the client-ca.pem file ###############
  223. ############################################################
  224. echo "Updating client-ca.pem"
  225. echo ""
  226. cat client-cert.pem client-ecc-cert.pem > client-ca.pem
  227. ############################################################
  228. ###### update the self-signed ecc-privOnlyCert.pem #########
  229. ############################################################
  230. echo "Updating ecc-privOnlyCert.pem"
  231. echo ""
  232. #pipe the following arguments to openssl req...
  233. echo -e ".\n.\n.\nWR\n.\nDE\n.\n.\n.\n" | openssl req -new -key ecc-privOnlyKey.pem -nodes -out ecc-privOnly.csr
  234. openssl x509 -req -in ecc-privOnly.csr -days 1000 -signkey ecc-privOnlyKey.pem -out ecc-privOnlyCert.pem
  235. rm ecc-privOnly.csr
  236. ############################################################
  237. ###### update the self-signed test/digsigku.pem ##########
  238. ############################################################
  239. echo "Updating test/digsigku.pem"
  240. echo ""
  241. #pipe the following arguments to openssl req...
  242. echo -e "US\nWashington\nSeattle\nFoofarah\nArglebargle\nfoobarbaz\ninfo@worlss.com\n.\n.\n" | openssl req -new -key ecc-key.pem -nodes -sha1 -out digsigku.csr
  243. openssl x509 -req -in digsigku.csr -days 1000 -extfile wolfssl.cnf -extensions digsigku -signkey ecc-key.pem -sha1 -set_serial 16393466893990650224 -out digsigku.pem
  244. rm digsigku.csr
  245. openssl x509 -in digsigku.pem -text > tmp.pem
  246. mv tmp.pem digsigku.pem
  247. mv digsigku.pem test/digsigku.pem
  248. ############################################################
  249. ########## make .der files from .pem files #################
  250. ############################################################
  251. echo "Creating der formatted certs..."
  252. echo ""
  253. openssl x509 -inform PEM -in \1024/client-cert.pem -outform DER -out \1024/client-cert.der
  254. openssl x509 -inform PEM -in \1024/server-cert.pem -outform DER -out \1024/server-cert.der
  255. openssl x509 -inform PEM -in \1024/ca-cert.pem -outform DER -out \1024/ca-cert.der
  256. openssl x509 -inform PEM -in ca-cert.pem -outform DER -out ca-cert.der
  257. openssl x509 -inform PEM -in ca-ecc-cert.pem -outform DER -out ca-ecc-cert.der
  258. openssl x509 -inform PEM -in ca-ecc384-cert.pem -outform DER -out ca-ecc384-cert.der
  259. openssl x509 -inform PEM -in client-cert.pem -outform DER -out client-cert.der
  260. openssl x509 -inform PEM -in server-cert.pem -outform DER -out server-cert.der
  261. openssl x509 -inform PEM -in client-ecc-cert.pem -outform DER -out client-ecc-cert.der
  262. openssl x509 -inform PEM -in server-ecc-rsa.pem -outform DER -out server-ecc-rsa.der
  263. openssl x509 -inform PEM -in server-ecc.pem -outform DER -out server-ecc.der
  264. openssl x509 -inform PEM -in server-ecc-comp.pem -outform DER -out server-ecc-comp.der
  265. ############################################################
  266. ###### update the ecc-rsa-server.p12 file ##################
  267. ############################################################
  268. echo "Updating ecc-rsa-server.p12 (password is \"\")"
  269. echo ""
  270. echo "" | openssl pkcs12 -des3 -descert -export -in server-ecc-rsa.pem -inkey ecc-key.pem -certfile server-ecc.pem -out ecc-rsa-server.p12 -password stdin
  271. ############################################################
  272. ###### update the test-servercert.p12 file #################
  273. ############################################################
  274. echo "Updating test-servercert.p12 (password is \"wolfSSL test\")"
  275. echo ""
  276. echo "wolfSSL test" | openssl pkcs12 -des3 -descert -export -in server-cert.pem -inkey server-key.pem -certfile ca-cert.pem -out test-servercert.p12 -password stdin
  277. ############################################################
  278. ###### calling gen-ext-certs.sh ##################
  279. ############################################################
  280. echo "Calling gen-ext-certs.sh"
  281. echo ""
  282. cd ..
  283. ./certs/test/gen-ext-certs.sh
  284. cd ./certs
  285. ############################################################
  286. ###### calling gen-badsig.sh ##################
  287. ############################################################
  288. echo "Calling gen-badsig.sh"
  289. echo ""
  290. cd ./test
  291. ./gen-badsig.sh
  292. cd ../
  293. ############################################################
  294. ########## generate ocsp certs ######################
  295. ############################################################
  296. echo "Changing directory to ocsp..."
  297. echo ""
  298. # guard against recursive calls to renewcerts.sh
  299. if [ -d ocsp ]; then
  300. cd ./ocsp
  301. echo "Execute ./renewcerts.sh..."
  302. ./renewcerts.sh
  303. cd ../
  304. else
  305. echo "Error could not find ocsp directory"
  306. exit 1
  307. fi
  308. ############################################################
  309. ###### calling assemble-chains.sh ##################
  310. ############################################################
  311. echo "Calling assemble-chains.sh"
  312. echo ""
  313. cd ./test-pathlen
  314. ./assemble-chains.sh
  315. cd ../
  316. ############################################################
  317. ########## store DER files as buffers ######################
  318. ############################################################
  319. echo "Changing directory to wolfssl root..."
  320. echo ""
  321. cd ../
  322. echo "Execute ./gencertbuf.pl..."
  323. echo ""
  324. ./gencertbuf.pl
  325. ############################################################
  326. ########## generate the new crls ###########################
  327. ############################################################
  328. echo "Change directory to wolfssl/certs"
  329. echo ""
  330. cd certs
  331. echo "We are back in the certs directory"
  332. echo ""
  333. echo "Updating the crls..."
  334. echo ""
  335. cd crl
  336. echo "changed directory: cd/crl"
  337. echo ""
  338. ./gencrls.sh
  339. echo "ran ./gencrls.sh"
  340. echo ""
  341. #cleanup the file system now that we're done
  342. echo "Performing final steps, cleaning up the file system..."
  343. echo ""
  344. rm ../wolfssl.cnf
  345. }
  346. #function for restoring a previous configure state
  347. function restore_config(){
  348. mv tmp.status config.status
  349. mv tmp.options.h wolfssl/options.h
  350. make clean
  351. make -j 8
  352. }
  353. #function for copy and pasting ntru updates
  354. function move_ntru(){
  355. cp ntru-cert.pem certs/ntru-cert.pem
  356. cp ntru-key.raw certs/ntru-key.raw
  357. cp ntru-cert.der certs/ntru-cert.der
  358. }
  359. ###############################################################################
  360. ##################### THE EXECUTABLE BODY #####################################
  361. ###############################################################################
  362. #start in root.
  363. cd ../
  364. #if HAVE_NTRU already defined && there is no argument
  365. if grep HAVE_NTRU "wolfssl/options.h" && [ -z "$1" ]
  366. then
  367. #run the function to renew the certs
  368. run_renewcerts
  369. # run_renewcerts will end in the wolfssl/certs/crl dir, backup to root.
  370. cd ../../
  371. echo "changed directory to wolfssl root directory."
  372. echo ""
  373. echo ""
  374. echo "Enter directory to ed25519 certificate generation example."
  375. echo "Can be found at https://github.com/wolfSSL/wolfssl-examples"
  376. read ED25519_DIR
  377. if [ -d "${ED25519_DIR}" ]; then
  378. pushd ./certs/ed25519
  379. ./gen-ed25519.sh ${ED25519_DIR}
  380. popd
  381. else
  382. echo "Unable to find directory ${ED25519_DIR}"
  383. exit 1
  384. fi
  385. ############################################################
  386. ########## update ntru if already installed ################
  387. ############################################################
  388. # We cannot assume that user has certgen and keygen enabled
  389. ./configure --with-ntru --enable-certgen --enable-keygen
  390. make check
  391. #copy/paste ntru-certs and key to certs/
  392. move_ntru
  393. #else if there was an argument given, check it for validity or print out error
  394. elif [ ! -z "$1" ]; then
  395. #valid argument then renew certs without ntru
  396. if [ "$1" == "--override-ntru" ]; then
  397. echo "overriding ntru, update all certs except ntru."
  398. run_renewcerts
  399. #valid argument create ed25519 certificates
  400. elif [ "$1" == "--ed25519" ] || [ "$2" == "--ed25519" ]; then
  401. echo ""
  402. echo "Enter directory to ed25519 certificate generation example."
  403. echo "Can be found at https://github.com/wolfSSL/wolfssl-examples"
  404. read ED25519_DIR
  405. pushd ./certs/ed25519
  406. ./gen-ed25519.sh ${ED25519_DIR}
  407. popd
  408. #valid argument print out other valid arguments
  409. elif [ "$1" == "-h" ] || [ "$1" == "-help" ]; then
  410. echo ""
  411. echo "\"no argument\" will attempt to update all certificates"
  412. echo "--override-ntru updates all certificates except ntru"
  413. echo "--ed25519 updates all ed25519 certificates"
  414. echo "-h or -help display this menu"
  415. echo ""
  416. echo ""
  417. #else the argument was invalid, tell user to use -h or -help
  418. else
  419. echo ""
  420. echo "That is not a valid option."
  421. echo ""
  422. echo "use -h or -help for a list of available options."
  423. echo ""
  424. fi
  425. #else HAVE_NTRU not already defined
  426. else
  427. echo "Saving the configure state"
  428. echo ""
  429. cp config.status tmp.status
  430. cp wolfssl/options.h tmp.options.h
  431. echo "Running make clean"
  432. echo ""
  433. make clean
  434. #attempt to define ntru by configuring with ntru
  435. echo "Configuring with ntru, enabling certgen and keygen"
  436. echo ""
  437. ./configure --with-ntru --enable-certgen --enable-keygen
  438. make check
  439. # check options.h a second time, if the user had
  440. # ntru installed on their system and in the default
  441. # path location, then it will now be defined, if the
  442. # user does not have ntru on their system this will fail
  443. # again and we will not update any certs until user installs
  444. # ntru in the default location
  445. # if now defined
  446. if grep HAVE_NTRU "wolfssl/options.h"; then
  447. run_renewcerts
  448. #run_renewcerts leaves us in wolfssl/certs/crl, backup to root
  449. cd ../../
  450. echo "changed directory to wolfssl root directory."
  451. echo ""
  452. move_ntru
  453. echo "ntru-certs, and ntru-key.raw have been updated"
  454. echo ""
  455. # restore previous configure state
  456. restore_config
  457. else
  458. # restore previous configure state
  459. restore_config
  460. echo ""
  461. echo "ntru is not installed at the default location,"
  462. echo "or ntru not installed, none of the certs were updated."
  463. echo ""
  464. echo "clone the ntru repository into your \"cd ~\" directory then,"
  465. echo "\"cd NTRUEncrypt\" and run \"make\" then \"make install\""
  466. echo "once complete run this script again to update all the certs."
  467. echo ""
  468. echo "To update all certs except ntru use \"./renewcerts.sh --override-ntru\""
  469. echo ""
  470. fi #END now defined
  471. fi #END already defined
  472. exit 0