static
void load_endian32_changed(uint8_t* dest, uint8_t* src, uint16_t words){
+#if defined LITTLE_ENDIAN
while(words--){
*dest++ = src[3];
*dest++ = src[2];
*dest++ = src[0];
src += 4;
}
+#elif defined BIG_ENDIAN
+ memcpy(dest, src, words * sizeof(uint32_t));
+#endif
}
0x6ed9eba1,
0x8f1bbcdc,
0xca62c1d6};
-
/* load the w array (changing the endian and so) */
load_endian32_changed((uint8_t*)w, (uint8_t*)block, 16);
+
#if DEBUG
uint8_t dbgi;
for(dbgi=0; dbgi<16; ++dbgi){
lb[56+i] = ((uint8_t*)&(state->length))[7-i];
}
#elif defined BIG_ENDIAN
- *((uint64_t)&(lb[56])) = state->length;
+ *((uint64_t*)&(lb[56])) = state->length;
#endif
sha1_nextBlock(state, lb);
}
void sha1_ctx2hash (void *dest, sha1_ctx_t *state){
#if defined LITTLE_ENDIAN
load_endian32_changed((uint8_t*)dest, (uint8_t*)state->h, 5);
-#elif BIG_ENDIAN
- if (dest != state->h)
+#elif defined BIG_ENDIAN
+ if (dest != state->h) {
memcpy(dest, state->h, SHA1_HASH_BITS/8);
+ }
#else
# error unsupported endian type!
#endif