Use CommonCrypto for sha on OS X

This reverts commit 31b43ffe770c420e2a012b019c631056c30def67.

Conflicts:
	gen164/5/shax.c
This commit is contained in:
Steve Dee 2014-04-20 14:51:35 -07:00
parent 13ae1eee30
commit 9feaa6ea39

View File

@ -5,9 +5,11 @@
#include "all.h" #include "all.h"
#include "../pit.h" #include "../pit.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #if defined(U2_OS_osx)
#include <CommonCrypto/CommonDigest.h>
#else
#include <openssl/sha.h> #include <openssl/sha.h>
#endif
/* functions /* functions
*/ */
@ -21,11 +23,19 @@
u2_bytes(0, met_w, fat_y, a); u2_bytes(0, met_w, fat_y, a);
{ {
c3_y dig_y[32]; c3_y dig_y[32];
#if defined(U2_OS_osx)
CC_SHA256_CTX ctx_h;
CC_SHA256_Init(&ctx_h);
CC_SHA256_Update(&ctx_h, fat_y, met_w);
CC_SHA256_Final(dig_y, &ctx_h);
#else
SHA256_CTX ctx_h; SHA256_CTX ctx_h;
SHA256_Init(&ctx_h); SHA256_Init(&ctx_h);
SHA256_Update(&ctx_h, fat_y, met_w); SHA256_Update(&ctx_h, fat_y, met_w);
SHA256_Final(dig_y, &ctx_h); SHA256_Final(dig_y, &ctx_h);
#endif
free(fat_y); free(fat_y);
return u2_rl_bytes(wir_r, 32, dig_y); return u2_rl_bytes(wir_r, 32, dig_y);
} }
@ -42,11 +52,19 @@
u2_bytes(0, a, fat_y, b); u2_bytes(0, a, fat_y, b);
{ {
c3_y dig_y[64]; c3_y dig_y[64];
#if defined(U2_OS_osx)
CC_SHA512_CTX ctx_h;
CC_SHA512_Init(&ctx_h);
CC_SHA512_Update(&ctx_h, fat_y, a);
CC_SHA512_Final(dig_y, &ctx_h);
#else
SHA512_CTX ctx_h; SHA512_CTX ctx_h;
SHA512_Init(&ctx_h); SHA512_Init(&ctx_h);
SHA512_Update(&ctx_h, fat_y, a); SHA512_Update(&ctx_h, fat_y, a);
SHA512_Final(dig_y, &ctx_h); SHA512_Final(dig_y, &ctx_h);
#endif
free(fat_y); free(fat_y);
return u2_rl_bytes(wir_r, 64, dig_y); return u2_rl_bytes(wir_r, 64, dig_y);
} }