So I want to create a simple, fast and yet secure authentication in two steps for a PC - microcontroller communication.

The first step is a seed request, the second step is an authentication request.

The encryption that is being used is AES-128.

There should be a fixed key k with a length of 16 bytes.

Whenever a seed request is coming a random 16 bytes authentication message m should be generated and then be encrypted with k and sent back to the client as a seed s.

(NOTE: E(k, m) will always output the same s)

The seed s then should be decrypted with k by the client and then the original authentication message m should be sent to the server as an authentication request.

The server compares the auth message m with the message of the request, and grants access if they are equal or rejects the request otherwise.

Also assume that an adversary can collect as many m and s pairs as he wants.

Based on the information above is it feasible to easily break this system or not?

  • $\begingroup$ Authentication is nice, but what are you going to do afterwards? How do you know that you are communicating with the right party? Don't you need to establish a secret? Or dual authentication? PS removed previous answer, shouldn't be answering in the morning. $\endgroup$
    – Maarten Bodewes
    Commented Mar 18, 2017 at 12:25
  • $\begingroup$ Consider it as a one to one communication, and after a successful auth you can access higher level functions of the controller, like modifying expert parameters and so on. $\endgroup$
    – Szabolcs
    Commented Mar 18, 2017 at 12:46

2 Answers 2


It is vulnerable to replay attacks since the attacker knows the plaintext and its corresponding ciphertext. To mitigate against this you might want to include some information in the message like a timestamp so that assuming time keeping isn't compromised for the server and client, outdated messages, i.e messages marked by a timestamp earlier than a certain timeframe can be invalidated.

  • 1
    $\begingroup$ I don't think replay attack is an efficient approach here, because there are 2^128 (s, m) pairs. So the probability you get a seed that was already sent before is really low. $\endgroup$
    – Szabolcs
    Commented Mar 18, 2017 at 12:20
  • $\begingroup$ Ah i did not realize m is 16 bytes long and picked at random. I think you're right that a replay attack is inefficient. $\endgroup$
    – elemetrics
    Commented Mar 18, 2017 at 23:22

No. This authentication scheme is secure. What this means is that when the protocol is done (server checks m = m'), the server can be sure that—some time before—an authentication request has been done by a party that knows k.

What you do after the authentication step may not be secure however. You should not forget to also authenticate every message in the conversation.

  • $\begingroup$ Excuse me but what happens if the attacker intercepts the message $m'$ and forward it ? How can I make this scheme secure over the "Internet"? $\endgroup$
    – thinker.92
    Commented May 27, 2019 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.