lachlanbell / SwiftOTP

A Swift library for generating One Time Passwords (OTP)
MIT License
285 stars 59 forks source link

Enforce positive numbers with UInt #29

Open ptrkstr opened 3 years ago

ptrkstr commented 3 years ago
ptrkstr commented 3 years ago

I saw your comment here @lachlanbell about UInt64 being in the spec but I couldn't see it. https://github.com/lachlanbell/SwiftOTP/issues/2#issuecomment-384644490

lachlanbell commented 3 years ago

Hi @ptrkstr, thanks for the PR!

Really sorry, I haven't had a chance to properly review this yet due to other commitments eating up almost all of my free time. I'll give this a proper look soon.

Regarding the spec, it mentions that the counter value C should be 8 bytes (=64 bits), so from a preliminary look I think UInt64 should still be used. The UInt64 type isn't hardware dependent, so it should work on 32-bit systems as well.

ptrkstr commented 3 years ago

Hey @lachlanbell, Thanks for the reply, no apology necessary :) Ahh great point, let me revert the UInt64 changes. I think there's value in the other changes I've made regarding UInt over Int to avoid a guard for negative number checking. I'll comment back when it's done.

ptrkstr commented 3 years ago

Hey @lachlanbell, I've reverted the UInt64 changes, ready for review.