Formatting the code.

This commit is contained in:
Louis-Bertrand Varin 2018-03-31 16:01:30 -04:00
parent 74efc57369
commit 8324d03f0a
294 changed files with 3796 additions and 3740 deletions

View file

@ -19,10 +19,11 @@
#include "ASN1Key.h"
#include <gcrypt.h>
namespace {
constexpr quint8 TAG_INT = 0x02;
constexpr quint8 TAG_SEQUENCE = 0x30;
constexpr quint8 KEY_ZERO = 0x0;
namespace
{
constexpr quint8 TAG_INT = 0x02;
constexpr quint8 TAG_SEQUENCE = 0x30;
constexpr quint8 KEY_ZERO = 0x0;
bool nextTag(BinaryStream& stream, quint8& tag, quint32& len)
{
@ -103,7 +104,8 @@ namespace {
mpi_invm(u, q, p);
iqmp_hex.resize((bap.length() + 1) * 2);
gcry_mpi_print(GCRYMPI_FMT_HEX, reinterpret_cast<unsigned char*>(iqmp_hex.data()), iqmp_hex.length(), nullptr, u);
gcry_mpi_print(
GCRYMPI_FMT_HEX, reinterpret_cast<unsigned char*>(iqmp_hex.data()), iqmp_hex.length(), nullptr, u);
gcry_mpi_release(u);
gcry_mpi_release(p);
@ -121,7 +123,7 @@ bool ASN1Key::parseDSA(QByteArray& ba, OpenSSHKey& key)
return false;
}
QByteArray p,q,g,y,x;
QByteArray p, q, g, y, x;
readInt(stream, p);
readInt(stream, q);
readInt(stream, g);
@ -156,7 +158,7 @@ bool ASN1Key::parseRSA(QByteArray& ba, OpenSSHKey& key)
return false;
}
QByteArray n,e,d,p,q,dp,dq,qinv;
QByteArray n, e, d, p, q, dp, dq, qinv;
readInt(stream, n);
readInt(stream, e);
readInt(stream, d);

View file

@ -27,7 +27,6 @@ AgentSettingsPage::AgentSettingsPage(DatabaseTabWidget* tabWidget)
AgentSettingsPage::~AgentSettingsPage()
{
}
QString AgentSettingsPage::name()

View file

@ -19,8 +19,8 @@
#ifndef AGENTSETTINGSPAGE_H
#define AGENTSETTINGSPAGE_H
#include "gui/SettingsWidget.h"
#include "gui/DatabaseTabWidget.h"
#include "gui/SettingsWidget.h"
class AgentSettingsPage : public ISettingsPage
{

View file

@ -17,8 +17,8 @@
*/
#include "AgentSettingsWidget.h"
#include "ui_AgentSettingsWidget.h"
#include "core/Config.h"
#include "ui_AgentSettingsWidget.h"
AgentSettingsWidget::AgentSettingsWidget(QWidget* parent)
: QWidget(parent)

View file

@ -19,10 +19,11 @@
#ifndef AGENTSETTINGSWIDGET_H
#define AGENTSETTINGSWIDGET_H
#include <QWidget>
#include <QScopedPointer>
#include <QWidget>
namespace Ui {
namespace Ui
{
class AgentSettingsWidget;
}

View file

@ -23,7 +23,6 @@ BinaryStream::BinaryStream(QObject* parent)
: QObject(parent)
, m_timeout(-1)
{
}
BinaryStream::BinaryStream(QIODevice* device)
@ -31,7 +30,6 @@ BinaryStream::BinaryStream(QIODevice* device)
, m_timeout(-1)
, m_device(device)
{
}
BinaryStream::BinaryStream(QByteArray* ba, QObject* parent)
@ -105,7 +103,7 @@ bool BinaryStream::read(QByteArray& ba)
bool BinaryStream::read(quint32& i)
{
if (read(reinterpret_cast<char *>(&i), sizeof(i))) {
if (read(reinterpret_cast<char*>(&i), sizeof(i))) {
i = qFromBigEndian<quint32>(i);
return true;
}
@ -115,7 +113,7 @@ bool BinaryStream::read(quint32& i)
bool BinaryStream::read(quint16& i)
{
if (read(reinterpret_cast<char *>(&i), sizeof(i))) {
if (read(reinterpret_cast<char*>(&i), sizeof(i))) {
i = qFromBigEndian<quint16>(i);
return true;
}
@ -125,24 +123,24 @@ bool BinaryStream::read(quint16& i)
bool BinaryStream::read(quint8& i)
{
return read(reinterpret_cast<char *>(&i), sizeof(i));
return read(reinterpret_cast<char*>(&i), sizeof(i));
}
bool BinaryStream::readString(QByteArray& ba)
{
quint32 length;
quint32 length;
if (!read(length)) {
return false;
}
if (!read(length)) {
return false;
}
ba.resize(length);
ba.resize(length);
if (!read(ba.data(), ba.length())) {
return false;
}
if (!read(ba.data(), ba.length())) {
return false;
}
return true;
return true;
}
bool BinaryStream::readString(QString& str)
@ -157,7 +155,6 @@ bool BinaryStream::readString(QString& str)
return true;
}
bool BinaryStream::write(const char* ptr, qint64 size)
{
if (m_device->write(ptr, size) < 0) {
@ -186,18 +183,18 @@ bool BinaryStream::write(const QByteArray& ba)
bool BinaryStream::write(quint32 i)
{
i = qToBigEndian<quint32>(i);
return write(reinterpret_cast<char *>(&i), sizeof(i));
return write(reinterpret_cast<char*>(&i), sizeof(i));
}
bool BinaryStream::write(quint16 i)
{
i = qToBigEndian<quint16>(i);
return write(reinterpret_cast<char *>(&i), sizeof(i));
return write(reinterpret_cast<char*>(&i), sizeof(i));
}
bool BinaryStream::write(quint8 i)
{
return write(reinterpret_cast<char *>(&i), sizeof(i));
return write(reinterpret_cast<char*>(&i), sizeof(i));
}
bool BinaryStream::writeString(const QByteArray& ba)

View file

@ -19,9 +19,9 @@
#ifndef BINARYSTREAM_H
#define BINARYSTREAM_H
#include <QObject>
#include <QIODevice>
#include <QBuffer>
#include <QIODevice>
#include <QObject>
class BinaryStream : QObject
{

View file

@ -30,13 +30,11 @@ KeeAgentSettings::KeeAgentSettings()
, m_saveAttachmentToTempFile(false)
, m_fileName(QString())
{
}
bool KeeAgentSettings::operator==(KeeAgentSettings& other)
{
return (m_allowUseOfSshKey == other.m_allowUseOfSshKey
&& m_addAtDatabaseOpen == other.m_addAtDatabaseOpen
return (m_allowUseOfSshKey == other.m_allowUseOfSshKey && m_addAtDatabaseOpen == other.m_addAtDatabaseOpen
&& m_removeAtDatabaseClose == other.m_removeAtDatabaseClose
&& m_useConfirmConstraintWhenAdding == other.m_useConfirmConstraintWhenAdding
&& m_useLifetimeConstraintWhenAdding == other.m_useLifetimeConstraintWhenAdding

View file

@ -19,8 +19,8 @@
#ifndef KEEAGENTSETTINGS_H
#define KEEAGENTSETTINGS_H
#include <QtCore>
#include <QXmlStreamReader>
#include <QtCore>
class KeeAgentSettings
{
@ -31,7 +31,7 @@ public:
bool operator!=(KeeAgentSettings& other);
bool isDefault();
bool fromXml(const QByteArray &ba);
bool fromXml(const QByteArray& ba);
QByteArray toXml();
bool allowUseOfSshKey() const;

View file

@ -18,10 +18,10 @@
#include "OpenSSHKey.h"
#include "ASN1Key.h"
#include "crypto/SymmetricCipher.h"
#include <QCryptographicHash>
#include <QRegularExpression>
#include <QStringList>
#include <QCryptographicHash>
#include "crypto/SymmetricCipher.h"
const QString OpenSSHKey::TYPE_DSA = "DSA PRIVATE KEY";
const QString OpenSSHKey::TYPE_RSA = "RSA PRIVATE KEY";
@ -30,7 +30,7 @@ const QString OpenSSHKey::TYPE_OPENSSH = "OPENSSH PRIVATE KEY";
// bcrypt_pbkdf.cpp
int bcrypt_pbkdf(const QByteArray& pass, const QByteArray& salt, QByteArray& key, quint32 rounds);
OpenSSHKey::OpenSSHKey(QObject *parent)
OpenSSHKey::OpenSSHKey(QObject* parent)
: QObject(parent)
, m_type(QString())
, m_cipherName(QString("none"))
@ -43,7 +43,6 @@ OpenSSHKey::OpenSSHKey(QObject *parent)
, m_comment(QString())
, m_error(QString())
{
}
OpenSSHKey::OpenSSHKey(const OpenSSHKey& other)
@ -58,7 +57,6 @@ OpenSSHKey::OpenSSHKey(const OpenSSHKey& other)
, m_comment(other.m_comment)
, m_error(other.m_error)
{
}
bool OpenSSHKey::operator==(const OpenSSHKey& other) const

View file

@ -19,8 +19,8 @@
#ifndef OPENSSHKEY_H
#define OPENSSHKEY_H
#include <QtCore>
#include "BinaryStream.h"
#include <QtCore>
class OpenSSHKey : QObject
{

View file

@ -28,7 +28,8 @@
SSHAgent* SSHAgent::m_instance;
SSHAgent::SSHAgent(QObject* parent) : QObject(parent)
SSHAgent::SSHAgent(QObject* parent)
: QObject(parent)
{
#ifndef Q_OS_WIN
m_socketPath = QProcessEnvironment::systemEnvironment().value("SSH_AUTH_SOCK");
@ -108,7 +109,8 @@ bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
return false;
}
QByteArray mapName = (QString("SSHAgentRequest") + reinterpret_cast<intptr_t>(QThread::currentThreadId())).toLatin1();
QByteArray mapName =
(QString("SSHAgentRequest") + reinterpret_cast<intptr_t>(QThread::currentThreadId())).toLatin1();
HANDLE handle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, AGENT_MAX_MSGLEN, mapName.data());
@ -125,8 +127,8 @@ bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
return false;
}
quint32 *requestLength = reinterpret_cast<quint32*>(ptr);
void *requestData = reinterpret_cast<void*>(reinterpret_cast<char*>(ptr) + 4);
quint32* requestLength = reinterpret_cast<quint32*>(ptr);
void* requestData = reinterpret_cast<void*>(reinterpret_cast<char*>(ptr) + 4);
*requestLength = qToBigEndian<quint32>(in.length());
memcpy(requestData, in.data(), in.length());
@ -157,7 +159,6 @@ bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
#endif
}
bool SSHAgent::addIdentity(OpenSSHKey& key, quint32 lifetime, bool confirm)
{
if (!isAgentRunning()) {
@ -186,8 +187,8 @@ bool SSHAgent::addIdentity(OpenSSHKey& key, quint32 lifetime, bool confirm)
}
if (responseData.length() < 1 || static_cast<quint8>(responseData[0]) != SSH_AGENT_SUCCESS) {
m_error = tr("Agent refused this identity. Possible reasons include:")
+ "\n" + tr("The key has already been added.");
m_error =
tr("Agent refused this identity. Possible reasons include:") + "\n" + tr("The key has already been added.");
if (lifetime > 0) {
m_error += "\n" + tr("Restricted lifetime is not supported by the agent (check options).");

View file

@ -19,9 +19,9 @@
#ifndef AGENTCLIENT_H
#define AGENTCLIENT_H
#include <QtCore>
#include <QList>
#include "OpenSSHKey.h"
#include <QList>
#include <QtCore>
#include "gui/DatabaseWidget.h"
@ -46,16 +46,16 @@ public slots:
void databaseModeChanged(DatabaseWidget::Mode mode = DatabaseWidget::LockedMode);
private:
const quint8 SSH_AGENT_FAILURE = 5;
const quint8 SSH_AGENT_SUCCESS = 6;
const quint8 SSH_AGENTC_REQUEST_IDENTITIES = 11;
const quint8 SSH_AGENT_IDENTITIES_ANSWER = 12;
const quint8 SSH_AGENTC_ADD_IDENTITY = 17;
const quint8 SSH_AGENTC_REMOVE_IDENTITY = 18;
const quint8 SSH_AGENTC_ADD_ID_CONSTRAINED = 25;
const quint8 SSH_AGENT_FAILURE = 5;
const quint8 SSH_AGENT_SUCCESS = 6;
const quint8 SSH_AGENTC_REQUEST_IDENTITIES = 11;
const quint8 SSH_AGENT_IDENTITIES_ANSWER = 12;
const quint8 SSH_AGENTC_ADD_IDENTITY = 17;
const quint8 SSH_AGENTC_REMOVE_IDENTITY = 18;
const quint8 SSH_AGENTC_ADD_ID_CONSTRAINED = 25;
const quint8 SSH_AGENT_CONSTRAIN_LIFETIME = 1;
const quint8 SSH_AGENT_CONSTRAIN_CONFIRM = 2;
const quint8 SSH_AGENT_CONSTRAIN_LIFETIME = 1;
const quint8 SSH_AGENT_CONSTRAIN_CONFIRM = 2;
explicit SSHAgent(QObject* parent = nullptr);
~SSHAgent();

View file

@ -8,7 +8,6 @@
#endif
#include <sys/types.h>
#ifdef _WIN32
#include <stdint.h>
@ -16,5 +15,5 @@ typedef uint32_t u_int32_t;
typedef uint16_t u_int16_t;
typedef uint8_t u_int8_t;
#define bzero(p,s) memset(p, 0, s)
#define bzero(p, s) memset(p, 0, s)
#endif