Esempio n. 1
0
        public void VerifyKeys(string secret, ulong counter, string code)
        {
            var authenticator = new CounterAuthenticator();
            var base32Secret  = Base32Encoding.ToString(Encoding.ASCII.GetBytes(secret));

            Assert.IsTrue(authenticator.CheckCode(base32Secret, code, counter));
        }
Esempio n. 2
0
        public void CreateKey()
        {
            var authenticator = new CounterAuthenticator();
            var secret        = Authenticator.GenerateKey();
            var code          = authenticator.GetCode(secret, 0uL);

            Assert.IsTrue(authenticator.CheckCode(secret, code, 0uL), "Generated Code doesn't verify");
        }
Esempio n. 3
0
        public void VerifyUsedCounter()
        {
            var authenticator = new CounterAuthenticator();

            // Test Values from http://www.ietf.org/rfc/rfc4226.txt - Appendix D
            var base32Secret = Base32Encoding.ToString(Encoding.ASCII.GetBytes("12345678901234567890"));

            ulong usedCounter;

            Assert.True(authenticator.CheckCode(base32Secret, "520489", 0uL, out usedCounter));

            Assert.AreEqual(usedCounter, 9uL);
        }