keepassxc

Форк
0
67 строк · 1.5 Кб
1
/*
2
 *  Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
3
 *
4
 *  This program is free software: you can redistribute it and/or modify
5
 *  it under the terms of the GNU General Public License as published by
6
 *  the Free Software Foundation, either version 2 or (at your option)
7
 *  version 3 of the License.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU General Public License
15
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18
#include "Kdf.h"
19

20
#include "crypto/Random.h"
21

22
Kdf::Kdf(const QUuid& uuid)
23
    : m_rounds(KDF_DEFAULT_ROUNDS)
24
    , m_seed(QByteArray(KDF_MAX_SEED_SIZE, 0))
25
    , m_uuid(uuid)
26
{
27
}
28

29
const QUuid& Kdf::uuid() const
30
{
31
    return m_uuid;
32
}
33

34
int Kdf::rounds() const
35
{
36
    return m_rounds;
37
}
38

39
QByteArray Kdf::seed() const
40
{
41
    return m_seed;
42
}
43

44
bool Kdf::setRounds(int rounds)
45
{
46
    if (rounds >= 1 && rounds < INT_MAX) {
47
        m_rounds = rounds;
48
        return true;
49
    }
50
    m_rounds = 1;
51
    return false;
52
}
53

54
bool Kdf::setSeed(const QByteArray& seed)
55
{
56
    if (seed.size() < KDF_MIN_SEED_SIZE || seed.size() > KDF_MAX_SEED_SIZE) {
57
        return false;
58
    }
59

60
    m_seed = seed;
61
    return true;
62
}
63

64
void Kdf::randomizeSeed()
65
{
66
    setSeed(randomGen()->randomArray(m_seed.size()));
67
}
68

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.