How to implement access control for Automotive Embedded Systems using mbedTLS? I am trying to implement a security access scheme for Automotive Embedded Systems.I need to be able to generate a Random number(of my desired length), combine it with some secret data to send a Seed/Challenge, generate a Key internally using the same Seed/Challenge as one of the inputs to a function and then be able to compare the received key with the computed key. Could someone help me know whether mbedTLS /PolarSSL library has functions to support me in achieving my objectives? I am new to this topic and there are too many new terms that I do not fully understand.

Summary of my needs:


Generate a RN of desired length (N1 bytes)
Seed / Challenge: RN + secret_data1 (N2 bytes)
Generate Key: f1(Challenge,  secret_data2, fixed data bytes) -> N3 bytes
Compare Key: f2(received key, generated key) -> return SUCCESS / FAILURE 


Thank you in advance.
As stated in the comments we can't / won't advise on whether PolarSSL is suitable to perform the operations required.



However, for your needs $N_1=N_2=N_3=32$ sounds like a reasonable choice, giving you a solid 256-bit security and no need to worry about truncation and the alike.

As for $f_1$, HMAC-SHA256 sounds like the obvious choice, also giving you $N_3=32$. You'd input the secret data as a key and the challenge and the fixed bytes as a message and you're good.

Finally for $f_2$, this needs to be the same choice as $f_1$ paired with a simple constant time comparison.

I can't promise anything, but all of this functionality is required for any TLS implementation right now, so if the low-level primitives are provided you can use the library.