*************************************
How to use the scripts 
*************************************
1. gen_ecc_pub_key_hfile.bat

   This script can be used to generate the header file of ECC public key data array.
   This header file will be compiled in the Boot project for ECDSA signature verification.

   Two parameters to be given when running the script in windows command console

   param1: <ecc key file>
   param2: The folder where the header file for public key will be generated

   Example of usage: 
	gen_ecc_pub_key_hfile.bat ecc.key ..\Projects\Boot\Inc\

   After running the script, on the console you will see something as follows. 
   The content of the generated header file is also shown on the console.
	"################# Generate public key from private ecc key "
	read EC key
	"################# Get public key hex data "
	read EC key
	"    04:0f:57:11:87:de:7c:d0:12:aa:23:07:9b:c5:98: "
	"    8c:6c:a1:31:a4:6d:f4:2c:5d:c2:94:d4:3b:4d:c3: "
	"    f1:c8:4e:d1:48:13:8c:e5:8e:00:f2:c4:05:bf:ca: "
	"    37:e0:ae:43:7b:56:83:0d:21:e2:4e:df:be:92:d5: "
	"    7e:2e:84:35:9c "
	"################# Display header file content "
	#ifndef __ECC_PUB_KEY_H_
	#define __ECC_PUB_KEY_H_
	static const uint8_t ECC_PUB_KEY[] = {
	 0x04, 0x0f, 0x57, 0x11, 0x87, 0xde, 0x7c, 0xd0, 0x12, 0xaa, 0x23, 0x07, 0x9b, 0xc5, 0x98,
	 0x8c, 0x6c, 0xa1, 0x31, 0xa4, 0x6d, 0xf4, 0x2c, 0x5d, 0xc2, 0x94, 0xd4, 0x3b, 0x4d, 0xc3,
	 0xf1, 0xc8, 0x4e, 0xd1, 0x48, 0x13, 0x8c, 0xe5, 0x8e, 0x00, 0xf2, 0xc4, 0x05, 0xbf, 0xca,
	 0x37, 0xe0, 0xae, 0x43, 0x7b, 0x56, 0x83, 0x0d, 0x21, 0xe2, 0x4e, 0xdf, 0xbe, 0x92, 0xd5,
	 0x7e, 0x2e, 0x84, 0x35, 0x9c
	};
	static const size_t ECC_PUB_LEN = 65;
	#endif /*__ECC_PUB_KEY_H_*/

    

