This library implements some hash and cryptographic algorithms.
Dependents: ES_CW2_Starter_JIN EMBEDDED_CW2 EMBEDDED_CW2_Final Spinnybois ... more
Fork of Crypto by
Diff: hash/SHA2_64.cpp
- Revision:
- 13:ac8e23b98dae
- Parent:
- 7:2dbbdfb08123
diff -r cb30c135cd5f -r ac8e23b98dae hash/SHA2_64.cpp --- a/hash/SHA2_64.cpp Tue Apr 08 19:39:25 2014 +0000 +++ b/hash/SHA2_64.cpp Sun May 11 11:14:51 2014 +0000 @@ -15,8 +15,19 @@ static uint64_t revWord(uint64_t w) { +#ifdef __CC_ARM return __rev(w >> 32) | ((uint64_t)(__rev(w)) << 32); +#else + return (w >> 56) + | ((w & 0x00FF000000000000) >> 40) + | ((w & 0x0000FF0000000000) >> 24) + | ((w & 0x000000FF00000000) >> 8) + | ((w & 0x00000000FF000000) << 8) + | ((w & 0x0000000000FF0000) << 24) + | ((w & 0x000000000000FF00) << 40) + | ((w & 0x00000000000000FF) << 56); +#endif } #define ROTL(W,N) (((W) << (N)) | ((W) >> (64-(N)))) @@ -67,7 +78,7 @@ void SHA2_64::update(uint8_t *data, uint32_t length) { - if(length < 128-bufferLength) + if((int)length < 128-bufferLength) { memcpy(&buffer[bufferLength], data, length); bufferLength += length; @@ -83,7 +94,7 @@ computeBlock(&h0,&h1,&h2,&h3,&h4,&h5,&h6,&h7,buffer); offset += 128; } - if(offset > length) + if(offset > (int)length) offset -= 128; bufferLength = length - offset; memcpy(buffer, &data[offset], bufferLength); @@ -351,4 +362,4 @@ *h52 += f; *h62 += g; *h72 += h; -} +} \ No newline at end of file