In order to generate M1 to M5 values as required by the SHE memory  
update protocol several programs are required.
These have been provided for convenience.
The C-sources are provided in directory src.
These have been compiled using gcc to create executables which can be 
found in directory bin.

The following sources were downloaded from www.hoozi.com and modified 
by Freescale. Original author was Niyaz PK.
AES_ENC_CBC_CMD.c
AES_ENC_ECB_CMD.c
AES_MP_KDF_CMD.c

The following source was based on an original program by Junhyuk Song
and Jicheol Lee:
AES_CMAC_CMD.c

A script which uses these programs has been written and runs on unix based systems.
It has been tested on cygwin system. This script is called create_M1_to_M5.
A further script which calls that script has been written so multiple key's M* values 
can be generated.

Please make sure that you are using the tcsh in cygwin.

create_M1_to_M5 new_key_value auth_key_value UID_120_bits  ID_of_key_being_updated  id_of_authorizing_key new_counter_value WP|BP|DP|KU|WC|3b0

Example use of create_M1_to_M5:

source create_M1_to_M5 2FF8B03C5C5405465A9C94BD2D863279 00000000000000000000000000000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 4  4 0000001 00

Example output:

M1 ID 4 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44
M2 ID 4 ff8b75f73e6ad5a1729423c6e9311f1a 244bebb8574290b1dc4c304f8c5031b1
M3 ID 4 f24a833ce8af4bb162ebafd93cf36644
M4 ID 4 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44 66c1f68720c2884a5a0d407d8d53f4b0
M5 ID 4 fb999b88631352ff8e9d53051e6cbbca

In order to process more than one key use generate_all_M1_to_M5

Example use of generate_all_M1_to_M5:

source generate_all_M1_to_M5 | sort | ./make_array.pl > ../generated_testfile.h

The make_array.pl script formats the output into an array which can be included in application code.

Example output of this command may be found in file example_header_file.h
Note that it is left to the user to change the UID_120 environment variable in generate_all_M1_to_M5.
In the example provided WC=0 which means that UID_120 must be set on a per part basis.
If WC were to be set to be 1 then UID_120 would then be 0.

