summaryrefslogtreecommitdiff
path: root/libcrypt
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-03-24 00:11:44 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-03-24 00:11:44 +0100
commit272e4fa4d38440d5c01259fce7d74f8c0a9d300f (patch)
tree4238b8f7ccc23037c8bb16885f1e76298977193c /libcrypt
parentc846358a61434e6cb9b1f73bc35df0e5404f52d2 (diff)
libcrypt: Rename some internal macros
to avoid clashes Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libcrypt')
-rw-r--r--libcrypt/sha256.c18
-rw-r--r--libcrypt/sha512.c18
2 files changed, 18 insertions, 18 deletions
diff --git a/libcrypt/sha256.c b/libcrypt/sha256.c
index 6bc2d8b2b..3e12b5ce4 100644
--- a/libcrypt/sha256.c
+++ b/libcrypt/sha256.c
@@ -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;
diff --git a/libcrypt/sha512.c b/libcrypt/sha512.c
index 079caee0a..b2e36a3b3 100644
--- a/libcrypt/sha512.c
+++ b/libcrypt/sha512.c
@@ -139,12 +139,12 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
uint64_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, 28) ^ CYCLIC (x, 34) ^ CYCLIC (x, 39))
-#define S1(x) (CYCLIC (x, 14) ^ CYCLIC (x, 18) ^ CYCLIC (x, 41))
-#define R0(x) (CYCLIC (x, 1) ^ CYCLIC (x, 8) ^ (x >> 7))
-#define R1(x) (CYCLIC (x, 19) ^ CYCLIC (x, 61) ^ (x >> 6))
+#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, 28) ^ CYCLIC (x, 34) ^ CYCLIC (x, 39))
+#define _S1(x) (CYCLIC (x, 14) ^ CYCLIC (x, 18) ^ CYCLIC (x, 41))
+#define _R0(x) (CYCLIC (x, 1) ^ CYCLIC (x, 8) ^ (x >> 7))
+#define _R1(x) (CYCLIC (x, 19) ^ CYCLIC (x, 61) ^ (x >> 6))
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
@@ -157,13 +157,13 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
++words;
}
for (unsigned int t = 16; t < 80; ++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.3.2 step 3. */
for (unsigned int t = 0; t < 80; ++t)
{
- uint64_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
- uint64_t T2 = S0 (a) + Maj (a, b, c);
+ uint64_t T1 = h + _S1 (e) + _Ch (e, f, g) + K[t] + W[t];
+ uint64_t T2 = _S0 (a) + _Maj (a, b, c);
h = g;
g = f;
f = e;