|
@@ -108,12 +108,12 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
|
|
|
uint32_t h_save = h;
|
|
|
|
|
|
/* Operators defined in FIPS 180-2:4.1.2. */
|
|
|
-#define Ch(x, y, z) ((x & y) ^ (~x & z))
|
|
|
-#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
|
|
|
-#define S0(x) (CYCLIC (x, 2) ^ CYCLIC (x, 13) ^ CYCLIC (x, 22))
|
|
|
-#define S1(x) (CYCLIC (x, 6) ^ CYCLIC (x, 11) ^ CYCLIC (x, 25))
|
|
|
-#define R0(x) (CYCLIC (x, 7) ^ CYCLIC (x, 18) ^ (x >> 3))
|
|
|
-#define R1(x) (CYCLIC (x, 17) ^ CYCLIC (x, 19) ^ (x >> 10))
|
|
|
+#define _Ch(x, y, z) ((x & y) ^ (~x & z))
|
|
|
+#define _Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
|
|
|
+#define _S0(x) (CYCLIC (x, 2) ^ CYCLIC (x, 13) ^ CYCLIC (x, 22))
|
|
|
+#define _S1(x) (CYCLIC (x, 6) ^ CYCLIC (x, 11) ^ CYCLIC (x, 25))
|
|
|
+#define _R0(x) (CYCLIC (x, 7) ^ CYCLIC (x, 18) ^ (x >> 3))
|
|
|
+#define _R1(x) (CYCLIC (x, 17) ^ CYCLIC (x, 19) ^ (x >> 10))
|
|
|
|
|
|
/* It is unfortunate that C does not provide an operator for
|
|
|
cyclic rotation. Hope the C compiler is smart enough. */
|
|
@@ -126,13 +126,13 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
|
|
|
++words;
|
|
|
}
|
|
|
for (unsigned int t = 16; t < 64; ++t)
|
|
|
- W[t] = R1 (W[t - 2]) + W[t - 7] + R0 (W[t - 15]) + W[t - 16];
|
|
|
+ W[t] = _R1 (W[t - 2]) + W[t - 7] + _R0 (W[t - 15]) + W[t - 16];
|
|
|
|
|
|
/* The actual computation according to FIPS 180-2:6.2.2 step 3. */
|
|
|
for (unsigned int t = 0; t < 64; ++t)
|
|
|
{
|
|
|
- uint32_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
|
|
|
- uint32_t T2 = S0 (a) + Maj (a, b, c);
|
|
|
+ uint32_t T1 = h + _S1 (e) + _Ch (e, f, g) + K[t] + W[t];
|
|
|
+ uint32_t T2 = _S0 (a) + _Maj (a, b, c);
|
|
|
h = g;
|
|
|
g = f;
|
|
|
f = e;
|