]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Change entropy Strength to Time To Crack
authorIan Coleman <coleman.ian@gmail.com>
Fri, 16 Jun 2017 23:34:50 +0000 (09:34 +1000)
committerIan Coleman <coleman.ian@gmail.com>
Tue, 20 Jun 2017 00:58:31 +0000 (10:58 +1000)
See issue 78

src/index.html
src/js/index.js
tests.js

index bc8ffba1d4780e707e6674e9e342da0967a83c07..5edd68ec3972ab17ae94c7d5b71964d182786afc 100644 (file)
                                 <div class="col-sm-7">
                                     <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards" data-translate-placeholder></textarea>
                                     <div class="row">
-                                        <label class="col-sm-3 control-label" data-translate>Strength</label>
-                                        <div class="strength col-sm-3 form-control-static"></div>
+                                        <label class="col-sm-3 control-label" data-translate><span class="more-info" data-translate-title title="Based on estimates from zxcvbn using Filtered Entropy">Time To Crack</span></label>
+                                        <div class="crack-time col-sm-3 form-control-static"></div>
                                         <label class="col-sm-3 control-label" data-translate>Event Count</label>
                                         <div class="event-count col-sm-3 form-control-static"></div>
                                     </div>
index 3b86e42fb3e8c2c11a8f3bee5fe8d32efb10ab79..2bb766de96f4ea6eb10d8630a45e5816aa380241 100644 (file)
@@ -30,7 +30,7 @@
     DOM.entropy = $(".entropy");
     DOM.entropyFiltered = DOM.entropyContainer.find(".filtered");
     DOM.entropyType = DOM.entropyContainer.find(".type");
