X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=sha256%2Fsha256.c;h=3e66355313dd1c82a9ed693d0936faf01cf733b6;hp=c121466bc37685b5ccc755d1d740f29b6f2b67a6;hb=a5fa5eb95b79e98e260365878fc9338ccba3fba9;hpb=1cc5630207195b3bc9d967596a9a207c1c0f6464 diff --git a/sha256/sha256.c b/sha256/sha256.c index c121466..3e66355 100644 --- a/sha256/sha256.c +++ b/sha256/sha256.c @@ -73,6 +73,10 @@ uint32_t rotr32( uint32_t x, uint8_t n){ return ((x>>n) | (x<<(32-n))); } +static +uint32_t rotl32( uint32_t x, uint8_t n){ + return ((x<>(32-n))); +} /*************************************************************************/ @@ -90,10 +94,10 @@ uint32_t change_endian32(uint32_t x){ #define CH(x,y,z) (((x)&(y)) ^ ((~(x))&(z))) #define MAJ(x,y,z) (((x)&(y)) ^ ((x)&(z)) ^ ((y)&(z))) -#define SIGMA0(x) (rotr32((x),2) ^ rotr32((x),13) ^ rotr32((x),22)) -#define SIGMA1(x) (rotr32((x),6) ^ rotr32((x),11) ^ rotr32((x),25)) -#define SIGMA_a(x) (rotr32((x),7) ^ rotr32((x),18) ^ ((x)>>3)) -#define SIGMA_b(x) (rotr32((x),17) ^ rotr32((x),19) ^ ((x)>>10)) +#define SIGMA0(x) (rotr32((x),2) ^ rotr32((x),13) ^ rotl32((x),10)) +#define SIGMA1(x) (rotr32((x),6) ^ rotr32((x),11) ^ rotl32((x),7)) +#define SIGMA_a(x) (rotr32((x),7) ^ rotl32((x),14) ^ ((x)>>3)) +#define SIGMA_b(x) (rotl32((x),15) ^ rotl32((x),13) ^ ((x)>>10)) const uint32_t k[]={