Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
scrypt.h
Go to the documentation of this file.
1 #ifndef SCRYPT_H
2 #define SCRYPT_H
3 #include <stdlib.h>
4 #include <stdint.h>
5 
6 static const int SCRYPT_SCRATCHPAD_SIZE = 131072 + 63;
7 
8 void scrypt_1024_1_1_256(const char *input, char *output);
9 void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad);
10 
11 #if defined(USE_SSE2)
12 #if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__))
13 #define USE_SSE2_ALWAYS 1
14 #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_sse2((input), (output), (scratchpad))
15 #else
16 #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_detected((input), (output), (scratchpad))
17 #endif
18 
19 void scrypt_detect_sse2();
20 void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad);
21 extern void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad);
22 #else
23 #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_generic((input), (output), (scratchpad))
24 #endif
25 
26 void
27 PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
28  size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen);
29 
30 static inline uint32_t le32dec(const void *pp)
31 {
32  const uint8_t *p = (uint8_t const *)pp;
33  return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
34  ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
35 }
36 
37 static inline void le32enc(void *pp, uint32_t x)
38 {
39  uint8_t *p = (uint8_t *)pp;
40  p[0] = x & 0xff;
41  p[1] = (x >> 8) & 0xff;
42  p[2] = (x >> 16) & 0xff;
43  p[3] = (x >> 24) & 0xff;
44 }
45 #endif
void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad)
Definition: scrypt.cpp:256
unsigned char uint8_t
Definition: stdint.h:19
unsigned int uint32_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:22
void PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt, size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and write the output to buf.
Definition: scrypt.cpp:137
void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad)
Definition: scrypt-sse2.cpp:95
void scrypt_1024_1_1_256(const char *input, char *output)
Definition: scrypt.cpp:325