I'm currently trying to encrypt my key with KEK and send back the whole encrypted header over UART.
I've made a program that works on a secure device (while in NONSECURE boot mode) that configures the hardware (pinmux, clocks, uart, gpio) and sends the part of the memory where the encrypted header will be over UART. This works.
For the SECURE_WITH_SK boot I've changed the main() function to read:
void main( void ) {
encrypted = SK_setUserKey( keystruct );
SK_switchNonSec( main_non_sec );
}
all the code from the tested program is in main_non_sec(), which means hardware init, UART communication and status notification via LEDs turned on/off with GPIO.
The .ini for SecureHexAIS (simple test keys for now, just to make sure it works) contains this:
[General]
busWidth=8
BootMode=UART
crcCheckType=NO_CRC
seqReadEn=ON
[Security]
securityType=GENERIC
bootExitType = SECUREWITHSK
encryptSections=ALL
encryptionKey=000102030405060708090A0B0C0D0E0F
genericSHASelection = SHA256
[TAPSCONFIG]
TAPSCFG = 0x0000FFFF
[AIS_Set]
TYPE = 2
ADDRESS = 0x80000000
DATA = 0xBE40C0DE
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x80000004
DATA = 0x00000000
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x80000008
DATA = 0x00000001
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x8000000C
DATA = 0x01234567
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x80000010
DATA = 0x10111213
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x80000014
DATA = 0x14151617
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x80000018
DATA = 0x18191A1B
SLEEP = 128
[AIS_Set]
TYPE = 2
ADDRESS = 0x8000001C
DATA = 0x1C1D1E1F
SLEEP = 128
Yes, the keystruct resides at 0x80000000 and has the NOINIT flag set in the linker. The whole program seems to load and run fine:
(File IO): Read 8700 bytes from file C:\Program Files (x86)\Texas Instruments\SecureHexAIS\DSP_Bootstrap.bin.
(Serial Port): Opening COM1 at 115200 baud...
(AIS Parse): Read magic word 0x41504954.
(AIS Parse): Waiting for BOOTME... (power on or reset target now)
(AIS Parse): BOOTME received!
(AIS Parse): Performing Start-Word Sync...
(AIS Parse): Performing Ping Opcode Sync...
(AIS Parse): Processing command 0: 0x58535920.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Secure key loading, entering secure mode.
(AIS Parse): Processing command 1: 0x58535923.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Setting boot exit mode...
(AIS Parse): Set exit mode to 0x00000001.
(AIS Parse): Processing command 2: 0x5853590D.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Executing function...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 3: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 4: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 5: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 6: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 7: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 8: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 9: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 10: 0x58535907.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading boot table...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): Processing command 11: 0x58535921.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading encoded section...
(AIS Parse): Loaded 7520-Byte section to address 0x80000020.
(AIS Parse): Processing command 12: 0x58535921.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading encoded section...
(AIS Parse): Loaded 84-Byte section to address 0x800026B4.
(AIS Parse): Processing command 13: 0x58535921.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Loading encoded section...
(AIS Parse): Loaded 512-Byte section to address 0x80002800.
(AIS Parse): Processing command 14: 0x58535906.
(AIS Parse): Performing Opcode Sync...
(AIS Parse): Performing jump and close...
(AIS Parse): Secure mode; sending signature.
(AIS Parse): AIS complete. Jump to address 0x80001C00.
(AIS Parse): Waiting for DONE...
(AIS Parse): Boot completed successfully.
(Serial Port): Closing COM1.
However it doesn't work. When I connect with JTAG, the processor is stuck at 0x007F7FF0, which according to the OMAPL138 memory map (taken from SPRS586H) is the DSP L2 ROM, which means it still hasn't left the original bootloader. For a while I thought I might've made a mistake while copying the SK_* functions from the documentation, but putting an infinite loop before SK_setUserKey() makes no difference - the processor is still stuck at 0x007F7FF0 after boot.