From cb884d97cb380bc9b4dad03f4d2bf039605d45b5 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 6 Apr 2021 11:46:51 +0200 Subject: [PATCH] request strongest instance of securerandom when generating a seed --- .../sparrow/control/MnemonicKeystoreImportPane.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java index 3ea899f1..cfeeb4a2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java @@ -30,6 +30,7 @@ import org.controlsfx.validation.ValidationSupport; import org.controlsfx.validation.Validator; import org.controlsfx.validation.decoration.StyleClassValidationDecoration; +import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; @@ -275,7 +276,14 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane { int mnemonicSeedLength = wordEntriesProperty.get().size() * 11; int entropyLength = mnemonicSeedLength - (mnemonicSeedLength/33); - DeterministicSeed deterministicSeed = new DeterministicSeed(new SecureRandom(), entropyLength, ""); + SecureRandom secureRandom; + try { + secureRandom = SecureRandom.getInstanceStrong(); + } catch(NoSuchAlgorithmException e) { + secureRandom = new SecureRandom(); + } + + DeterministicSeed deterministicSeed = new DeterministicSeed(secureRandom, entropyLength, ""); generatedMnemonicCode = deterministicSeed.getMnemonicCode(); displayMnemonicCode();