Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I think I knew how does two-factor authentication works.

  • I enter the password.
  • Server generate random number and send me it me by sms.
  • I enter this number.
  • Server check number I entered with number generated earlier.

But today I have found Authy (https://www.authy.com/) and it looks like I don't know how works this program and how works two-factor authentication.

Authy show me secret numbers without any connection with server. How can it do it ?

I can suppose that this numbers are not random. May be it is a some kind of number sequence where initial parameters let unambiguously know next number. May be this sequence is a function of time. Are I right ?

Is it secure ? Can I know next number if I know N previous numbers ?

share|improve this question
1  
Irrelevant of Authy (I am not familiar), your statement of understanding of two factor authentication is pretty mistaken. To begin with, SMS is not two factor, but it is out of band verification. Needs moar magik crypto dust. –  AviD Jan 1 at 10:48
add comment

2 Answers

up vote 2 down vote accepted

Authy show me secret numbers without any connection with server. How can it do it ?

Authy is using a one-time passcode (OTP) algorithm which come in a number of flavors, the two most popular being HMAC-based OTP (HOTP) and Time-based OTP (TOTP). Authy is using TOTP.

Both algorithms are essentially the same; they require some seed data and a counter to generate the next passcode in the series. HOTP implementations increment the counter each time the user requests/uses a passcode, TOTP increments the counter after a given time interval.

In Authy's case, when the user submits a passcode to the server, the server looks up the user's seed data, calculates the counter value based on the timestamp of the request and then generates the proper passcode. The server then checks that the generated passcode matches the user-submitted passcode.

Is it secure ? Can I know next number if I know N previous numbers ?

Yes and no, it depends on whether or not you trust the server's security.

Given N previous tokens an attacker still shouldn't be able to recover the seed data. However, these algorithms require the server to store the seed data for all of the users. If an attacker is able to compromise the database (through SQL injection, etc.) then they will be able to generate valid passcodes. This is what happened to RSA and their SecurID tokens (http://arstechnica.com/security/2011/06/rsa-finally-comes-clean-securid-is-compromised/)

Some companies like Duo Security (https://www.duosecurity.com/) and Twitter (https://blog.twitter.com/2013/login-verification-on-twitter-for-iphone-and-android) are tackling this issue by implementing challenge-response two-factor authentication with asymmetric key encryption. They only need to store public keys in this case, meaning that if their database is leaked an attacker doesn't have the private keys necessary to generate valid responses.

Disclaimer, I worked at Duo.


Updated based on questions in the comments

The algorithms (HOTP or TOTP) must be the same on the server and the client application?

The algorithm is identical, just the way the counter value is generated is different. If Google were HOTP and Authy wanted to support Google accounts, their app would have to generate and store the counter value differently from TOTP accounts.

Does HOTP client require connection with server to get next passcode (because it doesn't know how much requests was made from last time), while TOTP doesn't require it?

No, HOTP doesn't require a connection to work, but HOTP is generally not used because it's easy for the phone and server to fall out of sync.

Say both the server and app start out with a counter value of 0. The server usually has a window, maybe the next 10 passcodes, that it will consider valid. When the user submits a passcode, the server will compare the submitted passcode with the next 10 generated passcodes. If any of the 10 match, the server can update the stored counter value and remain in sync.

The problem though, is that the user may be able to generate too many passcodes in the app without using them. If the user is able to increment the counter beyond the passcode window size, then the server can no longer verify that the passcodes are valid.

share|improve this answer
    
Thanks for your answer! 1. The algorithms (HOTP or TOTP) must be the same on the server and the client application? For example, is it impossible that Google use HOTP on the server, but Authy use TOTP on iPhone, right? 2. Does HOTP client require connection with server to get next passcode (because it doesn't know how much requests was made from last time), while TOTP doesn't require it ? –  demas Jan 1 at 10:56
1  
No problem, my response was a bit too long for a comment, so I've updated the answer to include your follow up questions, cheers! –  JackWink Jan 1 at 16:06
add comment

It looks like it communicates using a simple REST API. In terms of how secure the tokens are -

The token is generated using a 1 way function (SHA-2) and a 256 Bits key. Even if the attacker had access to hundreds of Tokens, it would still be mathematically impossible for him to generate a new valid Token. If you are inclined to know more, Authy is based on RFC4426 ( http://www.ietf.org/rfc/rfc4226.txt ).

In short - Yes it uses a secure method to generate a token.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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