-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrypt.h
More file actions
40 lines (32 loc) · 1.72 KB
/
Copy pathscrypt.h
File metadata and controls
40 lines (32 loc) · 1.72 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
#ifndef MASTERPASSWORD_SCRYPT_H
#define MASTERPASSWORD_SCRYPT_H
#include <stdint.h>
/**
* A costly key derivation function - preventing brute forcing.
* @param passPhrase String of characters to be hashed.
* @param salt String of random characters that modifies the hash to protect against Rainbow table attacks.
* @param costFactor CPU/memory cost parameter – Must be a power of 2.
* @param blockSizeFactor Blocksize parameter, which fine-tunes sequential memory read size and performance.
* @param parallelizationFactor Parallelization parameter.
* @param desiredKeyLen Desired key length in bytes.
* @param hashLen The length in octets of the hash function.
* @param mixFuncLen The length in octets of the output of the mixing function.
* @return The derived key, an array of bytes, DesiredKeyLen long
*/
unsigned char* scrypt(unsigned char* passPhrase, unsigned char* salt, int costFactor, int blockSizeFactor,
int parallelizationFactor, int desiredKeyLen, int hashLen, int mixFuncLen);
void ROMix(unsigned char* block, int blockSize, int iterations);
unsigned char* BlockMix(const unsigned char* block, unsigned char* Y, int blockSize);
uint64_t Integrify(const unsigned char* x, int blockSize);
inline void xor_block(unsigned char* result, const unsigned char* block, const unsigned char* other_block, int const blockSize) {
for (int i = 0; i < blockSize; ++i) {
result[i] = block[i] ^ other_block[i];
}
}
inline void xor_constant(unsigned char* dst, const unsigned char* src, unsigned char constant, int len) {
for (int i = 0; i < len; ++i) {
dst[i] = src[i] ^ constant;
}
}
unsigned char* concat(const unsigned char* a, size_t aLen, const unsigned char* b, size_t bLen);
#endif