]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
New macro ROTL64, analogous to ROTL32.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 31 Mar 2012 19:55:04 +0000 (21:55 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 31 Mar 2012 19:55:04 +0000 (21:55 +0200)
ChangeLog
sha512-compress.c

index bc06c4718e3323c6f5a04d4bef27e697d4911a43..155fe11ea3d71dd1e4b9823fc9ae5494b5bdbf65 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        with complemented shift count.
        (SHR): Deleted macro, use plain shift operator instead.
 
+       * sha512-compress.c (ROTR): Deleted macro, replaced by...
+       (ROTL64): ...new macro, with complemented shift count
+       (SHR): Deleted macro, use plain shift operator instead.
+       (S0, S1, s0, s1): Updated accordingly.
+
 2012-03-30  Niels Möller  <nisse@lysator.liu.se>
 
        * nettle-internal.c (nettle_salsa20): Cipher struct for
index f0f9bf325f8ac97a263845b33675a8ad3568eaa1..10fca33e48cef3ec9dc09dad023d20591285cd23 100644 (file)
@@ -38,8 +38,7 @@
 /* A block, treated as a sequence of 64-bit words. */
 #define SHA512_DATA_LENGTH 16
 
-#define ROTR(n,x) ((x)>>(n) | ((x)<<(64-(n))))
-#define SHR(n,x) ((x)>>(n))
+#define ROTL64(n,x) ((x)<<(n) | ((x)>>(64-(n))))
 
 /* The SHA512 functions. The Choice function is the same as the SHA1
    function f1, and the majority function is the same as the SHA1 f3
 #define Choice(x,y,z)   ( (z) ^ ( (x) & ( (y) ^ (z) ) ) ) 
 #define Majority(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) )
 
-#define S0(x) (ROTR(28,(x)) ^ ROTR(34,(x)) ^ ROTR(39,(x))) 
-#define S1(x) (ROTR(14,(x)) ^ ROTR(18,(x)) ^ ROTR(41,(x)))
+#define S0(x) (ROTL64(36,(x)) ^ ROTL64(30,(x)) ^ ROTL64(25,(x))) 
+#define S1(x) (ROTL64(50,(x)) ^ ROTL64(46,(x)) ^ ROTL64(23,(x)))
 
-#define s0(x) (ROTR(1,(x)) ^ ROTR(8,(x)) ^ SHR(7,(x)))
-#define s1(x) (ROTR(19,(x)) ^ ROTR(61,(x)) ^ SHR(6,(x)))
+#define s0(x) (ROTL64(63,(x)) ^ ROTL64(56,(x)) ^ ((x) >> 7))
+#define s1(x) (ROTL64(45,(x)) ^ ROTL64(3,(x)) ^ ((x) >> 6))
 
 /* The initial expanding function. The hash function is defined over
    an 64-word expanded input array W, where the first 16 are copies of