diff options
| author | Ross Nicoll <[email protected]> | 2018-08-27 12:34:34 +0100 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2019-04-03 05:16:26 +0000 |
| commit | 76a9aab2f48c26f358b7be63a9ca3ca663575f7d (patch) | |
| tree | 3ee38a8c6e47d5327fcf42babe54d22c67098fe5 /src/crypto/scrypt.h | |
| parent | doc: Fill in authors and changelog for 0.17.1 release notes (diff) | |
| download | discoin-76a9aab2f48c26f358b7be63a9ca3ca663575f7d.tar.xz discoin-76a9aab2f48c26f358b7be63a9ca3ca663575f7d.zip | |
Scrypt n=1024 PoW hash
Scrypt n=1024 PoW hash based upon Colin Percival's Tarnsnap (2009)
Modified by Artforz, coblee, pooler, wtogami, Nikolay Belikov, Adrian Gallagher, Ross Nicoll
Diffstat (limited to 'src/crypto/scrypt.h')
| -rw-r--r-- | src/crypto/scrypt.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/crypto/scrypt.h b/src/crypto/scrypt.h new file mode 100644 index 000000000..5431fb67c --- /dev/null +++ b/src/crypto/scrypt.h @@ -0,0 +1,45 @@ +#ifndef SCRYPT_H +#define SCRYPT_H +#include <stdlib.h> +#include <stdint.h> + +static const int SCRYPT_SCRATCHPAD_SIZE = 131072 + 63; + +void scrypt_1024_1_1_256(const char *input, char *output); +void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad); + +#if defined(USE_SSE2) +#if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__)) +#define USE_SSE2_ALWAYS 1 +#define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_sse2((input), (output), (scratchpad)) +#else +#define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_detected((input), (output), (scratchpad)) +#endif + +void scrypt_detect_sse2(); +void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad); +extern void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad); +#else +#define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_generic((input), (output), (scratchpad)) +#endif + +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); + +static inline uint32_t le32dec(const void *pp) +{ + const uint8_t *p = (uint8_t const *)pp; + return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) + + ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24)); +} + +static inline void le32enc(void *pp, uint32_t x) +{ + uint8_t *p = (uint8_t *)pp; + p[0] = x & 0xff; + p[1] = (x >> 8) & 0xff; + p[2] = (x >> 16) & 0xff; + p[3] = (x >> 24) & 0xff; +} +#endif |