Is there any way to read/write a database's public custom data from a key provider?
I'm trying to modify KeeChallenge so that it doesn't require a separate xml file.
In the following code, I pass the IPluginHost to the key provider.
Setting the title text of the main KeePass window using m_host.MainWindow.Text works.
The data seems to be added but is not actually saved with the database. GetString returns the expected string only when SetString is not commented out.
The process of opening a database file is the following:
KeePass obtains the path (and server credentials) of the database file to open (e.g. via the 'Open File' dialog, the command line, ...).
The master key dialog is displayed (showing the database file path).
KeePass tries to read and decrypt the database file.
The key provider's GetKey method is invoked in step 2, before actually reading the file. So, the public custom data that you're accessing in your example code is either the public custom data of a different or of an empty database, but definitely not the one of the file that will be read in step 3.
I'm not planning to change the file opening process (primarily due to keeping a file open for a longer time or opening it multiple times can be problematic with some servers). If you really want to use public custom data for this, you'd need to read and parse the KDBX header in your plugin yourself.
Best regards,
Dominik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For OtpKeyProv, I'll continue using an auxiliary file. The auxiliary file changes each time the user opens the database (because it needs to be updated for the next one-time passwords), and when the database file is huge, writing a new small auxiliary file is far more efficient than writing a new database file each and every time.
Best regards,
Dominik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any way to read/write a database's public custom data from a key provider?
I'm trying to modify KeeChallenge so that it doesn't require a separate xml file.
In the following code, I pass the IPluginHost to the key provider.
Setting the title text of the main KeePass window using
m_host.MainWindow.Textworks.The data seems to be added but is not actually saved with the database.
GetStringreturns the expected string only whenSetStringis not commented out.Not really.
The process of opening a database file is the following:
The key provider's
GetKeymethod is invoked in step 2, before actually reading the file. So, the public custom data that you're accessing in your example code is either the public custom data of a different or of an empty database, but definitely not the one of the file that will be read in step 3.I'm not planning to change the file opening process (primarily due to keeping a file open for a longer time or opening it multiple times can be problematic with some servers). If you really want to use public custom data for this, you'd need to read and parse the KDBX header in your plugin yourself.
Best regards,
Dominik
Thanks for your response. I guess I'll be parsing the header myself.
For OtpKeyProv, I'll continue using an auxiliary file. The auxiliary file changes each time the user opens the database (because it needs to be updated for the next one-time passwords), and when the database file is huge, writing a new small auxiliary file is far more efficient than writing a new database file each and every time.
Best regards,
Dominik