Today I’m going to show you how to make an Arduino door lock that can be opened with an OTP code generated by your smartphone.
First, a short video about the project (english subtitles are available):
[youtube id=”AQuTeuIpuTg” width=”600″ height=”350″]
OTP (one-time password) is an access code you can use only one time: its main advantage is that – even if someone steals your code when you use it – it doesn’t work anymore.
Usually OTP codes also have a temporal validity, i.e. they can be used for a short period (tipically 30 seconds); those codes are called TOTP (time-based one-time password). OTP codes are widely used for secure access to home-banking websites, remote connections (VPN)…
In the past, the TOTP codes were usually generated by hardware tokens
but recently software tokens, that are smartphones applications, are becoming common:
OATH and Google Authenticator
Open Authentication (OATH) is an industry-wide collaboration to define open standards for strong authentication mechanisms. One of those standards (RFC 6238) defines an algorithm to generate TOTP codes.
The algorithm starts with a secret key (shared secret) and the actual timestamp (the number of seconds from the date 01/01/1970). With the use of an hash function (HMAC-SHA-1) on the key-timestamp pair and a truncate function on the result, you get a code of 6 numbers:
The algorithm requires therefore that the token (which generates the codes) and the server (which validates them)
- share the same secret key
- are in sync
Google Authenticator is an opensource application you can use to obtain TOTP codes that are compliant to the algorithm described by the RFC.
It’s available for Android, iOS and Blackberry smartphones:
Google Authenticator genrates OTP codes with a validity of 30 seconds and requires a private key of 10 characters.
In the next page, I’m going to show you how to generate and validate TOTP codes with Arduino…