Skip to content

Commit

Permalink
8294073: Performance improvement for message digest implementations
Browse files Browse the repository at this point in the history
Reviewed-by: jjiang
  • Loading branch information
XueleiFan committed Nov 21, 2022
1 parent 57f5cfd commit b366d17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/java.base/share/classes/sun/security/provider/SHA2.java
Expand Up @@ -195,10 +195,12 @@ private void implCompress0(byte[] buf, int ofs) {
Integer.rotateRight(e, 25);

// ch(x,y,z) = (x and y) xor ((complement x) and z)
int ch_efg = (e & f) ^ ((~e) & g);
// = z xor (x and (y xor z));
int ch_efg = g ^ (e & (f ^ g));

// maj(x,y,z) = (x and y) xor (x and z) xor (y and z)
int maj_abc = (a & b) ^ (a & c) ^ (b & c);
// = (x and y) xor ((x xor y) and z)
int maj_abc = (a & b) ^ ((a ^ b) & c);

int T1 = h + sigma1_e + ch_efg + ROUND_CONSTS[i] + W[i];
int T2 = sigma0_a + maj_abc;
Expand Down

1 comment on commit b366d17

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.