done for today

This commit is contained in:
Orson Peters 2013-01-21 22:55:57 +01:00
parent 841d4981bc
commit 7fc42dc138
3 changed files with 17 additions and 11 deletions

View File

@ -3,18 +3,22 @@
static uint64_t load_3(const unsigned char *in) { static uint64_t load_3(const unsigned char *in) {
uint64_t result; uint64_t result;
result = (uint64_t) in[0]; result = (uint64_t) in[0];
result |= ((uint64_t) in[1]) << 8; result |= ((uint64_t) in[1]) << 8;
result |= ((uint64_t) in[2]) << 16; result |= ((uint64_t) in[2]) << 16;
return result; return result;
} }
static uint64_t load_4(const unsigned char *in) { static uint64_t load_4(const unsigned char *in) {
uint64_t result; uint64_t result;
result = (uint64_t) in[0]; result = (uint64_t) in[0];
result |= ((uint64_t) in[1]) << 8; result |= ((uint64_t) in[1]) << 8;
result |= ((uint64_t) in[2]) << 16; result |= ((uint64_t) in[2]) << 16;
result |= ((uint64_t) in[3]) << 24; result |= ((uint64_t) in[3]) << 24;
return result; return result;
} }

Binary file not shown.

View File

@ -109,7 +109,6 @@ static int sha512_compress(sha512_context *md, unsigned char *buf)
} }
/* Compress */ /* Compress */
#define RND(a,b,c,d,e,f,g,h,i) \ #define RND(a,b,c,d,e,f,g,h,i) \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c);\ t1 = Sigma0(a) + Maj(a, b, c);\
@ -127,6 +126,8 @@ static int sha512_compress(sha512_context *md, unsigned char *buf)
RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7); RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
} }
#undef RND
/* feedback */ /* feedback */
@ -143,9 +144,9 @@ return 0;
@param md The hash state you wish to initialize @param md The hash state you wish to initialize
@return 0 if successful @return 0 if successful
*/ */
int sha512_init(sha512_context * md) int sha512_init(sha512_context * md) {
{
if (md == NULL) return 1; if (md == NULL) return 1;
md->curlen = 0; md->curlen = 0;
md->length = 0; md->length = 0;
md->state[0] = UINT64_C(0x6a09e667f3bcc908); md->state[0] = UINT64_C(0x6a09e667f3bcc908);
@ -156,6 +157,7 @@ return 0;
md->state[5] = UINT64_C(0x9b05688c2b3e6c1f); md->state[5] = UINT64_C(0x9b05688c2b3e6c1f);
md->state[6] = UINT64_C(0x1f83d9abfb41bd6b); md->state[6] = UINT64_C(0x1f83d9abfb41bd6b);
md->state[7] = UINT64_C(0x5be0cd19137e2179); md->state[7] = UINT64_C(0x5be0cd19137e2179);
return 0; return 0;
} }