1
0
Fork 0
forked from blue/squawk

some initial work and thoughts about encryption

This commit is contained in:
Blue 2023-01-01 20:25:51 +03:00
parent 758a9d95f3
commit b45a73b723
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
12 changed files with 342 additions and 18 deletions

View file

@ -26,4 +26,6 @@ target_sources(squawk PRIVATE
form.cpp
field.h
field.cpp
keyinfo.cpp
keyinfo.h
)

View file

@ -127,23 +127,28 @@ Q_ENUM_NS(Support)
enum class TrustLevel {
/// The key's trust is not decided.
Undecided,
undecided,
/// The key is automatically distrusted (e.g., by the security policy TOAKAFA).
/// \see SecurityPolicy
AutomaticallyDistrusted,
automaticallyDistrusted,
/// The key is manually distrusted (e.g., by clicking a button or \xep{0450, Automatic Trust
/// Management (ATM)}).
ManuallyDistrusted,
manuallyDistrusted,
/// The key is automatically trusted (e.g., by the client for all keys of a bare JID until one
/// of it is authenticated).
AutomaticallyTrusted,
automaticallyTrusted,
/// The key is manually trusted (e.g., by clicking a button).
ManuallyTrusted,
manuallyTrusted,
/// The key is authenticated (e.g., by QR code scanning or \xep{0450, Automatic Trust
/// Management (ATM)}).
Authenticated
authenticated
};
Q_ENUM_NS(TrustLevel)
enum class EncryptionProtocol {
omemo
};
Q_ENUM_NS(EncryptionProtocol)
}
#endif // SHARED_ENUMS_H

46
shared/keyinfo.cpp Normal file
View file

@ -0,0 +1,46 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 3 of the License, or
// (at your option) any later version.
//
// 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/>.
#include "keyinfo.h"
using namespace Shared;
Shared::KeyInfo::KeyInfo(
uint32_t p_id,
const QByteArray& p_fingerPrint,
const QString& p_label,
Shared::TrustLevel p_trustLevel,
Shared::EncryptionProtocol p_protocol,
bool p_currentDevice
):
id(p_id),
fingerPrint(p_fingerPrint),
label(p_label),
trustLevel(p_trustLevel),
protocol(p_protocol),
currentDevice(p_currentDevice)
{
}
Shared::KeyInfo::KeyInfo():
id(0),
fingerPrint(),
label(),
trustLevel(TrustLevel::Undecided),
protocol(EncryptionProtocol::omemo),
currentDevice(false)
{
}

55
shared/keyinfo.h Normal file
View file

@ -0,0 +1,55 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 3 of the License, or
// (at your option) any later version.
//
// 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 SHARED_KEYINFO_H
#define SHARED_KEYINFO_H
#include <QString>
#include <QByteArray>
#include <stdint.h>
#include "enums.h"
namespace Shared {
class KeyInfo
{
public:
KeyInfo(
uint32_t id,
const QByteArray&
fingerPrint,
const QString& label,
TrustLevel trustLevel,
EncryptionProtocol protocol = EncryptionProtocol::omemo,
bool currentDevice = false
);
KeyInfo();
private:
uint32_t id;
QByteArray fingerPrint;
QString label;
TrustLevel trustLevel;
EncryptionProtocol protocol;
bool currentDevice;
};
}
#endif // SHARED_KEYINFO_H

View file

@ -26,5 +26,6 @@
#include "messageinfo.h"
#include "utils.h"
#include "vcard.h"
#include "keyinfo.h"
#endif // SHARED_H