google / google-authenticator

Open source version of Google Authenticator (except the Android app)
Apache License 2.0
5.19k stars 968 forks source link

(Android) Codes are incorrectly generated because Math.pow() is inaccurate #395

Closed ThomasHabets closed 9 years ago

ThomasHabets commented 9 years ago

Original issue 396 created by RTitlestad on 2014-06-28T15:10:21.000Z:

My Zest T1 generates codes which are incorrect because the calculation of 10^6 using (int) Math.pow() in PasscodeGenerator comes to 999 999 instead of 1 000 000.

I've cloned the repo and committed a fix based on RFC 6238 here: https://code.google.com/r/rtitlestad-math-pow-fix/

ThomasHabets commented 9 years ago

Not applicable to this product. Please reopen in https://github.com/google/google-authenticator-android if applicable.

ThomasHabets commented 9 years ago

Comment #1 originally posted by RTitlestad on 2014-06-28T15:12:17.000Z:

Here's the specific revision: https://code.google.com/r/rtitlestad-math-pow-fix/source/detail?r=44d6789c0a94483d7d8a1b1021d5683ebf156772

ThomasHabets commented 9 years ago

Comment #2 originally posted by ludek.rasek@r73.info on 2014-09-07T19:28:24.000Z:

Same issue with Doogee DG800. I tested the fix suggested by the issue reporter.

ThomasHabets commented 9 years ago

Comment #3 originally posted by quijar on 2014-09-12T01:46:55.000Z:

Thanks Rowan, I use your fix and now generate valid codes.

ThomasHabets commented 9 years ago

Comment #4 originally posted by BassRuan on 2014-09-13T15:52:07.000Z:

Hi guys

My Zest T1 does exactly the same thing. I checked out the fix, but i'm not sure how it works. Can you please explain to me how to apply this fix?

Thanks

ThomasHabets commented 9 years ago

Comment #5 originally posted by dick.greeven@greevenservices.com on 2014-09-25T15:03:08.000Z:

Same issue with Doogee DG310. Please explain how to appy the fix. TIA.

ThomasHabets commented 9 years ago

Comment #6 originally posted by jeremie.broutier on 2014-09-25T17:26:29.000Z:

Hi,

I had the same problem with my Alcatel OneTouch Pop S7. I built the app including the fix, for KitKat devices, because my device is running Android 4.2.2 and i think sharing it can be usefull.

ThomasHabets commented 9 years ago

Comment #7 originally posted by BassRuan on 2014-09-26T07:06:18.000Z:

Hi

Thanks for sharing your .apk. This is a big help. Tested : working.

Kind Regards

ThomasHabets commented 9 years ago

Comment #8 originally posted by dick.greeven@greevenservices.com on 2014-09-26T08:22:47.000Z:

Hi

Thanks indeed. Works like a charm. Makes my life a little bit easier and my accounts a little bit more safe.

Best regards