Anoncoin  0.9.4
P2P Digital Currency
scrypt.h
Go to the documentation of this file.
1 // Copyright 2009 Colin Percival, 2011 ArtForz, 2012-2013 pooler
2 // Copyright (c) 2013-2015 The Anoncoin Core developers
3 #ifndef SCRYPT_H
4 #define SCRYPT_H
5 
6 // Many builder specific things set in the config file, ENABLE_WALLET is a good example.
7 // Don't forget to include it this way in your source or header files. GR Note: The
8 // latter is now my preferred method, with a note in the source file about how the builder
9 // config file has now been loaded. We define now USE_SSE2 in the build process, so this
10 // in an important attribute to now consider.
11 #if defined(HAVE_CONFIG_H)
12 #include "config/anoncoin-config.h"
13 #endif
14 
15 #include <stdlib.h>
16 #include <stdint.h>
17 
18 static const int SCRYPT_SCRATCHPAD_SIZE = 131072 + 63;
19 
20 void scrypt_1024_1_1_256(const char *input, char *output);
21 void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad);
22 
23 #if defined(USE_SSE2)
24 // GR note: Commented out, because the machine building this is not the target host, we can only allow detecting the possiblity of using that hardware.
25 // #if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__))
26 // #define USE_SSE2_ALWAYS 1
27 // #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_sse2((input), (output), (scratchpad))
28 // #else
29 #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_detected((input), (output), (scratchpad))
30 // #endif
31 
32 void scrypt_detect_sse2();
33 void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad);
34 extern void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad);
35 #else
36 #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_generic((input), (output), (scratchpad))
37 #endif
38 
39 void
40 PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
41  size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen);
42 
43 static inline uint32_t le32dec(const void *pp)
44 {
45  const uint8_t *p = (uint8_t const *)pp;
46  return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
47  ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
48 }
49 
50 static inline void le32enc(void *pp, uint32_t x)
51 {
52  uint8_t *p = (uint8_t *)pp;
53  p[0] = x & 0xff;
54  p[1] = (x >> 8) & 0xff;
55  p[2] = (x >> 16) & 0xff;
56  p[3] = (x >> 24) & 0xff;
57 }
58 #endif
void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad)
Definition: scrypt.cpp:259
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:140
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:328