From c04d31f82f66f00058062999979444fd7fffb0a5 Mon Sep 17 00:00:00 2001 From: Macha-orange <69054565+Macha-orange@users.noreply.github.com> Date: Wed, 28 Jul 2021 19:33:41 +0200 Subject: [PATCH] Add PBKDF2 customization - Add a "PBKDF2 rounds" button inside "Show Entropy Details" with values : 2048, 4096, 8192, 16384, 32768, custom. - Add hidden button for custom iterations. Accept number. - Add a Warning message above BIP39 seed when using anything other than 2048 PBKDF2 iterations. - Add a "PBKDF2" section in the bottom for detail. --- src/index.html | 25 +++++++++++++++++++++++++ src/js/index.js | 23 +++++++++++++++++++++++ src/js/jsbip39.js | 4 +++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 854043b..716c133 100644 --- a/src/index.html +++ b/src/index.html @@ -119,6 +119,18 @@

+ +
+ + +

Valid entropy values include:

@@ -198,6 +210,13 @@
+
@@ -964,6 +983,12 @@

+

PBKDF2

+

What is PBKDF2 (Password Based Key Derivation Function 2) ?

+

Please refer to this wikipedia article for more detail. + Mail about PBKDF2 security here.

+

Wallet software that implement BIP39 only use 2048 iterations as a norm. Increasing this parameter will increase security against brute force attack, but you will need to store this new parameter. However, as long as you back up your BIP39 seed there will not be risk to lost your fund. To access them with custom PBKDF2 iterations, use this file (or other) to compute your targeted BIP39 seed.

+

Using less than 2048 PBKDF2 iterations is insecure without strong optional BIP39 Passphrase.

License

Please refer to the software license for more detail. diff --git a/src/js/index.js b/src/js/index.js index e46c3d5..e6b4d91 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -44,6 +44,9 @@ DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes"); DOM.entropyChecksum = DOM.entropyContainer.find(".checksum"); DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); + DOM.pbkdf2Rounds = DOM.entropyContainer.find(".pbkdf2-rounds"); + DOM.pbkdf2CustomInput = DOM.entropyContainer.find("#pbkdf2-custom-input"); + DOM.pbkdf2InfosDanger = $(".PBKDF2-infos-danger"); DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning"); DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); DOM.phrase = $(".phrase"); @@ -145,6 +148,8 @@ DOM.useEntropy.on("change", setEntropyVisibility); DOM.entropy.on("input", delayedEntropyChanged); DOM.entropyMnemonicLength.on("change", entropyChanged); + DOM.pbkdf2Rounds.on("change", pbkdf2RoundsChanged); + DOM.pbkdf2CustomInput.on("change", pbkdf2RoundsChanged); DOM.entropyTypeInputs.on("change", entropyTypeChanged); DOM.phrase.on("input", delayedPhraseChanged); DOM.showSplitMnemonic.on("change", toggleSplitMnemonic); @@ -336,6 +341,24 @@ entropyChangeTimeoutEvent = setTimeout(entropyChanged, 400); } + function pbkdf2RoundsChanged() { + if (DOM.pbkdf2Rounds.val() == "custom") { + PBKDF2_ROUNDS = DOM.pbkdf2CustomInput.val(); + DOM.pbkdf2CustomInput.removeClass("hidden"); + } else { + PBKDF2_ROUNDS = DOM.pbkdf2Rounds.val(); + DOM.pbkdf2CustomInput.addClass("hidden"); + } + ispbkdf2Rounds2048(); + phraseChanged(); + } + function ispbkdf2Rounds2048() { + if (PBKDF2_ROUNDS == 2048) { + DOM.pbkdf2InfosDanger.addClass("hidden"); + } else { + DOM.pbkdf2InfosDanger.removeClass("hidden"); + } + } function entropyChanged() { // If blank entropy, clear mnemonic, addresses, errors if (DOM.entropy.val().trim().length == 0) { diff --git a/src/js/jsbip39.js b/src/js/jsbip39.js index 1e52d9d..00d0523 100644 --- a/src/js/jsbip39.js +++ b/src/js/jsbip39.js @@ -28,7 +28,9 @@ var Mnemonic = function(language) { - var PBKDF2_ROUNDS = 2048; + var DOM = {}; + DOM.entropyContainer = $(".entropy-container"); + PBKDF2_ROUNDS = DOM.entropyContainer.find(".pbkdf2-rounds").val(); var RADIX = 2048; var self = this;