Use openssl sha everywhere

This commit is contained in:
Steve Dee 2014-04-16 11:06:54 -07:00
parent f29b34fb37
commit 8018b97d7f

View File

@ -5,13 +5,7 @@
#include "all.h"
#include "../pit.h"
#if defined(U2_OS_linux) || defined(U2_OS_bsd)
#include <openssl/sha.h>
#elif defined(U2_OS_osx)
#include <CommonCrypto/CommonDigest.h>
#else
#error "port: sha256"
#endif
/* functions
*/
@ -25,21 +19,11 @@
u2_bytes(0, met_w, fat_y, a);
{
c3_y dig_y[32];
#if defined(U2_OS_linux) || defined(U2_OS_bsd)
SHA256_CTX ctx_h;
SHA256_Init(&ctx_h);
SHA256_Update(&ctx_h, fat_y, met_w);
SHA256_Final(dig_y, &ctx_h);
#elif 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
#error "port: sha256"
#endif
free(fat_y);
return u2_rl_bytes(wir_r, 32, dig_y);
}
@ -56,21 +40,11 @@
u2_bytes(0, a, fat_y, b);
{
c3_y dig_y[64];
#if defined(U2_OS_linux) || defined(U2_OS_bsd)
SHA512_CTX ctx_h;
SHA512_Init(&ctx_h);
SHA512_Update(&ctx_h, fat_y, a);
SHA512_Final(dig_y, &ctx_h);
#elif 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
#error "port: sha512"
#endif
free(fat_y);
return u2_rl_bytes(wir_r, 64, dig_y);
}