Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Increase max TOTP step to 24 hours #9149

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/gui/TotpSetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ TotpSetupDialog::TotpSetupDialog(QWidget* parent, Entry* entry)
{
m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
setFixedSize(sizeHint());

connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/TotpSetupDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<number>1</number>
</property>
<property name="maximum">
<number>60</number>
<number>86400</number>
</property>
<property name="value">
<number>30</number>
Expand Down
2 changes: 1 addition & 1 deletion src/totp/totp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ QSharedPointer<Totp::Settings> Totp::parseSettings(const QString& rawSettings, c

// Bound digits and step
settings->digits = qBound(1u, settings->digits, 10u);
settings->step = qBound(1u, settings->step, 60u);
settings->step = qBound(1u, settings->step, 86400u);

// Detect custom settings, used by setup GUI
if (settings->encoder.shortName.isEmpty()
Expand Down
6 changes: 6 additions & 0 deletions tests/TestTotp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ void TestTotp::testParseSecret()
QCOMPARE(settings->step, 30u);
QCOMPARE(settings->algorithm, Totp::Algorithm::Sha512);

// Max TOTP step of 24-hours
secret.replace("period=30", "period=90000");
settings = Totp::parseSettings(secret);
QVERIFY(!settings.isNull());
QCOMPARE(settings->step, 86400u);

// KeeOTP Parsing
secret = "key=HXDMVJECJJWSRBY%3d&step=25&size=8&otpHashMode=Sha256";
settings = Totp::parseSettings(secret);
Expand Down