aboutsummaryrefslogtreecommitdiff
path: root/lib/e2ee/qolmutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/e2ee/qolmutils.cpp')
-rw-r--r--lib/e2ee/qolmutils.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/e2ee/qolmutils.cpp b/lib/e2ee/qolmutils.cpp
new file mode 100644
index 00000000..c6e51bcd
--- /dev/null
+++ b/lib/e2ee/qolmutils.cpp
@@ -0,0 +1,22 @@
+// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include "e2ee/qolmutils.h"
+#include <QtCore/QRandomGenerator>
+
+using namespace Quotient;
+
+QByteArray Quotient::toKey(const Quotient::PicklingMode &mode)
+{
+ if (std::holds_alternative<Quotient::Unencrypted>(mode)) {
+ return {};
+ }
+ return std::get<Quotient::Encrypted>(mode).key;
+}
+
+RandomBuffer::RandomBuffer(size_t size)
+ : QByteArray(static_cast<int>(size), '\0')
+{
+ QRandomGenerator::system()->generate(begin(), end());
+}