[WIP, RFC] Add support for displaying TOTP keys as QR codes #964
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR is for adding the feature requested in #764. It is currently a work-in-progress.
What's pending (please provide feedback)
Decide how to include the qtqrencode dependency. I was thinking on using DownloadProject for having CMake include it as an external dependency. This approach proves beneficial in that the external dependency doesn't need to be included in the project source tree and yet it can be compiled using the same compiler flags and settings that are used for the project (as if it were a CMake subdirectory).Decide how to add support for a base32 encoder that complies with RFC 4648. We need this to generate QR codes in the "Key Uri Format" that is expected by authenticator apps such as Google Authenticator (read more on the Google Authenticator wiki). I was thinking on using the cppcodec library, but we need to figure out how to integrate it with Keepassxc, as their code uses C++ exceptions but Keepassxc is compiled using the-fno-exceptions
flag.Instead of using
qtqrencode
, a new class,QRCode
is placed insrc/core
for enabling support for QR code generation usinglibqrencode
. Besides not having another dependency, we have the benefit of not linking againstQt::QtSvg
--whichqtqrencode
requires.QR code size is selected automatically by
libqrencode
based on input data.QR code error correction level is set to its highest.
Our local base32 implementation is compliant with RFC 4648. Three new methods were added for compatibility with Google Authenticator's "Key Uri Format" (which requires no padding characters):
Motivation and context
This is best explained by #764.
How has this been tested?
Currently, it is build for testing using Fedora 26 and the following nix environment:
You need to enable the option:WITH_CX_TOTPSEED_QRCODE
You need to enable the option
WITH_CX_TOTPDISPLAYKEY
:mkdir build cd build cmake -DWITH_ASAN=ON -DWITH_XC_TOTPDISPLAYKEY=ON -DCMAKE_BUILD_TYPE=Debug ..
Test barcodes
Screenshots (if appropriate):
Below are two images that illustrate the proposed interface for this feature.
Note: you can actually read the barcode above! (Tested with the Ya.Key iOS app).
Types of changes
Checklist:
-DWITH_ASAN=ON
. [REQUIRED]