aboutsummaryrefslogtreecommitdiff
path: root/lib/e2ee/qolmutils.cpp
blob: c6e51bcda39e738b4a4058a79ebd26a79f2e3fec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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());
}