diff options
author | technion <technion@lolware.net> | 2014-09-21 10:14:59 +1000 |
---|---|---|
committer | technion <technion@lolware.net> | 2014-09-21 10:14:59 +1000 |
commit | 0217f5828a07caff3c43ae1400e0479d40cce62a (patch) | |
tree | a3648353751dffeeadc3e2c597ec4c1103c294e7 | |
parent | c75e52cc1219ff79947078772fc5c0543cbeee8b (diff) | |
parent | 1023e18857560035d8eb2f25e1321abbba770714 (diff) |
Merge pull request #28 from Convey-Compliance/master
Minimal changes to allow compilation in Visual Studio
-rw-r--r-- | b64.c | 2 | ||||
-rw-r--r-- | crypto-mcf.c | 10 | ||||
-rw-r--r-- | libscrypt.h | 9 | ||||
-rw-r--r-- | sysendian.h | 21 |
4 files changed, 27 insertions, 15 deletions
@@ -174,7 +174,7 @@ libscrypt_b64_encode(src, srclength, target, targsize) if (datalength >= targsize) return (-1); target[datalength] = '\0'; /* Returned value doesn't count \0. */ - return (datalength); + return (int)(datalength); } /* skips all whitespace anywhere. diff --git a/crypto-mcf.c b/crypto-mcf.c index 74e7be0..8ad3eb8 100644 --- a/crypto-mcf.c +++ b/crypto-mcf.c @@ -25,13 +25,19 @@ static uint32_t scrypt_ilog2(uint32_t n) while (((uint32_t)1 << t) < n) { if(t > SCRYPT_SAFE_N) - return -1; /* Check for insanity */ + return (uint32_t) -1; /* Check for insanity */ t++; } return t; } +#ifdef _MSC_VER + #define SNPRINTF _snprintf +#else + #define SNPRINTF snprintf +#endif + int libscrypt_mcf(uint32_t N, uint32_t r, uint32_t p, const char *salt, const char *hash, char *mcf) { @@ -59,7 +65,7 @@ int libscrypt_mcf(uint32_t N, uint32_t r, uint32_t p, const char *salt, * determined that mcf should be defined as at least SCRYPT_MCF_LEN * in length */ - s = snprintf(mcf, SCRYPT_MCF_LEN, SCRYPT_MCF_ID "$%06x$%s$%s", (unsigned int)params, salt, hash); + s = SNPRINTF(mcf, SCRYPT_MCF_LEN, SCRYPT_MCF_ID "$%06x$%s$%s", (unsigned int)params, salt, hash); if (s > SCRYPT_MCF_LEN) return 0; diff --git a/libscrypt.h b/libscrypt.h index 318576e..b7141f5 100644 --- a/libscrypt.h +++ b/libscrypt.h @@ -33,18 +33,19 @@ int libscrypt_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t, int libscrypt_mcf(uint32_t N, uint32_t r, uint32_t p, const char *salt, const char *hash, char *mcf); +#ifndef _MSC_VER /* Generates a salt. Uses /dev/urandom/ */ int libscrypt_salt_gen(/*@out@*/ uint8_t *rand, size_t len); -/* Checks a given MCF against a password */ -int libscrypt_check(char *mcf, const char *password); - /* Creates a hash of a passphrase using a randomly generated salt */ /* Returns >0 on success, or 0 for fail */ int libscrypt_hash(char *dst, const char* passphrase, uint32_t N, uint8_t r, - uint8_t p); + uint8_t p); +#endif +/* Checks a given MCF against a password */ +int libscrypt_check(char *mcf, const char *password); #ifdef __cplusplus } diff --git a/sysendian.h b/sysendian.h index 5ecb505..af1ecdc 100644 --- a/sysendian.h +++ b/sysendian.h @@ -42,8 +42,13 @@ #else #include <stdint.h> +#ifdef _MSC_VER + #define INLINE __inline +#else + #define INLINE inline +#endif -static inline uint32_t +static INLINE uint32_t be32dec(const void *pp) { const uint8_t *p = (uint8_t const *)pp; @@ -52,7 +57,7 @@ be32dec(const void *pp) ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24)); } -static inline void +static INLINE void be32enc(void *pp, uint32_t x) { uint8_t * p = (uint8_t *)pp; @@ -63,7 +68,7 @@ be32enc(void *pp, uint32_t x) p[0] = (x >> 24) & 0xff; } -static inline uint64_t +static INLINE uint64_t be64dec(const void *pp) { const uint8_t *p = (uint8_t const *)pp; @@ -74,7 +79,7 @@ be64dec(const void *pp) ((uint64_t)(p[1]) << 48) + ((uint64_t)(p[0]) << 56)); } -static inline void +static INLINE void be64enc(void *pp, uint64_t x) { uint8_t * p = (uint8_t *)pp; @@ -89,7 +94,7 @@ be64enc(void *pp, uint64_t x) p[0] = (x >> 56) & 0xff; } -static inline uint32_t +static INLINE uint32_t le32dec(const void *pp) { const uint8_t *p = (uint8_t const *)pp; @@ -98,7 +103,7 @@ le32dec(const void *pp) ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24)); } -static inline void +static INLINE void le32enc(void *pp, uint32_t x) { uint8_t * p = (uint8_t *)pp; @@ -109,7 +114,7 @@ le32enc(void *pp, uint32_t x) p[3] = (x >> 24) & 0xff; } -static inline uint64_t +static INLINE uint64_t le64dec(const void *pp) { const uint8_t *p = (uint8_t const *)pp; @@ -120,7 +125,7 @@ le64dec(const void *pp) ((uint64_t)(p[6]) << 48) + ((uint64_t)(p[7]) << 56)); } -static inline void +static INLINE void le64enc(void *pp, uint64_t x) { uint8_t * p = (uint8_t *)pp; |