mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8252204: AArch64: Implement SHA3 accelerator/intrinsic
Co-authored-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Co-authored-by: Dong Bo <dongbo4@huawei.com> Reviewed-by: aph, kvn
This commit is contained in:
parent
7d3d4daefd
commit
b25d894015
36 changed files with 1243 additions and 255 deletions
|
@ -25,6 +25,7 @@
|
|||
|
||||
package sun.security.provider;
|
||||
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
import static sun.security.provider.ByteArrayAccess.*;
|
||||
import java.nio.*;
|
||||
import java.util.*;
|
||||
|
@ -73,15 +74,25 @@ abstract class SHA3 extends DigestBase {
|
|||
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) {
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
state[i] ^= b[ofs++];
|
||||
}
|
||||
keccak();
|
||||
implCompressCheck(b, ofs);
|
||||
implCompress0(b, ofs);
|
||||
}
|
||||
|
||||
@IntrinsicCandidate
|
||||
private void implCompress0(byte[] b, int ofs) {
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
state[i] ^= b[ofs++];
|
||||
}
|
||||
keccak();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,10 +105,7 @@ abstract class SHA3 extends DigestBase {
|
|||
if (numOfPadding < 1) {
|
||||
throw new ProviderException("Incorrect pad size: " + numOfPadding);
|
||||
}
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
state[i] ^= buffer[i];
|
||||
}
|
||||
keccak();
|
||||
implCompress(buffer, 0);
|
||||
System.arraycopy(state, 0, out, ofs, engineGetDigestLength());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue