1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#include "AESParameters.h"
8

9
#include "../HexCoding.h"
10

11
#include <TrezorCrypto/rand.h>
12

13
using namespace TW;
14
using namespace TW::Keystore;
15

16 1
AESParameters::AESParameters() {
17 1
    iv = Data(blockSize, 0);
18 1
    random_buffer(iv.data(), blockSize);
19
}
20

21
namespace CodingKeys {
22
static const auto iv = "iv";
23
} // namespace CodingKeys
24

25
/// Initializes `AESParameters` with a JSON object.
26 1
AESParameters::AESParameters(const nlohmann::json& json) {
27 1
    iv = parse_hex(json[CodingKeys::iv].get<std::string>());
28
}
29

30
/// Saves `this` as a JSON object.
31 1
nlohmann::json AESParameters::json() const {
32 1
    nlohmann::json j;
33 1
    j[CodingKeys::iv] = hex(iv);
34 1
    return j;
35
}

Read our documentation on viewing source code .

Loading