@@ -13,6 +13,9 @@ discard block |
||
13 | 13 | private $salt; |
14 | 14 | private $iv; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $passphrase |
|
18 | + */ |
|
16 | 19 | public function __construct($passphrase) |
17 | 20 | { |
18 | 21 | $this->passphrase = $passphrase; |
@@ -45,7 +48,7 @@ discard block |
||
45 | 48 | /** |
46 | 49 | * Decrypt the encrypted string |
47 | 50 | * |
48 | - * @param $dataEnciphered |
|
51 | + * @param string $dataEnciphered |
|
49 | 52 | * @return string |
50 | 53 | * @throws Exception |
51 | 54 | */ |
@@ -69,6 +72,9 @@ discard block |
||
69 | 72 | return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, $ciphertext, MCRYPT_MODE_CBC, $this->iv)); |
70 | 73 | } |
71 | 74 | |
75 | + /** |
|
76 | + * @param string $salt |
|
77 | + */ |
|
72 | 78 | private function setSalt($salt) |
73 | 79 | { |
74 | 80 | $this->salt = $salt; |
@@ -79,6 +85,9 @@ discard block |
||
79 | 85 | $this->salt = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM); // abuse IV function for random salt |
80 | 86 | } |
81 | 87 | |
88 | + /** |
|
89 | + * @param string $iv |
|
90 | + */ |
|
82 | 91 | private function setIv($iv) |
83 | 92 | { |
84 | 93 | $this->iv = $iv; |
@@ -94,14 +103,18 @@ discard block |
||
94 | 103 | $this->key = hash_pbkdf2('sha256', $passphrase, $this->salt, $iterations, $length); |
95 | 104 | } |
96 | 105 | |
106 | + /** |
|
107 | + * @param string $ciphertext |
|
108 | + * @param string $key |
|
109 | + */ |
|
97 | 110 | private function hmacSign($ciphertext, $key) |
98 | 111 | { |
99 | 112 | return hash_hmac('sha256', $ciphertext, $key) . $ciphertext; |
100 | 113 | } |
101 | 114 | |
102 | 115 | /** |
103 | - * @param $bundle |
|
104 | - * @param $key |
|
116 | + * @param string $bundle |
|
117 | + * @param string $key |
|
105 | 118 | * @return bool |
106 | 119 | */ |
107 | 120 | private function hmacVerify($bundle, $key) |