Add yubikey param and DBus methods to unlock the database requiring yubikey #9251
+192
−31
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.
At the moment, we do not have the option to unlock the database in the GUI in case we use hmac-secret from YubiKey.
Let's add a yubikey parameter that will allow us to unlock the database using the Yubikey slot we specified, and add DBus methods that will allow us to do the same from other processes.
The code that I am adding maintains backward compatibility for all program parameters and DBus,and additional parameters in functions inside the code are optional, so I do not expect regression in existing use cases.
One of the main changes I had to add (because I didn't know how to solve it sensibly) is to disable the functionality of remembering the last key used to open a given database when using the --yubikey parameter. This is because in the case of a larger number of keys, asynchronous searches by Keepass for available keys created a conflict with my method of using yubikey from the --yubikey parameter. However, it does not affect the behavior of the program without this parameter.
I added two new DBus methods (openDatabaseYubiKey and listHardwareKeys) and extended the openDatabase method with an optional parameter to indicate the YubiKey slot
The listHardwareKeys parameter is used return a list of YubiKey slots available in the program.
I added the parameter openDatabaseYubiKey to maintain backward compatibility of the previous methods, and to give the possibility to unlock the database with just a password and yubikey (I don't like this way much, but I didn't have a better idea)
Screenshots
N/A
Testing strategy
Manual tests on existing databases:
Type of change