This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Securing and authenticating code in the field

Other Parts Discussed in Thread: SHA-256

I have a very basic understanding of the C2000's CSM, we're planning on using a OTP bootloader to do upgrades in the field.


The problem I'm facing is that

1) The Flash API in ROM is considered insecure, so it cannot be used to flash a secure device

2) This necessitates sending the Flash API another way (over the serial port, etc) into secure SARAM with help from the OTP bootloader and then executing it, as discussed here:

http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/170158.aspx?pi303962=1


So how do I go about validating that what is being sent is really the Flash API and not some nefarious code designed to dump the contents of flash back out to the serial port?  I somehow doubt an SHA-256 signing algorithm is going to fit in the OTP flash space...

Along the same lines, we'd like to encrypt the actual firmware such that only the OTP can decode it right before flashing.  A basic symmetric encryption algorithm would probably suffice, since OTP is considered secure the decryption key could be hard-coded.


Thoughts?

  • Nathan,

    You don't have to transmit the flash APIs from an external source.  You could keep them resident in your flash (in the boot flash sector, e.g. in flash sector A alongside your flash reprogramming kernel.  That way if something goes wrong during re-flashing such as a power loss, you can reboot and try again.  You NEVER re-flash the boot sector in the field once the product is deployed).  When you want to re-flash the device, you copy them to secure RAM (to their linked runtime address).  The downside of doing this is that the APIs consume flash space, and also if for some reason you ever needed to upgrade your APIs you would need reflash the boot sector in the flash which is not something you would want to be doing in the field (again, because if you lost power while sector A was erased, you'd need JTAG to recover).

    Yes, I know some users have implemented an encryption scheme for the incoming new flash contents.  I cannot advise though on what they used.  I agree, you need something reasonably small and efficient (since you probably don't want the re-flashing process to take too long).

    Regards,

    David

  • David,

    True, we could reserve some additional space (like Flash A) outside the OTP flash to hold the flash API, but that seems to be increasing the risk of the OTP bootloader being able to recover in the event of a flashing problem.  I'm already concerned that the OTP can always be programmed (flipping bits from 1 to 0) after we ship, sticking dependency code in flash that can be erased in the field just seems like asking for problems.


    That would probably leave enough space for a decent encryption / validation scheme for the rest of the flash though.

    --Nathan

  • Nathan,

    Nathan Lewis1 said:

    True, we could reserve some additional space (like Flash A) outside the OTP flash to hold the flash API, but that seems to be increasing the risk of the OTP bootloader being able to recover in the event of a flashing problem.

    Maybe you meant to say "NOT being able to recover?"

    I wouldn't worry about bits in the OTP being programmed from 1's to 0's by a hacker.  First, he'd need to get by your encyption scheme.  Your scheme should be using a CRC check word for each data buffer that is sent over the comms link for re-flashing.  The CRC value is also encrypted, probably located as the last word(s) in the packet/buffer that is sent.  The secondary bootloader decrypts, and then checks the CRC against the CRC it computes for the received data buffer.  That way, without the encryption key a hacker could not make any rogue packets and send them into the device to re-flash stuff you don't want anyone to touch.  Second, if someone figured out your encryption key, they wouldn't waste their time poking 0's into your OTP.  They'd do more devious stuff!

    An important thing here is to NOT unlock the CSM when re-flashing the device.  You don't need to.  Run the flash APIs from secure RAM.  They don't need the CSM unlocked in order to operate on the flash from there.

    Regards,

    David