I am using MBED TLS to connect to the azure IoT Hub. Somewhere in the Azure code, a key is passed into the function “mbedtls_aes_setkey_enc”. I need to get this key out of the function so I can use it in my own hardware accelerated version of the MBED TLS CBC encryption function. However, the complicating factor is that the set key function is called multiple times by unrelated functions, so the only thing I have is the context struct which is passed to the encryption function.
The context struct only stores round keys from “mbedtls_aes_setkey_enc”, but I need the 256 bit encryption key, not the round keys. The only solution I have come up with is to take the round keys and convert it back to the encryption key in my encryption function, however this seems to be a very complex approach for something that should be quite simple.
Does anyone have any ideas of how I could get this 256 encryption key into my encryption function?