-    DOM.entropyStrength = DOM.entropyContainer.find(".strength");
+    DOM.entropyCrackTime = DOM.entropyContainer.find(".crack-time");
     DOM.entropyEventCount = DOM.entropyContainer.find(".event-count");
     DOM.entropyBits = DOM.entropyContainer.find(".bits");
     DOM.entropyBitsPerEvent = DOM.entropyContainer.find(".bits-per-event");
     }
 
     function clearEntropyFeedback() {
-        DOM.entropyStrength.text("...");
+        DOM.entropyCrackTime.text("...");
         DOM.entropyType.text("");
         DOM.entropyWordCount.text("0");
         DOM.entropyEventCount.text("0");
 
     function showEntropyFeedback(entropy) {
         var numberOfBits = entropy.binaryStr.length;
-        var strength = "extremely weak";
-        if (numberOfBits >= 64) {
-            strength = "very weak";
-        }
-        if (numberOfBits >= 96) {
-            strength = "weak";
-        }
-        if (numberOfBits >= 128) {
-            strength = "strong";
-        }
-        if (numberOfBits >= 160) {
-            strength = "very strong";
-        }
-        if (numberOfBits >= 192) {
-            strength = "extremely strong";
-        }
-        // If time to crack is less than one day, and password is considered
-        // strong or better based on the number of bits, rename strength to
-        // 'easily cracked'.
+        var timeToCrack = "unknown";
         try {
             var z = zxcvbn(entropy.base.parts.join(""));
-            var timeToCrack = z.crack_times_seconds.offline_fast_hashing_1e10_per_second;
-            if (timeToCrack < 86400 && entropy.binaryStr.length >= 128) {
-                strength = "easily cracked";
-                if (z.feedback.warning != "") {
-                    strength = strength + " - " + z.feedback.warning;
-                };
-            }
+            timeToCrack = z.crack_times_display.offline_fast_hashing_1e10_per_second;
+            if (z.feedback.warning != "") {
+                timeToCrack = timeToCrack + " - " + z.feedback.warning;
+            };
         }
         catch (e) {
-            strength = "unknown";
             console.log("Error detecting entropy strength with zxcvbn:");
             console.log(e);
         }
         var bitsPerEvent = entropy.bitsPerEvent.toFixed(2);
         DOM.entropyFiltered.html(entropy.cleanHtml);
         DOM.entropyType.text(entropyTypeStr);
-        DOM.entropyStrength.text(strength);
+        DOM.entropyCrackTime.text(timeToCrack);
         DOM.entropyEventCount.text(entropy.base.ints.length);
         DOM.entropyBits.text(numberOfBits);
         DOM.entropyWordCount.text(wordCount);
index f346729f00e0a0e0bb8012aa6bd46b1556db40c2..c2f2cb5b2716543c24b699ac2d89ce0edb404182 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -2824,7 +2824,7 @@ page.open(url, function(status) {
             events: 1,
             bits: 4,
             words: 0,
-            strength: "extremely weak",
+            strength: "less than a second",
         },
         {
             entropy: "AAAAAAAA",
@@ -2833,7 +2833,7 @@ page.open(url, function(status) {
             events: 8,
             bits: 32,
             words: 3,
-            strength: "extremely weak",
+            strength: "less than a second - Repeats like \"aaa\" are easy to guess",
         },
         {
             entropy: "AAAAAAAA B",
@@ -2842,7 +2842,7 @@ page.open(url, function(status) {
             events: 9,
             bits: 36,
             words: 3,
-            strength: "extremely weak",
+            strength: "less than a second - Repeats like \"aaa\" are easy to guess",
         },
         {
             entropy: "AAAAAAAA BBBBBBBB",
@@ -2851,7 +2851,7 @@ page.open(url, function(status) {
             events: 16,
             bits: 64,
             words: 6,
-            strength: "very weak",
+            strength: "less than a second - Repeats like \"aaa\" are easy to guess",
         },
         {
             entropy: "AAAAAAAA BBBBBBBB CCCCCCCC",
@@ -2860,7 +2860,7 @@ page.open(url, function(status) {
             events: 24,
             bits: 96,
             words: 9,
-            strength: "weak",
+            strength: "less than a second",
         },
         {
             entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD",
@@ -2869,7 +2869,7 @@ page.open(url, function(status) {
             events: 32,
             bits: 128,
             words: 12,
-            strength: "easily cracked",
+            strength: "2 minutes",
         },
         {
             entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA",
@@ -2878,7 +2878,7 @@ page.open(url, function(status) {
             events: 32,
             bits: 128,
             words: 12,
-            strength: "strong",
+            strength: "2 days",
         },
         {
             entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE",
@@ -2887,7 +2887,7 @@ page.open(url, function(status) {
             events: 40,
             bits: 160,
             words: 15,
-            strength: "very strong",
+            strength: "3 years",
         },
         {
             entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE FFFFFFFF",
@@ -2896,7 +2896,7 @@ page.open(url, function(status) {
             events: 48,
             bits: 192,
             words: 18,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         {
             entropy: "7d",
@@ -2904,7 +2904,7 @@ page.open(url, function(status) {
             events: 1,
             bits: 5,
             words: 0,
-            strength: "extremely weak",
+            strength: "less than a second",
         },
         {
             entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
@@ -2912,7 +2912,7 @@ page.open(url, function(status) {
             events: 52,
             bits: 225,
             words: 21,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         {
             entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
@@ -2920,7 +2920,7 @@ page.open(url, function(status) {
             events: 53,
             bits: 254,
             words: 21,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         {
             entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
@@ -2928,7 +2928,7 @@ page.open(url, function(status) {
             events: 53,
             bits: 254,
             words: 21,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         {
             entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
@@ -2936,7 +2936,7 @@ page.open(url, function(status) {
             events: 53,
             bits: 264,
             words: 24,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         // Next test was throwing uncaught error in zxcvbn
         // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
@@ -2946,7 +2946,7 @@ page.open(url, function(status) {
             events: 104,
             bits: 499,
             words: 45,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         // Case insensitivity to duplicate cards
         {
@@ -2955,7 +2955,7 @@ page.open(url, function(status) {
             events: 2,
             bits: 9,
             words: 0,
-            strength: "extremely weak",
+            strength: "less than a second",
         },
         {
             entropy: "ASas",
@@ -2963,7 +2963,7 @@ page.open(url, function(status) {
             events: 2,
             bits: 9,
             words: 0,
-            strength: "extremely weak",
+            strength: "less than a second",
         },
         // Missing cards are detected
         {
@@ -2972,7 +2972,7 @@ page.open(url, function(status) {
             events: 51,
             bits: 221,
             words: 18,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         {
             entropy: "ac2c3c4c5c6c7c8c  tcjcqckcad2d3d4d  6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
@@ -2980,7 +2980,7 @@ page.open(url, function(status) {
             events: 50,
             bits: 216,
             words: 18,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         {
             entropy: "ac2c3c4c5c6c7c8c  tcjcqckcad2d3d4d  6d7d8d9dtdjd  kdah2h3h  5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
@@ -2988,7 +2988,7 @@ page.open(url, function(status) {
             events: 48,
             bits: 208,
             words: 18,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         // More than six missing cards does not show message
         {
@@ -2997,7 +2997,7 @@ page.open(url, function(status) {
             events: 45,
             bits: 195,
             words: 18,
-            strength: "extremely strong",
+            strength: "centuries",
         },
         // Multiple decks of cards increases bits per event
         {
@@ -3041,7 +3041,7 @@ page.open(url, function(status) {
             events: 33,
             bits: 184,
             bitsPerEvent: 5.59,
-            strength: 'easily cracked - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
+            strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
         },
     ];
     // use entropy