aboutsummaryrefslogtreecommitdiff
path: root/src/keyring.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyring.h')
-rw-r--r--src/keyring.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/keyring.h b/src/keyring.h
new file mode 100644
index 0000000..81d97fc
--- /dev/null
+++ b/src/keyring.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <QAbstractTableModel>
+#include <QFont>
+#include <QString>
+
+#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<KeyInfo> 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);