< prev index next >

src/java.base/share/classes/sun/security/provider/SHA3.java

Print this page
rev 60737 : 8252204: AArch64: Implement SHA3 accelerator/intrinsic
Reviewed-by: duke
Contributed-by: dongbo4@huawei.com

*** 23,32 **** --- 23,33 ---- * questions. */ package sun.security.provider; + import jdk.internal.HotSpotIntrinsicCandidate; import static sun.security.provider.ByteArrayAccess.*; import java.nio.*; import java.util.*; import java.security.*;
*** 71,85 **** --- 72,96 ---- SHA3(String name, int digestLength, byte suffix, int c) { super(name, digestLength, (WIDTH - c)); this.suffix = suffix; } + private void implCompressCheck(byte[] b, int ofs) { + Objects.requireNonNull(b); + } + /** * Core compression function. Processes blockSize bytes at a time * and updates the state of this object. */ void implCompress(byte[] b, int ofs) { + implCompressCheck(b, ofs); + implCompress0(b, ofs); + } + + @HotSpotIntrinsicCandidate + private void implCompress0(byte[] b, int ofs) { for (int i = 0; i < buffer.length; i++) { state[i] ^= b[ofs++]; } keccak(); }
*** 92,105 **** int numOfPadding = setPaddingBytes(suffix, buffer, (int)(bytesProcessed % buffer.length)); if (numOfPadding < 1) { throw new ProviderException("Incorrect pad size: " + numOfPadding); } ! for (int i = 0; i < buffer.length; i++) { ! state[i] ^= buffer[i]; ! } ! keccak(); System.arraycopy(state, 0, out, ofs, engineGetDigestLength()); } /** * Resets the internal state to start a new hash. --- 103,113 ---- int numOfPadding = setPaddingBytes(suffix, buffer, (int)(bytesProcessed % buffer.length)); if (numOfPadding < 1) { throw new ProviderException("Incorrect pad size: " + numOfPadding); } ! implCompress(buffer, 0); System.arraycopy(state, 0, out, ofs, engineGetDigestLength()); } /** * Resets the internal state to start a new hash.
< prev index next >