How do 6-digit codes work for Two-Factor Authentication?

137 views

So, I get that broadly the answer is “It’s an algorithm”, but I’d like to know more specifics if there are any.

For some websites/services, Two-Factor Authentication requires a (usually 6-digit) code to authenticate the user. This code changes frequently, usually every 30 seconds or so. The code generators for doing this are sometimes connected to internet/cell service, but they don’t have to be for a lot of authentication services.

I guess what I’m wondering is how a server is able to verify that my code of (for example, of course) 554-048 is now the code to authenticate my account, which I just obtained from a device that is not connected to any way of transmitting data, and that the previous code, 685-392 is no longer valid.

In: 4

2 Answers

Anonymous 0 Comments

When you register for app-based 2FA, you scan a QR code. That QR code essentially contains a giant password.

However, instead of ever transmitting that password back (because it could be intercepted in the process), you run that password through an algorithm, along with the current time (typically rounded down to 30 seconds). That algorithm will spit out a 6-digit number.

When the server checks, it will also compare the time + password (since it knows about it when you registered) using the same algorithm. If it matches, then you must have the original password, which means you have the original device you used to register.

Since the algorithm uses the current time, if anybody ever gets a peak at your 2FA app, those codes aren’t valid for very long, so it poses very little risk.

Anonymous 0 Comments

uh, because THEY sent the code to a second device, and are waiting for the SAME code they sent you?

Any randomly generated number works fine, they are just waiting for the SAME one they sent you.

A check-sum, on the other hand, is completely different. And rolling-code transmitters for apartment garage doors are different too.