#pragma once #include #include #include #include "ext_packet.h" // The sole reason I use a class here is because Qt demands it. At least, that's // my impression after reading the documentation. class KeyringModel : public QAbstractTableModel { Q_OBJECT public: explicit KeyringModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; void load_keys(void); static constexpr int KeyIDRole = 0x0100; private: struct KeyInfo { QByteArray id; QString name; QString bytes; }; QVector m_keys; }; enum class ResponseResult { success, invalid_password, inaccessible_keyring, corrupted_entry, unsupported_version, derivation_failed, decryption_failed, bad_curve_point, hardware_fault, invalid_pin, hardware_lockout, incompatible_arguments, }; enum class KeyringStorageType { invalid, software, hardware, }; struct KeyringKey { KeyringStorageType type = KeyringStorageType::invalid; QByteArray id; QByteArray public_key; QByteArray protected_secret; QString name; }; int keyring_initialize(void); int keyring_hardware_available(void); int generate_software_key(QStringView name, const QByteArray &password); int generate_hardware_key(QStringView name, const QByteArray &pin); KeyringKey acquire_keyring_key(QByteArrayView key_id); void delete_key(const QByteArray &key_id); ResponseResult unlock_and_auth(const KeyringKey &key, QByteArrayView password, QByteArrayView ephemeral_key, QByteArrayView username, AuthResponse &out);