mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-14 03:17:19 +00:00
Always use utility method in KeyCrypterScrypt for determining the scrypt salt.
This commit is contained in:
@@ -42,7 +42,6 @@ import org.spongycastle.crypto.params.KeyParameter;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -65,11 +64,7 @@ public class ECKeyTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(KeyCrypterScrypt.randomSalt()));
|
||||||
|
|
||||||
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
|
|
||||||
secureRandom.nextBytes(salt);
|
|
||||||
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
|
|
||||||
ScryptParameters scryptParameters = scryptParametersBuilder.build();
|
ScryptParameters scryptParameters = scryptParametersBuilder.build();
|
||||||
keyCrypter = new KeyCrypterScrypt(scryptParameters);
|
keyCrypter = new KeyCrypterScrypt(scryptParameters);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import org.junit.Test;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -50,9 +49,8 @@ public class KeyCrypterScryptTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
|
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder()
|
||||||
new SecureRandom().nextBytes(salt);
|
.setSalt(ByteString.copyFrom(KeyCrypterScrypt.randomSalt()));
|
||||||
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
|
|
||||||
scryptParameters = scryptParametersBuilder.build();
|
scryptParameters = scryptParametersBuilder.build();
|
||||||
|
|
||||||
BriefLogFormatter.init();
|
BriefLogFormatter.init();
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ public class WalletTest extends TestWithWallet {
|
|||||||
private static final CharSequence PASSWORD1 = "my helicopter contains eels";
|
private static final CharSequence PASSWORD1 = "my helicopter contains eels";
|
||||||
private static final CharSequence WRONG_PASSWORD = "nothing noone nobody nowhere";
|
private static final CharSequence WRONG_PASSWORD = "nothing noone nobody nowhere";
|
||||||
|
|
||||||
private SecureRandom secureRandom = new SecureRandom();
|
|
||||||
|
|
||||||
private final Address OTHER_ADDRESS = new ECKey().toAddress(PARAMS);
|
private final Address OTHER_ADDRESS = new ECKey().toAddress(PARAMS);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -2094,9 +2092,8 @@ public class WalletTest extends TestWithWallet {
|
|||||||
|
|
||||||
// Try added an ECKey that was encrypted with a differenct ScryptParameters (i.e. a non-homogenous key).
|
// Try added an ECKey that was encrypted with a differenct ScryptParameters (i.e. a non-homogenous key).
|
||||||
// This is not allowed as the ScryptParameters is stored at the Wallet level.
|
// This is not allowed as the ScryptParameters is stored at the Wallet level.
|
||||||
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
|
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder()
|
||||||
secureRandom.nextBytes(salt);
|
.setSalt(ByteString.copyFrom(KeyCrypterScrypt.randomSalt()));
|
||||||
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
|
|
||||||
Protos.ScryptParameters scryptParameters = scryptParametersBuilder.build();
|
Protos.ScryptParameters scryptParameters = scryptParametersBuilder.build();
|
||||||
KeyCrypter keyCrypterDifferent = new KeyCrypterScrypt(scryptParameters);
|
KeyCrypter keyCrypterDifferent = new KeyCrypterScrypt(scryptParameters);
|
||||||
ECKey ecKeyDifferent = new ECKey();
|
ECKey ecKeyDifferent = new ECKey();
|
||||||
|
|||||||
Reference in New Issue
Block a user