X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=sha2%2Fsha2_small_common.c;h=d650b287f26ee45f20f95737dd691d7a72038c8d;hp=7dad795f492fb44bc981cfa5593688c406ef76a6;hb=52867acc0c7f09a79efbbb738cef0c3f5a2abb04;hpb=9132c1117c69c30ff96919343682174050eb73ca diff --git a/sha2/sha2_small_common.c b/sha2/sha2_small_common.c index 7dad795..d650b28 100644 --- a/sha2/sha2_small_common.c +++ b/sha2/sha2_small_common.c @@ -51,9 +51,9 @@ 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) ^ 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_0(x) (rotr32((x), 2) ^ rotr32((x),13) ^ rotl32((x),10)) +#define SIGMA_1(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 @@ -74,7 +74,7 @@ uint32_t k[]={ * block must be, 512, Bit = 64, Byte, long !!! */ void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void* block){ - uint32_t w[16], wx; /* this is 256, byte, large, */ + uint32_t w[16], wx; uint8_t i; uint32_t a[8],t1,t2; @@ -103,8 +103,8 @@ void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void* bl memmove(&(w[0]), &(w[1]), 15*4); w[15] = wx; } - t1 = a[7] + SIGMA1(a[4]) + CH(a[4],a[5],a[6]) + k[i] + wx; - t2 = SIGMA0(a[0]) + MAJ(a[0],a[1],a[2]); + t1 = a[7] + SIGMA_1(a[4]) + CH(a[4],a[5],a[6]) + k[i] + wx; + t2 = SIGMA_0(a[0]) + MAJ(a[0],a[1],a[2]); memmove(&(a[1]), &(a[0]), 7*4); /* a[7]=a[6]; a[6]=a[5]; a[5]=a[4]; a[4]=a[3]; a[3]=a[2]; a[2]=a[1]; a[1]=a[0]; */ a[4] += t1; a[0] = t1 + t2;