Commit Graph

48 Commits (master)

Author SHA1 Message Date
Johan Ouwerkerk 3c0fc6201f test: bump limits to trigger confusion in QDateTime
The old values/test cases match behaviour on Debian, where the QDateTime
class gets confused at lower limits for the internal ms since epoch value
than it does on SUSE for some reason.
2021-07-27 20:50:18 +02:00
Johan Ouwerkerk 7fbad71cc3 chore: code quality fixups suggest by CI 2021-07-27 20:50:18 +02:00
Johan Ouwerkerk ea19844300 refactor: proxy commandline arguments
Add a 'proxy' to forward external API calls into the main application
control flow. Right now it only supports forwarding commandline
arguments, but this construct is already useful as a starting point for
future D-Bus API support.
2021-05-03 04:03:24 +00:00
Johan Ouwerkerk 653e0b4b44 chore: code fixups suggested by static analysis 2021-02-06 18:13:08 +01:00
Johan Ouwerkerk cbd069085e fix!: guard against incorrect password inputs using an encrypted challenge
Previously entering an incorrect password would appear to successfully "unlock" accounts, contrary to expectations.
By introducing a challenge object as part of the master key parameters, an incorrect password can now be detected and signalled accordingly.

This fix introduces a backwards incompatible change to the accounts data as stored on disk, meaning old Keysmith accounts configuration will no longer load and must be recreated from scratch.
2021-01-20 06:17:48 +00:00
Johan Ouwerkerk c31aa8df52 chore: perform some code cleanups suggested by clazy
These cleanups block the invalid password detection/retry UX feature from landing.

See-Also: https://invent.kde.org/utilities/keysmith/-/merge_requests/71
2020-11-23 21:45:30 +01:00
Johan Ouwerkerk 4ca180abf1 refactor: remove some duplicate mocking code, reuse existing fake random utility instead 2020-11-22 16:17:21 +01:00
Johan Ouwerkerk 369593f33d chore: clean up use of string.h includes. 2020-11-22 16:12:08 +01:00
Johan Ouwerkerk 4425795211 feat: add basic support for accepting otpauth:// URIs from the commandline
This change is a building block towards receiving decoded QR codes from other applications and adding corresponding accounts in Keysmith.

Issues: #7, #14
2020-10-27 18:08:31 +01:00
Johan Ouwerkerk 420198c49a feat: add basic support for otpauth:// URI parameter model
Add support converting an otpauth:// URI into a model object.
Validation is quite lax and focused on what Keysmith can recover from within the scope of UI/UX for adding accounts via QR codes.

See-Also: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
Issues: #14
2020-10-27 18:08:31 +01:00
Johan Ouwerkerk db51ce9e3f feat: add basic support for otpauth:// URI parsing
This change provides a bare minimum implementation to parse an otpauth:// type URI into its component parts.
Parsing is quite lax, and focused on what Keysmith can support or recover from in the intended UI/UX for adding accounts via QR codes.

See-Also: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
Issues: #14
2020-10-27 18:08:31 +01:00
Johan Ouwerkerk f1dbd0c4b7 feat: reduce apparent latency when re-computing tokens by computing the 'next' token in advance.
One downside of offloading the token computation to a worker thread and having to do token decryption is an increase in latency.
For the case with a few accounts this latency does not matter, but in case of many accounts it can induce a significant delay when refreshing tokens in the UI.

To hide this latency, when computing an OTP token for the current state of the account the logical 'next' token is also computed as well and cached in the Account object.
When the next (re)computation of the OTP token is requested, the cached 'next' value is reused if still valid before the next pair of tokens is being computed.
This way the apparent latency of a token update is reduced to an near immediate property update in the UI, hiding the actual latency of the computation itself.

This 'optimisation' is implemented in the dumbest possible fashion that can still work.
This means that the code complexity of the change is quite limited, at the cost of rougly doubling the actual work being performed in the worker thread.
2020-09-16 04:54:15 +00:00
Johan Ouwerkerk e782840847 refactor: extract signal spying to a top-level autotest utility. 2020-08-14 20:02:43 +02:00
Johan Ouwerkerk 668a969d4f refactor: rename unsigned integer parsing function
Make the name for unsigned integer parsing (counter validator) fit better with the new custom datetime validator.
2020-08-08 09:17:55 +02:00
Johan Ouwerkerk 170d7f1811 refactor: introduce custom datetime validator
This change is a preparation for allowing the user to configure custom epochs for TOTP tokens

