mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01:00
PBKDF2SHA512: move dkLen check out of try/catch
It throws an exception so doesn't need an if/else and it also doesn't need to be in the try.
This commit is contained in:
parent
4e039df446
commit
140deb0669
1 changed files with 8 additions and 9 deletions
|
@ -43,17 +43,16 @@ public class PBKDF2SHA512 {
|
|||
public static byte[] derive(String P, String S, int c, int dkLen) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
if (dkLen > ((Math.pow(2, 32)) - 1) * H_LEN) {
|
||||
throw new IllegalArgumentException("derived key too long");
|
||||
}
|
||||
try {
|
||||
if (dkLen > ((Math.pow(2, 32)) - 1) * H_LEN) {
|
||||
throw new IllegalArgumentException("derived key too long");
|
||||
} else {
|
||||
int l = (int) Math.ceil((double) dkLen / (double) H_LEN);
|
||||
// int r = dkLen - (l-1)*hLen;
|
||||
int l = (int) Math.ceil((double) dkLen / (double) H_LEN);
|
||||
// int r = dkLen - (l-1)*hLen;
|
||||
|
||||
for (int i = 1; i <= l; i++) {
|
||||
byte[] T = F(P, S, c, i);
|
||||
baos.write(T);
|
||||
}
|
||||
for (int i = 1; i <= l; i++) {
|
||||
byte[] T = F(P, S, c, i);
|
||||
baos.write(T);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
Loading…
Add table
Reference in a new issue