Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdolfo E. GarcĂ­a <adolfo.garcia.cr@gmail.com>2017-10-15 07:54:20 +0300
committerJanek Bevendorff <janek@jbev.net>2017-10-21 14:15:02 +0300
commit19eb6a8a60afed2da5733a2eef47de80009f824f (patch)
tree0bb442d17d4554fb78e40c2597ced785d5d37a15 /tests/TestTotp.cpp
parent85f652290b48a2178fef65678889313d838c0f22 (diff)
Add new Base32 implementation
Diffstat (limited to 'tests/TestTotp.cpp')
-rw-r--r--tests/TestTotp.cpp29
1 files changed, 5 insertions, 24 deletions
diff --git a/tests/TestTotp.cpp b/tests/TestTotp.cpp
index e22c2567e..48ff88144 100644
--- a/tests/TestTotp.cpp
+++ b/tests/TestTotp.cpp
@@ -18,15 +18,14 @@
#include "TestTotp.h"
+#include <QDateTime>
#include <QTest>
+#include <QTextCodec>
#include <QTime>
-#include <QDateTime>
#include <QtEndian>
-#include <QTextCodec>
#include "crypto/Crypto.h"
#include "totp/totp.h"
-#include "totp/base32.h"
QTEST_GUILESS_MAIN(TestTotp)
@@ -35,12 +34,13 @@ void TestTotp::initTestCase()
QVERIFY(Crypto::init());
}
-
void TestTotp::testParseSecret()
{
quint8 digits = 0;
quint8 step = 0;
- QString secret = "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30";
+ QString secret = "otpauth://totp/"
+ "ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm="
+ "SHA1&digits=6&period=30";
QCOMPARE(QTotp::parseOtpString(secret, digits, step), QString("HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ"));
QCOMPARE(digits, quint8(6));
QCOMPARE(step, quint8(30));
@@ -60,25 +60,6 @@ void TestTotp::testParseSecret()
QCOMPARE(step, quint8(30));
}
-void TestTotp::testBase32()
-{
- QByteArray key = QString("JBSW Y3DP EB3W 64TM MQXC 4LQA").toLatin1();
- QByteArray secret = Base32::base32_decode(key);
- QCOMPARE(QString::fromLatin1(secret), QString("Hello world..."));
-
- key = QString("gezdgnbvgy3tqojqgezdgnbvgy3tqojq").toLatin1();
- secret = Base32::base32_decode(key);
- QCOMPARE(QString::fromLatin1(secret), QString("12345678901234567890"));
-
- key = QString("ORSXG5A=").toLatin1();
- secret = Base32::base32_decode(key);
- QCOMPARE(QString::fromLatin1(secret), QString("test"));
-
- key = QString("MZXW6YTBOI======").toLatin1();
- secret = Base32::base32_decode(key);
- QCOMPARE(QString::fromLatin1(secret), QString("foobar"));
-}
-
void TestTotp::testTotpCode()
{
// Test vectors from RFC 6238