keepassxc/src/sshagent/KeeAgentSettings.h

99 lines
3.4 KiB
C++
Raw Normal View History

2017-10-29 17:17:24 +02:00
/*
* Copyright (C) 2017 Toni Spets <toni.spets@iki.fi>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEAGENTSETTINGS_H
#define KEEAGENTSETTINGS_H
Replace all crypto libraries with Botan Selected the [Botan crypto library](https://github.com/randombit/botan) due to its feature list, maintainer support, availability across all deployment platforms, and ease of use. Also evaluated Crypto++ as a viable candidate, but the additional features of Botan (PKCS#11, TPM, etc) won out. The random number generator received a backend upgrade. Botan prefers hardware-based RNG's and will provide one if available. This is transparent to KeePassXC and a significant improvement over gcrypt. Replaced Argon2 library with built-in Botan implementation that supports i, d, and id. This requires Botan 2.11.0 or higher. Also simplified the parameter test across KDF's. Aligned SymmetricCipher parameters with available modes. All encrypt and decrypt operations are done in-place instead of returning new objects. This allows use of secure vectors in the future with no additional overhead. Took this opportunity to decouple KeeShare from SSH Agent. Removed leftover code from OpenSSHKey and consolidated the SSH Agent code into the same directory. Removed bcrypt and blowfish inserts since they are provided by Botan. Additionally simplified KeeShare settings interface by removing raw certificate byte data from the user interface. KeeShare will be further refactored in a future PR. NOTE: This PR breaks backwards compatibility with KeeShare certificates due to different RSA key storage with Botan. As a result, new "own" certificates will need to be generated and trust re-established. Removed YKChallengeResponseKeyCLI in favor of just using the original implementation with signal/slots. Removed TestRandom stub since it was just faking random numbers and not actually using the backend. TestRandomGenerator now uses the actual RNG. Greatly simplified Secret Service plugin's use of crypto functions with Botan.
2021-04-04 08:56:00 -04:00
#include "OpenSSHKey.h"
#include "core/Entry.h"
#include "core/EntryAttachments.h"
2017-10-29 17:17:24 +02:00
#include <QXmlStreamReader>
2018-03-31 16:01:30 -04:00
#include <QtCore>
2017-10-29 17:17:24 +02:00
class KeeAgentSettings
{
public:
KeeAgentSettings();
bool operator==(const KeeAgentSettings& other) const;
bool operator!=(const KeeAgentSettings& other) const;
bool isDefault() const;
void reset();
2017-10-29 17:17:24 +02:00
2018-03-31 16:01:30 -04:00
bool fromXml(const QByteArray& ba);
QByteArray toXml() const;
static bool inEntryAttachments(const EntryAttachments* attachments);
bool fromEntry(const Entry* entry);
void toEntry(Entry* entry) const;
bool keyConfigured() const;
bool toOpenSSHKey(const Entry* entry, OpenSSHKey& key, bool decrypt);
bool toOpenSSHKey(const QString& username,
const QString& password,
const QString& databasePath,
const EntryAttachments* attachments,
OpenSSHKey& key,
bool decrypt);
const QString errorString() const;
2017-10-29 17:17:24 +02:00
bool allowUseOfSshKey() const;
bool addAtDatabaseOpen() const;
bool removeAtDatabaseClose() const;
bool useConfirmConstraintWhenAdding() const;
bool useLifetimeConstraintWhenAdding() const;
int lifetimeConstraintDuration() const;
const QString selectedType() const;
const QString attachmentName() const;
bool saveAttachmentToTempFile() const;
const QString fileName() const;
const QString fileNameEnvSubst(QProcessEnvironment environment = QProcessEnvironment::systemEnvironment()) const;
2017-10-29 17:17:24 +02:00
void setAllowUseOfSshKey(bool allowUseOfSshKey);
void setAddAtDatabaseOpen(bool addAtDatabaseOpen);
void setRemoveAtDatabaseClose(bool removeAtDatabaseClose);
void setUseConfirmConstraintWhenAdding(bool useConfirmConstraintWhenAdding);
void setUseLifetimeConstraintWhenAdding(bool useLifetimeConstraintWhenAdding);
void setLifetimeConstraintDuration(int lifetimeConstraintDuration);
void setSelectedType(const QString& type);
void setAttachmentName(const QString& attachmentName);
void setSaveAttachmentToTempFile(bool);
void setFileName(const QString& fileName);
private:
bool readBool(QXmlStreamReader& reader);
int readInt(QXmlStreamReader& reader);
bool m_allowUseOfSshKey;
bool m_addAtDatabaseOpen;
bool m_removeAtDatabaseClose;
bool m_useConfirmConstraintWhenAdding;
bool m_useLifetimeConstraintWhenAdding;
int m_lifetimeConstraintDuration;
2017-10-29 17:17:24 +02:00
// location
QString m_selectedType;
2017-10-29 17:17:24 +02:00
QString m_attachmentName;
bool m_saveAttachmentToTempFile;
2017-10-29 17:17:24 +02:00
QString m_fileName;
QString m_error;
2017-10-29 17:17:24 +02:00
};
#endif // KEEAGENTSETTINGS_H