Is it possible to predict future 2FA values given older values with timestamps?

ⅰ亾dé卋堺 提交于 2020-07-03 10:01:12

问题


Is it safe to share 2FA codes? I'm talking about TOTP like Google Authenticator or Authy.

For example, if i have code and generation time, is it possible to predict new codes? What if i have more than 1 pair of code+time?

I think it's possible to predict new codes based on old information (code+time).

So if this is possible, how do I do it? Im looking for some algorithm.

Known Time period, time, code and secret length.

Example:

22:20:30 561918
22:21:00 161664
22:21:30 610130

回答1:


Internally, these 2FA generators usually work based on a time-based one-time password algorithm. Those algorithms work by using strong hash functions on a combination of two values: a shared secret and the current time increment, and specifically use a construction called HMAC that’s known to be secure provided the underlying hash function is.

As a result, if someone could predict future outputs of your 2FA device by seeing some timestamps and outputs from the 2FA device, then they would either (1) have to know the shared secret or (2) be able to break the HMAC. Both of these are unlikely unless someone either has hacked Google or knows of attacks on HMAC or the underlying hash function in ways beyond what’s in the public literature.

In other words, you shouldn’t need to worry about someone guessing future values given past values, though I’d still advise against giving out old values because you shouldn’t be giving out 2FA values to anyone except the site you’re logging into. :-)



来源:https://stackoverflow.com/questions/61263117/is-it-possible-to-predict-future-2fa-values-given-older-values-with-timestamps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!