Skip to content

Commit

Permalink
Switch to Qt-native random number generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Mar 14, 2024
1 parent 33906e7 commit a79090c
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 303 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR ("${CMAKE_BUILD_TYPE}" STREQUAL "Re
include(debug-definitions)
endif()

if(QT_DEFAULT_MAJOR_VERSION STREQUAL "")
if("${QT_DEFAULT_MAJOR_VERSION}" STREQUAL "")
set(QT_DEFAULT_MAJOR_VERSION 5)
endif()

Expand Down
4 changes: 0 additions & 4 deletions src/xmpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ set(XMPP_HEADERS_PRIVATE
zlib/zlibcompressor.h
zlib/zlibdecompressor.h
blake2/blake2qt.h

base/randomnumbergenerator.h
base/randrandomnumbergenerator.h
base/timezone.h
)

Expand Down Expand Up @@ -152,7 +149,6 @@ target_sources(iris PRIVATE
xmpp-im/jingle-ibb.cpp
xmpp-im/jingle-file.cpp

base/randomnumbergenerator.cpp
base/timezone.cpp

zlib/zlibcompressor.cpp
Expand Down
31 changes: 0 additions & 31 deletions src/xmpp/base/randomnumbergenerator.cpp

This file was deleted.

36 changes: 0 additions & 36 deletions src/xmpp/base/randomnumbergenerator.h

This file was deleted.

37 changes: 0 additions & 37 deletions src/xmpp/base/randrandomnumbergenerator.h

This file was deleted.

48 changes: 0 additions & 48 deletions src/xmpp/base/unittest/incrementingrandomnumbergenerator.h

This file was deleted.

64 changes: 0 additions & 64 deletions src/xmpp/base/unittest/randomnumbergeneratortest.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions src/xmpp/base/unittest/randrandomnumbergeneratortest.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions src/xmpp/sasl/digestmd5response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

#include "xmpp/sasl/digestmd5response.h"

#include "xmpp/base/randomnumbergenerator.h"
#include "xmpp/sasl/digestmd5proplist.h"

#include <QByteArray>
#include <QRandomGenerator>
#include <QtCrypto>
#include <QtDebug>

namespace XMPP {
DIGESTMD5Response::DIGESTMD5Response(const QByteArray &challenge, const QString &service, const QString &host,
const QString &arealm, const QString &user, const QString &authz,
const QByteArray &password, const RandomNumberGenerator &rand) : isValid_(true)
const QByteArray &password) : isValid_(true)
{
QString realm = arealm;

Expand All @@ -44,7 +44,7 @@ DIGESTMD5Response::DIGESTMD5Response(const QByteArray &challenge, const QString
QByteArray a;
a.resize(32);
for (int n = 0; n < (int)a.size(); ++n) {
a[n] = (char)rand.generateNumberBetween(0, 255);
a[n] = (char)QRandomGenerator::global()->bounded(0, 256);
}
QByteArray cnonce = a.toBase64();

Expand Down
4 changes: 1 addition & 3 deletions src/xmpp/sasl/digestmd5response.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
#include <QString>

namespace XMPP {
class RandomNumberGenerator;

class DIGESTMD5Response {
public:
DIGESTMD5Response(const QByteArray &challenge, const QString &service, const QString &host, const QString &realm,
const QString &user, const QString &authz, const QByteArray &password,
const RandomNumberGenerator &rand);
const QString &user, const QString &authz, const QByteArray &password);

const QByteArray &getValue() const { return value_; }

Expand Down
8 changes: 4 additions & 4 deletions src/xmpp/sasl/scramsha1message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

#include "xmpp/sasl/scramsha1message.h"

#include "xmpp/base/randomnumbergenerator.h"
#include "xmpp/jid/jid.h"

#include <QDebug>
#include <QRandomGenerator>
#include <QString>
#include <QTextStream>
#include <QtCrypto>
Expand All @@ -40,8 +40,8 @@ bool Normalize(const QString &username_in, QString &username_out)
}
}

SCRAMSHA1Message::SCRAMSHA1Message(const QString &authzid, const QString &authcid, const QByteArray &cnonce,
const RandomNumberGenerator &rand) : isValid_(true)
SCRAMSHA1Message::SCRAMSHA1Message(const QString &authzid, const QString &authcid, const QByteArray &cnonce) :
isValid_(true)
{
QString result;
QByteArray clientnonce;
Expand All @@ -57,7 +57,7 @@ SCRAMSHA1Message::SCRAMSHA1Message(const QString &authzid, const QString &authci
QByteArray a;
a.resize(32);
for (int n = 0; n < (int)a.size(); ++n) {
a[n] = (char)rand.generateNumberBetween(0, 255);
a[n] = (char)QRandomGenerator::global()->bounded(0, 256);
}
clientnonce = a.toBase64();
} else
Expand Down
5 changes: 1 addition & 4 deletions src/xmpp/sasl/scramsha1message.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
#ifndef SCRAMSHA1MESSAGE_H
#define SCRAMSHA1MESSAGE_H

#include "xmpp/base/randomnumbergenerator.h"

#include <QByteArray>
#include <QString>

namespace XMPP {
class SCRAMSHA1Message {
public:
SCRAMSHA1Message(const QString &authzid, const QString &authcid, const QByteArray &cnonce,
const RandomNumberGenerator &rand);
SCRAMSHA1Message(const QString &authzid, const QString &authcid, const QByteArray &cnonce);

const QByteArray &getValue() { return value_; }

Expand Down
Loading

0 comments on commit a79090c

Please sign in to comment.