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'd like to implement multi factor authentication on a few projects.

Now the first factor would be username and password, for the second factor I would like to use a token generator.

These tokens would be 6 characters long and generated by a device that the user carries (like a phone or special device)

But... I have no idea how a token generator works and how to implement it. (so I'm here to learn)

I would eventually like to build a phone app to do the token generation and a website (php) where the use would login.

Can anyone please give me some pointers in the right direction on how these algorithms work?

share|improve this question
add comment

6 Answers

up vote 6 down vote accepted

Drawing it up from scratch, for disconnected tokens you have a few options. They can be

  • counter-based -- a new password with every press and the authenticating system doesn't allow anything at least as old as the last used password.
  • time-based -- the algorithm factors in the current time and the server doesn't allow anything other than present, the minute before, and the next minute (or possibly a slightly wider window). Requires good time sync.

You need to seed an unpredictable sequence based algorithm with a secret shared value and either the time or your counter. hash(time . secret) or such. Using SHA-256 and chopping off some bits would be effective.

Strength comparisons:

  • RSA token -- 8 numeric digits, 10^8. (one in a hundred million)
  • Six numeric digits, 10^6. (one in a million)
  • Six alpha-numeric, 2.1x10^9 (one in 2 billion)
  • Six alpha-numeric, with caps: 5.6x10^10 (one in 56 billion)

See also:

share|improve this answer
add comment

I'm currently using a solution from Billion for two-factor authentication. But at least in our setup it requires windows computers. So I'm a bit curious on the Yubikey. Here are some more info.

http://www.grennan.com/?p=170

http://code.google.com/p/yubico-pam/wiki/ReadMe

share|improve this answer
add comment

I'm currently using the Google Authenticator as my OTP token of choice. (http://code.google.com/p/google-authenticator/)

If you are new to this, I recommend reading up on the OATH Initiative (http://www.openauthentication.org/). This ground has been well paved, good luck!

Mike

share|improve this answer
add comment

You want to create a one-time password by hashing a key and counter (or timestamp). The token generator hashes the key and counter, truncates the result into 6 characters, and increments the counter. The server does the same to compare.

HOTP is a common algorithm with a counter, TOTP is one that uses a timestamp. One advantage of these is that hardware and software token generators are available for them.

Generating the token is the easy part; authenticating securely and reliably with that token is trickier. Duo Security has open source clients for use with our two-factor service, and they might be useful for reference: https://github.com/duosecurity. Disclaimer, I am a Duo employee.

share|improve this answer
add comment

Some important ancilary design considerations.

Single user or multi-user?

If this is a pet project just for you then a lot of support tasks are easy. However, if this is a multiuser system, then you need to consider more factors.

Unified token or per-person token?

A unified token is a token that provides equivelent authentication for all users. That is even if there are multiple physical devices, any user may use any physical device for authentication. This is convenient for support, but weak for authentication. On the other hand a per-user token may only be used by a specified user. Each user must be uniquely assigned to a different physical token device. If the user looses or damages the device the user must be assigned to a new physical device. Per-user provides stronger authentication, but operational support is more expensive.

Authentication system parameters.

There are some critical parameters such as delay between failed authentication and next authentication prompt. This fail delay helps protect against online attacks where the attacker has obtained the username and password, but does not have a valid token device. Another parameter is the number of failed attempts until the account is temporarily disabled. Adding the the previous setting is the temporary disabled time. That is how long after n failed attempts should the account be temporarily disabled.

Token device protection

Since the token device is an authentication component, the token device will be a tempting target for attackers. If you are thinking of using a mobile phone or smart phone, you need to think about how you will protect the token generating software from attempts to monitor or disrupt it. If your device is a custom device, what communication channels will it have (USB, Ethernet, RS-232) and how will those enable an attacker to analyze or modify the device?

share|improve this answer
    
wow these are some great points! I've been working on a few tests, this whole project is to build a maximum security login system for future projects. –  HTDutchy Oct 11 '11 at 8:41
1  
Maximum security is extremely expensive in terms of dollars and in terms of resources. Strong integrity and confidentiality typically reduce an assets availability. I suggest you design the security proportional to the value of the assets you intend to protect. –  this.josh Oct 11 '11 at 15:09
    
lets just say the best I can? –  HTDutchy Oct 11 '11 at 16:23
    
It's not the best you can; it's the most your users are willing to tolerate before circumventing or abandoning your system. Requiring physical presence (no-network) provides great mitigation of exposure, but most users demand the ability to access your system remotely. –  this.josh Oct 11 '11 at 20:53
add comment

I would second looking into OATH, google authenticator uses it, as well as yubikey ( http://www.yubico.com/yubikey ). Actually, yubikeys can be programmed to do a few different algorithms, as well as TOTP with a helper windows application.

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.