mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
KeyCrypterScrypt: Log time taken for deriving key from password.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package org.bitcoinj.crypto;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.lambdaworks.crypto.SCrypt;
|
||||
import org.bitcoinj.core.Utils;
|
||||
@@ -154,7 +155,10 @@ public class KeyCrypterScrypt implements KeyCrypter {
|
||||
log.warn("You are using a ScryptParameters with no salt. Your encryption may be vulnerable to a dictionary attack.");
|
||||
}
|
||||
|
||||
final Stopwatch watch = Stopwatch.createStarted();
|
||||
byte[] keyBytes = SCrypt.scrypt(passwordBytes, salt, (int) scryptParameters.getN(), scryptParameters.getR(), scryptParameters.getP(), KEY_LENGTH);
|
||||
watch.stop();
|
||||
log.info("Deriving key took {} for {} scrypt iterations.", watch, scryptParameters.getN());
|
||||
return new KeyParameter(keyBytes);
|
||||
} catch (Exception e) {
|
||||
throw new KeyCrypterException("Could not generate key from password and salt.", e);
|
||||
|
Reference in New Issue
Block a user