| @@ 330-339 (lines=10) @@ | ||
| 327 | * @throws InvalidTokenException |
|
| 328 | * @return string the decrypted key |
|
| 329 | */ |
|
| 330 | private function decryptPassword(string $password, string $token): string { |
|
| 331 | $secret = $this->config->getSystemValue('secret'); |
|
| 332 | try { |
|
| 333 | return $this->crypto->decrypt($password, $token . $secret); |
|
| 334 | } catch (Exception $ex) { |
|
| 335 | // Delete the invalid token |
|
| 336 | $this->invalidateToken($token); |
|
| 337 | throw new InvalidTokenException(); |
|
| 338 | } |
|
| 339 | } |
|
| 340 | ||
| 341 | public function markPasswordInvalid(IToken $token, string $tokenId) { |
|
| 342 | if (!($token instanceof DefaultToken)) { |
|
| @@ 228-237 (lines=10) @@ | ||
| 225 | /** |
|
| 226 | * @throws InvalidTokenException |
|
| 227 | */ |
|
| 228 | private function decrypt(string $cipherText, string $token): string { |
|
| 229 | $secret = $this->config->getSystemValue('secret'); |
|
| 230 | try { |
|
| 231 | return $this->crypto->decrypt($cipherText, $token . $secret); |
|
| 232 | } catch (\Exception $ex) { |
|
| 233 | // Delete the invalid token |
|
| 234 | $this->invalidateToken($token); |
|
| 235 | throw new InvalidTokenException(); |
|
| 236 | } |
|
| 237 | } |
|
| 238 | ||
| 239 | private function encryptPassword(string $password, string $publicKey): string { |
|
| 240 | openssl_public_encrypt($password, $encryptedPassword, $publicKey, OPENSSL_PKCS1_OAEP_PADDING); |
|