Merged in rodolphe_breard/ryzomcore/sha512-auth (pull request #89)

ref #206 : windows compilation stuff
This commit is contained in:
Jan Boon 2014-10-07 01:14:31 +02:00
commit f0d88f6150
2 changed files with 14 additions and 14 deletions

View file

@ -30,7 +30,7 @@ NL_TARGET_LIB(ryzom_gameshare ${PRIV_H} ${SRC} ${R2})
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
TARGET_LINK_LIBRARIES(ryzom_gameshare nelmisc nelnet nelligo nelgeorges crypt ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES}) TARGET_LINK_LIBRARIES(ryzom_gameshare nelmisc nelnet nelligo nelgeorges ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES})
NL_DEFAULT_PROPS(ryzom_gameshare "Ryzom, Library: Game Share") NL_DEFAULT_PROPS(ryzom_gameshare "Ryzom, Library: Game Share")
NL_ADD_RUNTIME_FLAGS(ryzom_gameshare) NL_ADD_RUNTIME_FLAGS(ryzom_gameshare)
NL_ADD_LIB_SUFFIX(ryzom_gameshare) NL_ADD_LIB_SUFFIX(ryzom_gameshare)

View file

@ -11,18 +11,18 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <nel/misc/types_nl.h>
/* public domain sha512 implementation based on fips180-3 */ /* public domain sha512 implementation based on fips180-3 */
/* >=2^64 bits messages are not supported (about 2000 peta bytes) */ /* >=2^64 bits messages are not supported (about 2000 peta bytes) */
struct sha512 { struct sha512 {
uint64_t len; /* processed message length */ uint64 len; /* processed message length */
uint64_t h[8]; /* hash state */ uint64 h[8]; /* hash state */
uint8_t buf[128]; /* message block buffer */ uint8_t buf[128]; /* message block buffer */
}; };
static uint64_t ror(uint64_t n, int k) { return (n >> k) | (n << (64-k)); } static uint64 ror(uint64 n, int k) { return (n >> k) | (n << (64-k)); }
#define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Ch(x,y,z) (z ^ (x & (y ^ z)))
#define Maj(x,y,z) ((x & y) | (z & (x | y))) #define Maj(x,y,z) ((x & y) | (z & (x | y)))
#define S0(x) (ror(x,28) ^ ror(x,34) ^ ror(x,39)) #define S0(x) (ror(x,28) ^ ror(x,34) ^ ror(x,39))
@ -30,7 +30,7 @@ static uint64_t ror(uint64_t n, int k) { return (n >> k) | (n << (64-k)); }
#define R0(x) (ror(x,1) ^ ror(x,8) ^ (x>>7)) #define R0(x) (ror(x,1) ^ ror(x,8) ^ (x>>7))
#define R1(x) (ror(x,19) ^ ror(x,61) ^ (x>>6)) #define R1(x) (ror(x,19) ^ ror(x,61) ^ (x>>6))
static const uint64_t K[80] = { static const uint64 K[80] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
@ -55,17 +55,17 @@ static const uint64_t K[80] = {
static void processblock(struct sha512 *s, const uint8_t *buf) static void processblock(struct sha512 *s, const uint8_t *buf)
{ {
uint64_t W[80], t1, t2, a, b, c, d, e, f, g, h; uint64 W[80], t1, t2, a, b, c, d, e, f, g, h;
int i; int i;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
W[i] = (uint64_t)buf[8*i]<<56; W[i] = (uint64)buf[8*i]<<56;
W[i] |= (uint64_t)buf[8*i+1]<<48; W[i] |= (uint64)buf[8*i+1]<<48;
W[i] |= (uint64_t)buf[8*i+2]<<40; W[i] |= (uint64)buf[8*i+2]<<40;
W[i] |= (uint64_t)buf[8*i+3]<<32; W[i] |= (uint64)buf[8*i+3]<<32;
W[i] |= (uint64_t)buf[8*i+4]<<24; W[i] |= (uint64)buf[8*i+4]<<24;
W[i] |= (uint64_t)buf[8*i+5]<<16; W[i] |= (uint64)buf[8*i+5]<<16;
W[i] |= (uint64_t)buf[8*i+6]<<8; W[i] |= (uint64)buf[8*i+6]<<8;
W[i] |= buf[8*i+7]; W[i] |= buf[8*i+7];
} }
for (; i < 80; i++) for (; i < 80; i++)