colematt / pyOTP

A Python 3 implementation of the IETF One-Time Password algorithms with QRCode recognition for provisioning
MIT License
0 stars 0 forks source link

Add unit tests #2

Open colematt opened 6 years ago

colematt commented 6 years ago

RFC 4226 and RFC 6238 both define test routines. This issue adds those tests using unittest

colematt commented 3 years ago

RFC 4226 test cases:

Secret = "12345678901234567890"

IntermediateValues = [0xcc93cf18508d94934c64b65d8ba7667fb7cde4b0,
                    0x75a48a19d4cbe100644e8ac1397eea747a2d33ab,
                    0x0bacb7fa082fef30782211938bc1c5e70416ff44,
                    0x66c28227d03a2d5529262ff016a1e6ef76557ece,
                    0xa904c900a64b35909874b33e61c5938a8e15ed1c,
                    0xa37e783d7b7233c083d4f62926c7a25f238d0316,
                    0xbc9cd28561042c83f219324d3c607256c03272ae,
                    0xa4fb960c0bc06e1eabb804e5b397cdc4b45596fa,
                    0x1b3c89f65e6c9e883012052823443f048b4332db,
                    0x1637409809a679dc698207310c8c7fc07290d9e5]
TruncatedValues = [0x4c93cf18,
                0x41397eea,
                0x82fef30,
                0x66ef7655,
                0x61c5938a,
                0x33c083d4,
                0x7256c032,
                0x4e5b397,
                0x2823443f,
                0x2679dc69]
HOTPValues = ["755224",
            "287082",
            "359152",
            "969429",
            "338314",
            "254676",
            "287922",
            "162583",
            "399871",
            "520489"]
colematt commented 3 years ago

RFC 6238 test cases:

Secret = "12345678901234567890"
X = 30
T0 = 0

UTCTimes = ["1970-01-01 00:00:59 UTC",
"2005-03-18 01:58:29 UTC",
"2005-03-18 01:58:31 UTC",
"2009-02-13 23:31:30 UTC",
"2033-05-18 03:33:20 UTC",
"2603-10-11 11:33:20 UTC"]
TValues = [0x0000000000000001,
    0x00000000023523EC,
    0x00000000023523ED,
    0x000000000273EF07,
    0x0000000003F940AA,
    0x0000000027BC86AA]
  SHA1Values = ["94287082",
          "07081804",
          "14050471",
          "89005924",
          "69279037",
          "65353130"]
SHA256Values = ["46119246",
            "68084774",
            "67062674",
            "91819424",
            "90698825",
            "77737706"]
SHA512Values = ["90693936",
            "25091201",
            "99943326",
            "93441116",
            "38618901",
            "47863826"]