Skip to content

Commit

Permalink
second iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpowers committed Jul 12, 2022
1 parent e93aa8e commit 919851a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/java.base/share/classes/sun/security/provider/MD4.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ void implDigest(byte[] out, int ofs) {

private static int FF(int a, int b, int c, int d, int x, int s) {
a += ((b & c) | ((~b) & d)) + x;
return Integer.rotateRight(a, (32 - s));
return Integer.rotateLeft(a, s);
}

private static int GG(int a, int b, int c, int d, int x, int s) {
a += ((b & c) | (b & d) | (c & d)) + x + 0x5a827999;
return Integer.rotateRight(a, (32 - s));
return Integer.rotateLeft(a, s);
}

private static int HH(int a, int b, int c, int d, int x, int s) {
a += ((b ^ c) ^ d) + x + 0x6ed9eba1;
return Integer.rotateRight(a, (32 - s));
return Integer.rotateLeft(a, s);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/java.base/share/classes/sun/security/provider/MD5.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,22 @@ void implDigest(byte[] out, int ofs) {

private static int FF(int a, int b, int c, int d, int x, int s, int ac) {
a += ((b & c) | ((~b) & d)) + x + ac;
return (Integer.rotateRight(a, (32 - s)) + b);
return Integer.rotateLeft(a, s) + b;
}

private static int GG(int a, int b, int c, int d, int x, int s, int ac) {
a += ((b & d) | (c & (~d))) + x + ac;
return (Integer.rotateRight(a, (32 - s)) + b);
return Integer.rotateLeft(a, s) + b;
}

private static int HH(int a, int b, int c, int d, int x, int s, int ac) {
a += ((b ^ c) ^ d) + x + ac;
return (Integer.rotateRight(a, (32 - s)) + b);
return Integer.rotateLeft(a, s) + b;
}

private static int II(int a, int b, int c, int d, int x, int s, int ac) {
a += (c ^ (b | (~d))) + x + ac;
return (Integer.rotateRight(a, (32 - s)) + b);
return Integer.rotateLeft(a, s) + b;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/java.base/share/classes/sun/security/provider/SHA.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void implCompress0(byte[] buf, int ofs) {
// the buffer
for (int t = 16; t <= 79; t++) {
int temp = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
W[t] = Integer.rotateRight(temp, 31);
W[t] = Integer.rotateLeft(temp, 1);
}

int a = state[0];
Expand All @@ -167,44 +167,44 @@ private void implCompress0(byte[] buf, int ofs) {

// Round 1
for (int i = 0; i < 20; i++) {
int temp = Integer.rotateRight(a, (32-5)) +
int temp = Integer.rotateLeft(a, 5) +
((b&c)|((~b)&d))+ e + W[i] + round1_kt;
e = d;
d = c;
c = Integer.rotateRight(b, (32-30));
c = Integer.rotateLeft(b, 30);
b = a;
a = temp;
}

// Round 2
for (int i = 20; i < 40; i++) {
int temp = Integer.rotateRight(a, (32-5)) +
int temp = Integer.rotateLeft(a, 5) +
(b ^ c ^ d) + e + W[i] + round2_kt;
e = d;
d = c;
c = Integer.rotateRight(b, (32-30));
c = Integer.rotateLeft(b, 30);
b = a;
a = temp;
}

// Round 3
for (int i = 40; i < 60; i++) {
int temp = Integer.rotateRight(a, (32-5)) +
int temp = Integer.rotateLeft(a, 5) +
((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;
e = d;
d = c;
c = Integer.rotateRight(b, (32-30));
c = Integer.rotateLeft(b, 30);
b = a;
a = temp;
}

// Round 4
for (int i = 60; i < 80; i++) {
int temp = Integer.rotateRight(a, (32-5)) +
int temp = Integer.rotateLeft(a, 5) +
(b ^ c ^ d) + e + W[i] + round4_kt;
e = d;
d = c;
c = Integer.rotateRight(b, (32-30));
c = Integer.rotateLeft(b, 30);
b = a;
a = temp;
}
Expand Down

0 comments on commit 919851a

Please sign in to comment.