Issues: #7
2020-08-08 09:17:55 +02:00
Johan Ouwerkerk 3ccafda3a1 refactor: adjust validator test macro to be able to inject arbitrary constructor parameters. 2020-08-08 09:17:55 +02:00
Johan Ouwerkerk 09df98d3a4 refactor: prepare AccountStorage for more complex tokens
With this the AccountStorage module now fully supports some HOTP/TOTP parameters which are uncommon (but still part of HOTP/TOTP specifications).

 - Better types for offset, tokenLength. Make this consistent throughout
 - Finish support for offset, checksum parameters for HOTP tokens in AccountStorage
 - Finish support for hashing algorithm, epoch parameters for TOTP tokens in AccountStorage
 - Better API for creating oath::Algorithm instances
 - Code formatting (break up long lines)

Issues: #7
2020-08-08 09:17:55 +02:00
Johan Ouwerkerk d358d8abcc feat: Support configuring the issuer when adding a new account in Keysmith.
With this change, issuers are now fully supported.

Resolves: #13
2020-07-23 18:24:13 +02:00
Johan Ouwerkerk 0d40912360 feat: Add basic support for account 'issuer' in Keysmith.
With this change account storage and model work with accounts for which an issuer is recorded.
This is a prerequisite for fully supporting otpauth:// URIs (necessary for QR code support) in Keysmith.

Issues: #7, #13
See-Also: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
2020-07-23 18:24:13 +02:00
Johan Ouwerkerk 60ceb2ce4a Fixup bitrot in account name validator autotests 2020-06-11 07:28:16 +00:00
Johan Ouwerkerk b70feaf620 Track loaded/error state of AccountStorage objects
Two bits of boolean state are introduces to track whether or not:

 - an error has occurred
 - accounts have been loaded from storage yet

This change paves the way for having error handling UX.
2020-04-24 18:05:05 +02:00
Johan Ouwerkerk 035348caa5 Implement encryption/decryption of token secrets
With this change token secrets are encrypted prior to writing them to
storage, and decrypted as and when needed to generate tokens. Additional
validation is performed to verify that token secrets can be decrypted
successfully when loading accounts from storage.

With this change issue #6 should finally be resolved.
2020-04-24 18:01:34 +02:00
Johan Ouwerkerk a90c16cf82 Extract faking SecureRandom to a reusable utility 2020-04-23 19:00:38 +02:00
Johan Ouwerkerk 4d966c3926 Add support for a master key in account storage
With this change an unlock stage is introduced to loading account storage.
Key derivation parameters for a master key are recorded, and the master
password may be supplied to "unlock" the account secret(s) in storage.

This change paves the way for actually decrypting encrypted account
secrets later, and finally solving issue #6.
2020-04-23 18:59:17 +02:00
Johan Ouwerkerk a9ed1507b2 Add support for encrypting/decrypting token secrets
Introduce a secrets library which implements the necessary crypto using
libsodium. This change provides the basic building blocks for resolving
issue #6.
2020-04-23 18:59:17 +02:00
Johan Ouwerkerk ecf3476faa Fix up outdated token length validation
Keysmith can generate up to 10 digit HOTP/TOTP tokens and with this change
token length validation also permits it.
2020-04-11 21:46:19 +02:00
Johan Ouwerkerk b451bd2556 Fix up licensing for REUSE compliance.
This adds licensing and copyright information where missing and normalises
existing licensing/copyright statements to SPDX metadata tags.
2020-04-10 13:34:31 +02:00
Johan Ouwerkerk 28454721df Do not fix up input during validation
This change is a workaround for behaviour of QML controls: when fixup is
called during input validation, the `acceptableInput` property is not
updated correctly.
2020-04-04 10:50:52 +02:00
Johan Ouwerkerk 6a06a2f5f0 Fixup HMAC key size sanity checking.
Key lengths should be checked against the output size of the hashing
algorithm (instead of block size, which was used previously).
2020-02-17 07:08:09 +00:00
Johan Ouwerkerk 8729b92b8b Provide a custom HOTP/TOTP primitives.
Provides a building block for re-implementing the HOTP/TOTP algorithms
without using oath-toolkit: see issue #9.
2020-02-08 14:46:55 +01:00
Johan Ouwerkerk 2fe3eb8083 Provide a custom HMAC implementation
Provide a building block towards re-implementing the HOTP/TOTP
algorithms without using oath-toolkit: see issue #9.

