#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, }; int keyring_initialize(void); int generate_key(QStringView name, const QByteArray &password); void delete_key(const QByteArray &key_id); ResponseResult unlock_and_auth(QByteArrayView key_id, QByteArrayView password, QByteArrayView ephemeral_key, QByteArrayView username, AuthResponse &out);