Since there are many Chinese companies that can easily reverse engineer the PCB design and extract the .hex file out of the microcontrollers (even from the secure flash), embedded developers have to add some more protection to their products. In my case I'm using a STM32F103 and I want to add the crypto IC ATSHA204A on my PCB to protect my IP. By doing this, I'm hoping even if they can get the .hex out of the MCU and clone the board, the hex file will refuse to work if it cannot recognize crypto chip on the PCB.
This crypto IC has a unique serial number that was written while being manufactured, and it can always be read. It also has some features such as a secure area to keep some secret data, ability to generate random numbers and send it to the host via I2C or one-wire, ability to calculate SHA-256 hash of some given string and so on.
Now I am trying to understand how I should work with it as I am kind of a noob on the authentication subject. From what I have understood from reading the datasheet is, the workflow will be like this:
Personalization of the crypto IC:
The secure area in the crypto chip will be filled by the host (STM32F103 in my case) with some random secret key for each product, only once.
The secret key will also be present in the hosts flash memory.
Authentication of the board (My understanding, which is probably wrong):
The host requests a random number from the crypto-IC. Then the host generates some concatenated string with the secret key and the random number (nonce?), and calculate the SHA-256 hash of it.
Now the host should send the random key back to the crypto-IC and expect from it to generate the same string with the secret key inside of the crypto-IC and calculate the SHA-256 hash of it.
Crypto-IC sends the calculated hash back to the host and the host compares the hashes.
If the hashes match, validate. If they don't, the host refuses to work.
The workflow is probably wrong, but the main idea should be something close to it. Can anybody explain this?