2. sign_message_txt.bat

   This script can be used to generate the response message binary basing on the input challenge file in text format.
   e.g. the content of a challenge might look like this:
	65  c9  c1  f5  e1  b9  33  3d  95  2f  1c  21  54  39  b7  7a
 	c4  f0  4c  65  82  b2  39  b0  59  9f  30  b3  11  7b  1a  14
 	62  0a  60  9d  9c  b1  ce  09  fb  03  ea  97  62  4c  d8  d4
 	7e  98  e4  dd  8a  c1  97  ea  cc  52  16  46  f3  a3  ad  3d
 	9a  b9  46  33  ad  85  b3  10  3d  41  ff  62  b3  bd  89  bb
 	24  ce  e8  c4  97  89  27  77  50  a8  49  8b  7f  b2  ae  6a
 	64  1a  bf  94  8a  75  f7  e7  94  fe  bf  27  e1  11  88  e1
 	69  1b  43  9f  60  9a  6a  a2  7f  63  a3  d9  87  9d  3b  b5
 	16  3d  e4  2c  82  a4  ed  a2  3f  83  04  bb  5b  b2  f1  96
 	70  df  44  5e  11  43  02  76  bb  c8  9b  8e  96  38  7b  f6
 	68  91  05  78  de  c6  f3  db  0a  e5  9a  12  f4  0b  3b  e3
 	d9  79  18  66  cd  c6  93  17  68  2f  a0  68  8f  5d  c2  6c
 	f4  51  69  5c  1b  94  3f  f1  72  dd  dc  8d  75  1f  15  e2
 	f8  d5  57  3b  65  e8  54  f4  c9  5b  f2  1a  ba  e2  96  9c
 	b2  ac  87  a7  7c  f4  42  56  b0  ae  b0  24  80  2a  49  34
 	a4  83  6c  b4  29  c1  53  62  34  be  02  b3  c4  27  c4  6b

  To generate the response data of this challenge data, two parameters shall be given to run the script
  param1: <challenge txt file>
  param2: <ecc key file>
  Example of usage:
	sign_message_txt.bat challenge.txt ecc.key

  After running the script, on the console you will see something as follows. 
  After that the response file will be generated as message_ecdsa.sig. 
  Then in TeraTerm window, you can press 'c' to continue the authentication and send file message_ecdsa.sig 
  through TeraTerm menu (don't forget to check "binary" option in the "Send file" window)
  
	binary file to be handled: "C:\MMS\MMS-MCD\LAT\H7\H7DbgProt\Utils\\challenge.bin"
	########## Convert txt to bin ############
	Input Length = 1038
	Output Length = 256
	CertUtil: -decodehex command completed successfully.
	000000  65 c9 c1 f5 e1 b9 33 3d 95 2f 1c 21 54 39 b7 7a
	000010  c4 f0 4c 65 82 b2 39 b0 59 9f 30 b3 11 7b 1a 14
	000020  62 0a 60 9d 9c b1 ce 09 fb 03 ea 97 62 4c d8 d4
	000030  7e 98 e4 dd 8a c1 97 ea cc 52 16 46 f3 a3 ad 3d
	000040  9a b9 46 33 ad 85 b3 10 3d 41 ff 62 b3 bd 89 bb
	000050  24 ce e8 c4 97 89 27 77 50 a8 49 8b 7f b2 ae 6a
	000060  64 1a bf 94 8a 75 f7 e7 94 fe bf 27 e1 11 88 e1
	000070  69 1b 43 9f 60 9a 6a a2 7f 63 a3 d9 87 9d 3b b5
	000080  16 3d e4 2c 82 a4 ed a2 3f 83 04 bb 5b b2 f1 96
	000090  70 df 44 5e 11 43 02 76 bb c8 9b 8e 96 38 7b f6
	0000a0  68 91 05 78 de c6 f3 db 0a e5 9a 12 f4 0b 3b e3
	0000b0  d9 79 18 66 cd c6 93 17 68 2f a0 68 8f 5d c2 6c
	0000c0  f4 51 69 5c 1b 94 3f f1 72 dd dc 8d 75 1f 15 e2
	0000d0  f8 d5 57 3b 65 e8 54 f4 c9 5b f2 1a ba e2 96 9c
	0000e0  b2 ac 87 a7 7c f4 42 56 b0 ae b0 24 80 2a 49 34
	0000f0  a4 83 6c b4 29 c1 53 62 34 be 02 b3 c4 27 c4 6b
	########## Generate hash ############
	MESSAGE HASH
	000000  ff f7 8c 5b b2 c0 05 e4 f8 66 e1 9d c5 24 6f 15
	000010  f0 1e 5e 56 5c 1d c7 c0 b0 dc 70 a7 f4 0b d4 7f
	########## Sign hash biary ############
	########## Convert signature from asn1 to raw binary ############
	Message ECDSA Signature
	000000  a1 66 fc 46 7e b5 12 d3 3c 14 2c 72 a9 0e a5 33
	000010  37 65 81 24 fe fa f9 4a 02 52 41 e2 86 ad 47 a8
	000020  3c 31 bb ac 1b 66 df ba 0c 7a c9 8d 28 1b fd a6
	000030  c4 6b c5 f5 de 04 f7 2b 15 81 df 13 7f 86 72 6a
	"################# Generate public key from private ecc key "
	"################# Convert public key to binary "
	read EC key
	Public Key
	000000  0f 57 11 87 de 7c d0 12 aa 23 07 9b c5 98 8c 6c
	000010  a1 31 a4 6d f4 2c 5d c2 94 d4 3b 4d c3 f1 c8 4e
	000020  d1 48 13 8c e5 8e 00 f2 c4 05 bf ca 37 e0 ae 43
	000030  7b 56 83 0d 21 e2 4e df be 92 d5 7e 2e 84 35 9c
	=======================================================
	File to be send back as response for ECDSA verification:
	C:\MMS\MMS-MCD\LAT\H7\H7DbgProt\Utils\\message_ecdsa.sig
	=======================================================
	Press any key to continue . . .