forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTWKeyDerivation.h
More file actions
49 lines (41 loc) · 1.54 KB
/
TWKeyDerivation.h
File metadata and controls
49 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright © 2017-2019 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once
#include "TWBase.h"
#include "TWData.h"
#include "TWString.h"
TW_EXTERN_C_BEGIN
TW_EXPORT_STRUCT
struct TWKeyDerivation {
uint8_t unused; // C doesn't allow zero-sized struct
};
/// Scrypt key derivation function.
///
/// \param password password.
/// \param salt salt.
/// \param n CPU AND RAM cost (first modifier)
/// \param r RAM Cost
/// \param p CPU cost (parallelisation)
/// \param keyLength desired key length.
TW_EXPORT_STATIC_METHOD
TWData *_Nullable TWKeyDerivationScrypt(TWString *_Nonnull password, TWData *_Nonnull salt, uint64_t n, uint32_t r, uint32_t p, size_t keyLength);
/// PBKDF2 key derivation function, 256-bit variation.
///
/// \param password password.
/// \param salt salt.
/// \param iterations CPU cost.
/// \param keyLength desired key length.
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWKeyDerivationPBKDF2_256(TWString *_Nonnull password, TWData *_Nonnull salt, uint32_t iterations, size_t keyLength);
/// PBKDF2 key derivation function, 512-bit variation.
///
/// \param password password.
/// \param salt salt.
/// \param iterations CPU cost.
/// \param keyLength desired key length.
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWKeyDerivationPBKDF2_512(TWString *_Nonnull password, TWData *_Nonnull salt, uint32_t iterations, size_t keyLength);
TW_EXTERN_C_END