The hmac::compute function trades simplicity (having to pre-allocate
a scratch buffer) for avoding accidental leaks of key material
(security).

This particular trade-off will help with resolving issue #6.
2020-02-08 14:21:45 +01:00
Johan Ouwerkerk 26d6d62cbe Validate that an account secret is valid base32. 2020-02-08 14:21:45 +01:00
Johan Ouwerkerk ea81dafb8e Port base32 decoding away from liboath
Provide a custom base32 implementation; relates to issues: #9 and #6.

In particular being able to control memory allocation prior to
decoding base32 will help with resolving issue #6 in a (more) secure
fashion.
2020-02-08 14:21:45 +01:00
Johan Ouwerkerk a0caf83da2 Use the new Account models.
Drop the AccountDetailsPage instead of trying to update it: see issue #7

With this change issue #2 should be fixed
2020-01-28 06:49:06 +00:00
Johan Ouwerkerk a813810dfe Rewrite Account model(s) as a separate (sub)module within Keysmith, layered on top of the new Account (storage) module.
This fixes the model part in issue #2
2020-01-28 06:49:06 +00:00
Johan Ouwerkerk 0d5b792637 Rewrite Account (storage) management as a separate (sub)module within Keysmtih
This provides the ground work to finally fix issue #2
2020-01-28 06:49:06 +00:00
Yuri Chornoivan 6fada16de7 Fix minor EBN issues 2020-01-24 20:44:47 +02:00
Johan Ouwerkerk a5794e02da Refactor: turn the base32 wrapper into a static library
This library is meant for private use by Keysmith, to simplify linking to the base32 functionality in CMake files.
2019-12-28 06:40:31 +00:00
Friedrich W. H. Kossebau 7daddb524c Cleanup CMakeLists.txt a bit
* do cmake_minimum_required as first thing, as recommended
* bump KF to 5.37, first release with Kirigami (Qt 5.7 matching min dep)
* use KF5_MIN_VERSION also with ECM
* include KDE CMake settings as first
* remove unused cmake includes
* remove duplicated enable_testing()
* use correct KDEInstallDirs variables
2019-12-18 17:29:13 +01:00
Johan Ouwerkerk 68bd4dad00 Fix failing tests due to inconsistencies in French number formatting 2019-10-22 19:34:38 +02:00
Johan Ouwerkerk 543766b819 Introduce a validator for the HOTP counter field. 2019-10-02 21:56:58 +02:00
Johan Ouwerkerk d60cb92b21 Refactor: support injecting locales through test data 2019-10-02 21:34:33 +02:00
Johan Ouwerkerk 3bc3a14575 Introduce a validator for name input fields (account name). 2019-09-30 20:25:56 +02:00
Johan Ouwerkerk bccf2565b8 Refactor: extract the common logic/boilerplate of a validator test to a helper utility (header)
With this change adding tests for new validators will be much less work.
2019-09-29 19:51:00 +02:00
Johan Ouwerkerk eeeac7511c Introduce a custom base32 secret validator to perform input validation.
- Add a new static library "validator_lib" covering the "validators" namespace in C++
 - Introduce the Base32Validator to perform input field validation with fixup support
2019-09-29 12:48:25 +02:00
Johan Ouwerkerk 4fe0d069cd Add a test to check the TOTP implementation can (at least) generate the values from the RFC test vector correctly. 2019-09-11 09:40:44 +02:00
Johan Ouwerkerk 2d147e2427 Add a test to check the HOTP implementation can (at least) generate the values from the RFC test vector correctly. 2019-09-11 09:40:44 +02:00
Johan Ouwerkerk 6d7c56f94b Add autotests for validating the new base32 decoding utilities. 2019-09-11 09:40:44 +02:00