Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am making an arduino project to open my garage door. I want to make it so user

ID: 650893 • Letter: I

Question

I am making an arduino project to open my garage door. I want to make it so users with the passphrase can open the door. Due to computational restrictions it is unlikely encryption is possible. Under the assumption that only hashing algorithms are available, what is a secure way of protecting the door? My thoughts:

Client sends request to open door. Server increments counter.
Server responds with current counter value, timestamp and date, with hmac of the above. Client responds with H(passphrase + counter) + above server response. Server verifies hmac of server response, timestamp is within valid window, and sent hash matches known secret appended with counter.

Have I thought this one through properly or am I missing something?

Explanation / Answer

Some points:

Make sure you authenticate everything you send, not only parts of it. So, append a HMAC(password, everything) to the end of each message (which means both messages, not only the ones sent by the clients). If you do this, the message itself doesn't need to contain the password or any hash of it, though it should contain counter and/or timestamp, and be different for client and server.

Don't use MD5. While it is quite fast to compute, it has now a reputation as "broken" (because of quite fast collision attacks). While there is not yet a break which makes HMAC-MD5 attackable, better be save and use a better hash function, like one from the SHA-2 family (SHA-265 should be enough).

As said by Ilmari in a comment, a secure block cipher would not necessarily be harder to implement (or take more resources) than a secure hash function. Actually, many hash functions use some kind of block cipher internally in the compression function. You can construct a MAC from a block cipher (for example CMAC), too.