| Documentation |
|---|
| Related products |
|---|
| USB-I2C/SPI/GPIO Adapter - U2C-12 |
| USB-IO Interface Adapter - GPIO-12 |
XTEA encryption algorithm has been added to the bootloader to prevent unauthorized copying of user mode applications.
For successful firmware update user mode application should be encrypted with exactly the same XTEA key that was specified in the bootloader. Bootloader code is programmed into Flash memory at the production stage and is protected from reading by PIC microcontroller hardware. The end user is unable to find out the XTEA key and to decrypt application HEX file. You can send encrypted versions of user application to clients, and don’t worry if they can be used in other devices.
To change the XTEA key you have to modify constant value XTEA_KEY. Key length is 16 bytes. This constant is defined in xtea.asm file as shown below:
;------------------------------------------------------ XTEA_KEYS_SECTION CODE_PACK 0x001C ; Place ROM constants after vectors XTEA_KEY db "abcdefghijklmnop" ; 16 byte Key The key can be set as a string or as a bytes sequence, e.g.: ;------------------------------------------------------ XTEA_KEYS_SECTION CODE_PACK 0x001C ; Place ROM constants after vectors XTEA_KEY db 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70 ; 16 byte Key
Besides the key it is possible to change encryption algorithm iterations number. The iterations number defines protection level. 64 iterations set as default.
If you change iterations number, you have also to change DELTA_ITER value. DELTA_ITER should be equal to DELTA * XTEA_ITERATIONS.
For example:
XTEA_ITERATIONS equ 0x40 ; Number of iterations on x1,x2 DELTA_ITER db 0x40,0x6e,0xde,0x8d ; Delta*XTEA_ITERATIONS
In case of iterations number change in Bootloader code, one has to make identical changes in encoder application. This program is used to encrypt user application.