PBKDF2SHA512: simplify F() by using ByteUtils.concat()

This commit is contained in:
Sean Gilligan 2023-09-16 17:05:26 -07:00 committed by Andreas Schildbach
parent 053cd60dc5
commit 3023188541

View File

@ -23,6 +23,7 @@
package org.bitcoinj.crypto;
import org.bitcoinj.base.internal.ByteUtils;
import org.bitcoinj.base.internal.Preconditions;
import javax.crypto.Mac;
@ -88,12 +89,7 @@ public class PBKDF2SHA512 {
for (int j = 0; j < c; j++) {
if (j == 0) {
byte[] baS = S.getBytes(StandardCharsets.UTF_8);
byte[] baI = INT(i);
byte[] baU = new byte[baS.length + baI.length];
System.arraycopy(baS, 0, baU, 0, baS.length);
System.arraycopy(baI, 0, baU, baS.length, baI.length);
byte[] baU = ByteUtils.concat(S.getBytes(StandardCharsets.UTF_8), INT(i));
U_XOR = mac.doFinal(baU);
U_LAST = U_XOR;