Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
Use Botan as a private library
Browse files Browse the repository at this point in the history
formatting code changed by removing explicit
  • Loading branch information
librehat committed Jul 30, 2017
1 parent 4022d45 commit 1843683
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 44 deletions.
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ add_library(${LIBNAME} ${SOURCE})
target_link_libraries(${LIBNAME}
PUBLIC Qt5::Core
PUBLIC Qt5::Network
PUBLIC ${BOTAN_LIBRARIES})
PRIVATE ${BOTAN_LIBRARIES})
target_include_directories(${LIBNAME} PRIVATE ${BOTAN_INCLUDE_DIRS})

foreach(LIB Qt5Network Qt5Core ${BOTAN_LIBRARIES})
Expand Down
4 changes: 2 additions & 2 deletions lib/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class QSS_EXPORT Address : public QObject
QObject *parent = 0);

Address(const QHostAddress &ip,
const quint16 &p,
QObject *parent = 0);
const quint16 &p,
QObject *parent = 0);

Address(const Address &o);
//force the generation of default move constructor
Expand Down
4 changes: 2 additions & 2 deletions lib/addresstester.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class QSS_EXPORT AddressTester : public QObject
Q_OBJECT
public:
AddressTester(const QHostAddress &server_address,
const quint16 &server_port,
QObject *parent = 0);
const quint16 &server_port,
QObject *parent = 0);

static const int LAG_TIMEOUT = -1;
static const int LAG_ERROR = -2;
Expand Down
4 changes: 2 additions & 2 deletions lib/chacha.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ChaCha : public QObject
* IV length must be 8 or 12
*/
ChaCha(const QByteArray &_key,
const QByteArray &_iv,
QObject *parent = 0);
const QByteArray &_iv,
QObject *parent = 0);

public slots:
//encrypt (or decrypt, same process for ChaCha algorithm) a byte array.
Expand Down
14 changes: 13 additions & 1 deletion lib/cipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@
#include <botan/auto_rng.h>
#include <botan/key_filt.h>
#include <botan/lookup.h>
#include <stdexcept>
#include <botan/pipe.h>
#include <botan/version.h>
#include <QCryptographicHash>
#include <QMessageAuthenticationCode>
#include <stdexcept>

using namespace QSS;

#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,10,0)
#error "Botan library is too old."
#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
typedef Botan::SecureVector<Botan::byte> SecureByteArray;
#define DataOfSecureByteArray(sba) sba.begin()
#else
typedef Botan::secure_vector<Botan::byte> SecureByteArray;
#define DataOfSecureByteArray(sba) sba.data()
#endif

Cipher::Cipher(const QByteArray &method,
const QByteArray &key,
const QByteArray &iv,
Expand Down
16 changes: 4 additions & 12 deletions lib/cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,15 @@
#include <array>
#include <map>
#include <QObject>
#include <botan/pipe.h>
#include <botan/version.h>
#include "rc4.h"
#include "chacha.h"
#include "export.h"

namespace QSS {
namespace Botan {
class Pipe;
}

#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,10,0)
#error "Botan library is too old."
#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
typedef Botan::SecureVector<Botan::byte> SecureByteArray;
#define DataOfSecureByteArray(sba) sba.begin()
#else
typedef Botan::secure_vector<Botan::byte> SecureByteArray;
#define DataOfSecureByteArray(sba) sba.data()
#endif
namespace QSS {

class QSS_EXPORT Cipher : public QObject
{
Expand Down
4 changes: 2 additions & 2 deletions lib/encryptorprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class QSS_EXPORT EncryptorPrivate : public QObject
* If the initialisation doesn't succeed, isValid() function return false
*/
EncryptorPrivate(const QString &method,
const QString &password,
QObject *parent = 0);
const QString &password,
QObject *parent = 0);

//construct an invalid/null instance
explicit EncryptorPrivate(QObject *parent = 0);
Expand Down
4 changes: 2 additions & 2 deletions lib/rc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class RC4 : public QObject
// This class implements so-called RC4-MD5 cipher instead of original RC4
// _iv is not allowed to be empty!
RC4(const QByteArray &_key,
const QByteArray &_iv,
QObject *parent = 0);
const QByteArray &_iv,
QObject *parent = 0);

public slots:
QByteArray update(const QByteArray &input);
Expand Down
4 changes: 2 additions & 2 deletions lib/socketstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class QSS_EXPORT SocketStream : public QObject
* vice versa
*/
SocketStream(QAbstractSocket *a,
QAbstractSocket *b,
QObject *parent = 0);
QAbstractSocket *b,
QObject *parent = 0);

signals:
void info(const QString &);
Expand Down
14 changes: 7 additions & 7 deletions lib/tcprelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class QSS_EXPORT TcpRelay : public QObject
Q_OBJECT
public:
TcpRelay(QTcpSocket *localSocket,
int timeout,
const Address &server_addr,
const EncryptorPrivate &ep,
const bool &is_local,
const bool &autoBan,
const bool &auth,
QObject *parent = 0);
int timeout,
const Address &server_addr,
const EncryptorPrivate &ep,
const bool &is_local,
const bool &autoBan,
const bool &auth,
QObject *parent = 0);

enum STAGE { INIT, ADDR, UDP_ASSOC, DNS, CONNECTING, STREAM, DESTROYED };

Expand Down
12 changes: 6 additions & 6 deletions lib/tcpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class QSS_EXPORT TcpServer : public QTcpServer
Q_OBJECT
public:
TcpServer(const EncryptorPrivate &ep,
const int &timeout,
const bool &is_local,
const bool &auto_ban,
const bool &auth,
const Address &serverAddress,
QObject *parent = nullptr);
const int &timeout,
const bool &is_local,
const bool &auto_ban,
const bool &auth,
const Address &serverAddress,
QObject *parent = nullptr);
~TcpServer();

bool listen(const QHostAddress &address, quint16 port);
Expand Down
10 changes: 5 additions & 5 deletions lib/udprelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class QSS_EXPORT UdpRelay : public QObject
Q_OBJECT
public:
UdpRelay(const EncryptorPrivate &ep,
const bool &is_local,
const bool &auto_ban,
const bool &auth,
const Address &serverAddress,
QObject *parent = 0);
const bool &is_local,
const bool &auto_ban,
const bool &auth,
const Address &serverAddress,
QObject *parent = 0);

void setup(const QHostAddress &localAddr,
const quint16 &localPort);
Expand Down

0 comments on commit 1843683

Please sign in to comment.