From fca315d3a4edf931a250281806c63c28c0964fe5 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 9 Oct 2017 11:54:46 +0200 Subject: [PATCH] Encryption benchmark: highlight default settings --- plugins/dynamix/include/CryptoBenchmark.php | 8 +++++++- plugins/dynamix/include/update.crypto.php | 12 +++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix/include/CryptoBenchmark.php b/plugins/dynamix/include/CryptoBenchmark.php index 84d108256..d6bd43a17 100644 --- a/plugins/dynamix/include/CryptoBenchmark.php +++ b/plugins/dynamix/include/CryptoBenchmark.php @@ -10,6 +10,12 @@ * all copies or substantial portions of the Software. */ ?> + @@ -26,7 +32,7 @@ var test = 'sha1,sha256,sha512,ripemd160,whirlpool,aes-cbc:128,serpent-cbc:128,t function benchmark(index,last){ if (index > last) return; - $.get('/webGui/include/update.crypto.php',{index:index,test:test},function(data){ + $.get('/webGui/include/update.crypto.php',{index:index,test:test,luks:':',hash:''},function(data){ $('pre').append(data); benchmark(index+1,last); }); diff --git a/plugins/dynamix/include/update.crypto.php b/plugins/dynamix/include/update.crypto.php index 08883990e..76088d168 100644 --- a/plugins/dynamix/include/update.crypto.php +++ b/plugins/dynamix/include/update.crypto.php @@ -17,11 +17,17 @@ if ($index < count($tests)) { $test = $tests[$index]; list($name,$size) = explode(':',$test); if (!$size) { + $default = $test==$_GET['hash']; if ($index>0) $test .= '|tail -1'; - echo shell_exec("/usr/sbin/cryptsetup benchmark -h $test"); + if ($default) echo ""; + echo preg_replace(['/^(# Tests.*\n)/','/\n$/'],["$1\n",""],shell_exec("/usr/sbin/cryptsetup benchmark -h $test")); + echo $default ? " (default)\n" : "\n"; } else { + $default = $test==$_GET['luks']; if ($index>5) $size .= '|tail -1'; - echo preg_replace('/^# Tests.*\n/',"\n",shell_exec("/usr/sbin/cryptsetup benchmark -c $name -s $size")); + if ($default) echo ""; + echo preg_replace(['/^# Tests.*\n/','/\n$/'],["\n",""],shell_exec("/usr/sbin/cryptsetup benchmark -c $name -s $size")); + echo $default ? " (default)\n" : "\n"; } } else { $bm = popen('/usr/sbin/cryptsetup --help','r'); @@ -32,6 +38,6 @@ if ($index < count($tests)) { elseif (strpos($text,'LUKS1:')!==false) echo str_replace("\t"," ",$text); } pclose($bm); - echo "
"; + echo "
"; } ?>