BOARD imxrt1020evk.
I was not answered the previous question, I am creating a new one. Using your encryption utility enc_image.
enc_operation.c (func - void handle_data_enc_ctr(uint8_t *key, uint8_t *nonce, uint8_t *buf, size_t length))
I change your source code, because it didn't work fine.
#if 0 //BUGS CODE DETECTED
mbedtls_aes_crypt_ctr(&ctx, length, &offset, nonce, stream_block, buf, buf); //this code don't encrypt any data !!!
#else
mbedtls_aes_crypt_ctr(&ctx, length, &offset, nonce, stream_block, buf, out_buf); //this code work fine
memcpy(buf, out_buf, length);
#endif
Build this code: gcc *.c -lmbedtls -lmbedx509 -lmbedcrypto -o image_enc
After that:
./image_enc ifile=flexspi_nor_edma_transfer.bin ofile=flexspi_nor_edma_transfer_bee_encrypted_ctr.bin base_addr=0x60000000 region0_key=0123456789abcdeffedcba9876543210 region0_arg=1,[0x60001000,0x3FF000,0] region0_lock=0 use_zero_key=1 is_boot_image=1
Remove padding 1K size
dd if=flexspi_nor_edma_transfer_bee_encrypted_ctr.bin of=flexspi_nor_edma_transfer_bee_encrypted_ctr_remove1K.bin skip=1 bs=1024 count=200
Generate encrypt sb file
./elftosb -f kinetis -V -c program_imxrt1020_qspi_encrypt_sw_gp2.bd -o boot_image_encrypt.sb flexspi_nor_edma_transfer_bee_encrypted_ctr_remove1K.bin
Generate burn_fuse sb file
./elftosb -f kinetis -V -c burn_fuse.bd -o burn_fuse.sb
Flash images
./sdphost -t 50000 -p /dev/ttyACM0,115200 write-file 0x20208000 ivt_flashloader.bin
./sdphost -t 50000 -p /dev/ttyACM0,115200 jump-address 0x20208400
./blhost -p /dev/ttyACM0,115200 receive-sb-file burn_fuse.sb
./blhost -p /dev/ttyACM0,115200 receive-sb-file boot_image_encrypt.sb
BOARD NOT LOAD FROM FLEXSPI!!!
the same result with AEC ECB when try:
./image_enc ifile=flexspi_nor_edma_transfer.bin ofile=flexspi_nor_edma_transfer_bee_encrypted_ctr.bin base_addr=0x60000000 region0_key=0123456789abcdeffedcba9876543210 region0_arg=1,[0x60001000,0x3FF000,0] region0_lock=0 use_zero_key=1 is_boot_image=1
I read efuse:
./blhost -p /dev/ttyACM0,115200 efuse-read-once 6 - 0x3000 by secure datasheet 0x460[13,12] - set 12,13 bit - BEE_KEY0_SEL from SW_GP2
AES_KEY:(my key is 0123456789abcdeffedcba9876543210)
/blhost -p /dev/ttyACM0,115200 efuse-read-once 41 - 0x76543210
./blhost -p /dev/ttyACM0,115200 efuse-read-once 42 - 0xfedcba98
./blhost -p /dev/ttyACM0,115200 efuse-read-once 43 - 0x89abcdef
./blhost -p /dev/ttyACM0,115200 efuse-read-once 44 - 0x01234567
KIB0 and PRDB0 located in flexspi by offset 0x400 and 0x480. you write this data with a utility enc_image.
Has anyone checked the functionality of this utility??? Perhaps there is a working version of this utility(enc_image)? So far the impression is that nothing is working AES ECB - don't work, AES CTR - don't work. Bee encryption on the fly don't work....