diff options
author | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-12-24 17:28:05 +0300 |
---|---|---|
committer | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-12-24 17:28:05 +0300 |
commit | 93e769bfe52d303a33647582dcf136453fedd5b9 (patch) | |
tree | 5ad972293d5d36d721f187d8ecf572f832bf9753 /lib/Crypto | |
parent | 5045c7d931ad1fb13b948993166ade6a39602c32 (diff) |
Dedicated class for crypto parameters
Diffstat (limited to 'lib/Crypto')
-rw-r--r-- | lib/Crypto/CryptArgon2.php | 21 | ||||
-rw-r--r-- | lib/Crypto/CryptBlowfish.php | 8 | ||||
-rw-r--r-- | lib/Crypto/CryptExtendedDES.php | 8 | ||||
-rw-r--r-- | lib/Crypto/CryptSHA256.php | 8 | ||||
-rw-r--r-- | lib/Crypto/CryptSHA512.php | 8 | ||||
-rw-r--r-- | lib/Crypto/IPasswordAlgorithm.php | 3 | ||||
-rw-r--r-- | lib/Crypto/Phpass.php | 8 |
7 files changed, 20 insertions, 44 deletions
diff --git a/lib/Crypto/CryptArgon2.php b/lib/Crypto/CryptArgon2.php index 3c198d4..a1a22e3 100644 --- a/lib/Crypto/CryptArgon2.php +++ b/lib/Crypto/CryptArgon2.php @@ -21,6 +21,7 @@ namespace OCA\UserSQL\Crypto; +use OCA\UserSQL\Model\CryptoParam; use OCP\IL10N; /** @@ -106,18 +107,14 @@ class CryptArgon2 extends AbstractAlgorithm public function configuration() { return [ - [ - "name" => "memoryCost", "visible_name" => "Memory cost (KiB)", - "default" => PASSWORD_ARGON2_DEFAULT_MEMORY_COST, "min" => 1, "max" => 1048576 - ], - [ - "name" => "timeCost", "visible_name" => "Time cost", - "default" => PASSWORD_ARGON2_DEFAULT_TIME_COST, "min" => 1, "max" => 1024 - ], - [ - "name" => "threads", "visible_name" => "Threads", - "default" => PASSWORD_ARGON2_DEFAULT_THREADS, "min" => 1, "max" => 1024 - ] + new CryptoParam( + "Memory cost (KiB)", PASSWORD_ARGON2_DEFAULT_MEMORY_COST, 1, + 1048576 + ), + new CryptoParam( + "Time cost", PASSWORD_ARGON2_DEFAULT_TIME_COST, 1, 1024 + ), + new CryptoParam("Threads", PASSWORD_ARGON2_DEFAULT_THREADS, 1, 1024) ]; } diff --git a/lib/Crypto/CryptBlowfish.php b/lib/Crypto/CryptBlowfish.php index 3d48ade..a76d187 100644 --- a/lib/Crypto/CryptBlowfish.php +++ b/lib/Crypto/CryptBlowfish.php @@ -21,6 +21,7 @@ namespace OCA\UserSQL\Crypto; +use OCA\UserSQL\Model\CryptoParam; use OCP\IL10N; /** @@ -72,12 +73,7 @@ class CryptBlowfish extends AbstractAlgorithm */ public function configuration() { - return [ - [ - "name" => "cost", "visible_name" => "Cost", "default" => 10, - "min" => 4, "max" => 31 - ] - ]; + return [new CryptoParam("Cost", 10, 4, 31)]; } /** diff --git a/lib/Crypto/CryptExtendedDES.php b/lib/Crypto/CryptExtendedDES.php index 235e563..6bd2f30 100644 --- a/lib/Crypto/CryptExtendedDES.php +++ b/lib/Crypto/CryptExtendedDES.php @@ -21,6 +21,7 @@ namespace OCA\UserSQL\Crypto; +use OCA\UserSQL\Model\CryptoParam; use OCP\IL10N; /** @@ -53,12 +54,7 @@ class CryptExtendedDES extends AbstractCrypt */ public function configuration() { - return [ - [ - "name" => "iterations", "visible_name" => "Iterations", "default" => 1000, - "min" => 0, "max" => 16777215 - ] - ]; + return [new CryptoParam("Iterations", 1000, 0, 16777215)]; } /** diff --git a/lib/Crypto/CryptSHA256.php b/lib/Crypto/CryptSHA256.php index 75515eb..72a372d 100644 --- a/lib/Crypto/CryptSHA256.php +++ b/lib/Crypto/CryptSHA256.php @@ -21,6 +21,7 @@ namespace OCA\UserSQL\Crypto; +use OCA\UserSQL\Model\CryptoParam; use OCP\IL10N; /** @@ -54,12 +55,7 @@ class CryptSHA256 extends AbstractCrypt */ public function configuration() { - return [ - [ - "name" => "rounds", "visible_name" => "Rounds", "default" => 5000, - "min" => 1000, "max" => 999999999 - ] - ]; + return [new CryptoParam("Rounds", 5000, 1000, 999999999)]; } /** diff --git a/lib/Crypto/CryptSHA512.php b/lib/Crypto/CryptSHA512.php index b638175..2cc9a33 100644 --- a/lib/Crypto/CryptSHA512.php +++ b/lib/Crypto/CryptSHA512.php @@ -21,6 +21,7 @@ namespace OCA\UserSQL\Crypto; +use OCA\UserSQL\Model\CryptoParam; use OCP\IL10N; /** @@ -54,12 +55,7 @@ class CryptSHA512 extends AbstractCrypt */ public function configuration() { - return [ - [ - "name" => "rounds", "visible_name" => "Rounds", "default" => 5000, - "min" => 1000, "max" => 999999999 - ] - ]; + return [new CryptoParam("Rounds", 5000, 1000, 999999999)]; } /** diff --git a/lib/Crypto/IPasswordAlgorithm.php b/lib/Crypto/IPasswordAlgorithm.php index 5650c17..54c70b1 100644 --- a/lib/Crypto/IPasswordAlgorithm.php +++ b/lib/Crypto/IPasswordAlgorithm.php @@ -61,8 +61,7 @@ interface IPasswordAlgorithm /** * Configuration for the algorithm. - * The return array should contain entries which define keys: - * name, visible_name, default, min, max. + * The return array should contain entries of class <code>CryptoParam</code> * * @return array The configuration array. */ diff --git a/lib/Crypto/Phpass.php b/lib/Crypto/Phpass.php index 3693a6e..b038d3f 100644 --- a/lib/Crypto/Phpass.php +++ b/lib/Crypto/Phpass.php @@ -21,6 +21,7 @@ namespace OCA\UserSQL\Crypto; +use OCA\UserSQL\Model\CryptoParam; use OCP\IL10N; /** @@ -160,12 +161,7 @@ class Phpass extends AbstractAlgorithm */ public function configuration() { - return [ - [ - "name" => "iterations", "visible_name" => "Iterations (log2)", - "default" => 8, "min" => 4, "max" => 31 - ] - ]; + return [new CryptoParam("Iterations (log2)", 8, 4, 31)]; } /** |