11<?php
2+ declare (strict_types=1 );
23namespace ParagonIE \PasswordLock ;
34
45use \Defuse \Crypto \Crypto ;
@@ -17,7 +18,7 @@ class PasswordLock
1718 * @return string
1819 * @throws \Exception
1920 */
20- public static function hashAndEncrypt ($ password , Key $ aesKey )
21+ public static function hashAndEncrypt (string $ password , Key $ aesKey ): string
2122 {
2223 if (!\is_string ($ password )) {
2324 throw new \InvalidArgumentException (
@@ -46,7 +47,7 @@ public static function hashAndEncrypt($password, Key $aesKey)
4647 * @throws \Exception
4748 * @throws \InvalidArgumentException
4849 */
49- public static function decryptAndVerifyLegacy ($ password , $ ciphertext , $ aesKey )
50+ public static function decryptAndVerifyLegacy (string $ password , string $ ciphertext , string $ aesKey ): bool
5051 {
5152 if (!\is_string ($ password )) {
5253 throw new \InvalidArgumentException (
@@ -79,7 +80,7 @@ public static function decryptAndVerifyLegacy($password, $ciphertext, $aesKey)
7980 * @throws \Exception
8081 * @throws \InvalidArgumentException
8182 */
82- public static function decryptAndVerify ($ password , $ ciphertext , Key $ aesKey )
83+ public static function decryptAndVerify (string $ password , string $ ciphertext , Key $ aesKey ): bool
8384 {
8485 if (!\is_string ($ password )) {
8586 throw new \InvalidArgumentException (
@@ -111,7 +112,7 @@ public static function decryptAndVerify($password, $ciphertext, Key $aesKey)
111112 * @param Key $newKey
112113 * @return string
113114 */
114- public static function rotateKey ($ ciphertext , Key $ oldKey , Key $ newKey )
115+ public static function rotateKey (string $ ciphertext , Key $ oldKey , Key $ newKey ): string
115116 {
116117 $ plaintext = Crypto::decrypt ($ ciphertext , $ oldKey );
117118 return Crypto::encrypt ($ plaintext , $ newKey );
@@ -128,11 +129,11 @@ public static function rotateKey($ciphertext, Key $oldKey, Key $newKey)
128129 * @throws \Exception
129130 */
130131 public static function upgradeFromVersion1 (
131- $ password ,
132- $ ciphertext ,
133- $ oldKey ,
132+ string $ password ,
133+ string $ ciphertext ,
134+ string $ oldKey ,
134135 Key $ newKey
135- ) {
136+ ): string {
136137 if (!self ::decryptAndVerifyLegacy ($ password , $ ciphertext , $ oldKey )) {
137138 throw new \Exception (
138139 'The correct password is necessary for legacy migration. '
0 commit comments