mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-30 19:41:24 +00:00
ECKey: Decrypted keys must always be 32 bytes long, otherwise likely the encryption key was wrong.
This commit is contained in:
@@ -1107,6 +1107,9 @@ public class ECKey implements EncryptableItem {
|
|||||||
throw new KeyCrypterException("The keyCrypter being used to decrypt the key is different to the one that was used to encrypt it");
|
throw new KeyCrypterException("The keyCrypter being used to decrypt the key is different to the one that was used to encrypt it");
|
||||||
checkState(encryptedPrivateKey != null, "This key is not encrypted");
|
checkState(encryptedPrivateKey != null, "This key is not encrypted");
|
||||||
byte[] unencryptedPrivateKey = keyCrypter.decrypt(encryptedPrivateKey, aesKey);
|
byte[] unencryptedPrivateKey = keyCrypter.decrypt(encryptedPrivateKey, aesKey);
|
||||||
|
if (unencryptedPrivateKey.length != 32)
|
||||||
|
throw new KeyCrypterException.InvalidCipherText(
|
||||||
|
"Decrypted key must be 32 bytes long, but is " + unencryptedPrivateKey.length);
|
||||||
ECKey key = ECKey.fromPrivate(unencryptedPrivateKey);
|
ECKey key = ECKey.fromPrivate(unencryptedPrivateKey);
|
||||||
if (!isCompressed())
|
if (!isCompressed())
|
||||||
key = key.decompress();
|
key = key.decompress();
|
||||||
|
Reference in New Issue
Block a user