mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-05 03:26:43 +00:00
more clearing private bits
This commit is contained in:
parent
d2bd335e76
commit
06de1d7e14
6 changed files with 20 additions and 2 deletions
|
@ -111,6 +111,7 @@ public class Utils {
|
||||||
int srcPos = isFirstByteOnlyForSign ? 1 : 0;
|
int srcPos = isFirstByteOnlyForSign ? 1 : 0;
|
||||||
int destPos = numBytes - length;
|
int destPos = numBytes - length;
|
||||||
System.arraycopy(src, srcPos, dest, destPos, length);
|
System.arraycopy(src, srcPos, dest, destPos, length);
|
||||||
|
Arrays.fill(src, (byte)0);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ECIESKeyCrypter implements AsymmetricKeyCrypter {
|
||||||
byte[] hmacInput = Arrays.copyOfRange(decoded, 0, decoded.length - 32);
|
byte[] hmacInput = Arrays.copyOfRange(decoded, 0, decoded.length - 32);
|
||||||
|
|
||||||
if(!Arrays.equals(mac, hmac256(key_m, hmacInput))) {
|
if(!Arrays.equals(mac, hmac256(key_m, hmacInput))) {
|
||||||
throw new InvalidPasswordException();
|
throw new InvalidPasswordException("The password was invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
return aesKeyCrypter.decrypt(new EncryptedData(iv, ciphertext, null, null), new Key(key_e, null, null));
|
return aesKeyCrypter.decrypt(new EncryptedData(iv, ciphertext, null, null), new Key(key_e, null, null));
|
||||||
|
|
|
@ -699,6 +699,12 @@ public class ECKey implements EncryptableItem {
|
||||||
return Utils.bigIntegerToBytes(getPrivKey(), 32);
|
return Utils.bigIntegerToBytes(getPrivKey(), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
for(int i = 0; i < priv.bitLength(); i++) {
|
||||||
|
priv.clearBit(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the creation time of this key or zero if the key was deserialized from a version that did not store
|
* Returns the creation time of this key or zero if the key was deserialized from a version that did not store
|
||||||
* that data.
|
* that data.
|
||||||
|
|
|
@ -27,6 +27,5 @@ public class Key {
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
Arrays.fill(keyBytes, (byte)0);
|
Arrays.fill(keyBytes, (byte)0);
|
||||||
Arrays.fill(salt, (byte)0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,4 +202,10 @@ public class Keystore {
|
||||||
seed = seed.decrypt(key);
|
seed = seed.decrypt(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearPrivate() {
|
||||||
|
if(hasSeed()) {
|
||||||
|
seed.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,4 +198,10 @@ public class Wallet {
|
||||||
keystore.decrypt(key);
|
keystore.decrypt(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearPrivate() {
|
||||||
|
for(Keystore keystore : keystores) {
|
||||||
|
keystore.clearPrivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue