1 | <?php |
||
15 | final class EncryptionUtils |
||
16 | { |
||
17 | // @codingStandardsIgnoreStart |
||
18 | const ENCRYPTION_PADDING = "\x28\xbf\x4e\x5e\x4e\x75\x8a\x41\x64\x00\x4e\x56\xff\xfa\x01\x08\x2e\x2e\x00\xb6\xd0\x68\x3e\x80\x2f\x0c\xa9\xfe\x64\x53\x69\x7a"; |
||
19 | // @codingStandardsIgnoreEnd |
||
20 | |||
21 | private function __construct() |
||
24 | |||
25 | /** |
||
26 | * Computes the encryption key as defined by algorithm 3.2 in 3.5.2. |
||
27 | * |
||
28 | * @param string $password |
||
29 | * @param int $revision |
||
30 | * @param int $keyLength |
||
31 | * @param string $ownerEntry |
||
32 | * @param int $permissions |
||
33 | * @param string $idEntry |
||
34 | * @param bool $encryptMetadata |
||
35 | * @return string |
||
36 | */ |
||
37 | public static function computeEncryptionKey( |
||
67 | |||
68 | /** |
||
69 | * Computes the owner entry as defined by algorithm 3.3 in 3.5.2. |
||
70 | * |
||
71 | * @param string $ownerPassword |
||
72 | * @param string $userPassword |
||
73 | * @param int $revision |
||
74 | * @param int $keyLength |
||
75 | * @return string |
||
76 | */ |
||
77 | public static function computeOwnerEntry($ownerPassword, $userPassword, $revision, $keyLength) |
||
99 | |||
100 | /** |
||
101 | * Computes the user entry (rev 2) as defined by algorithm 3.4 in 3.5.2. |
||
102 | * |
||
103 | * @param string $userPassword |
||
104 | * @param string $ownerEntry |
||
105 | * @param int $userPermissionFlags |
||
106 | * @param string $idEntry |
||
107 | * @return string[] |
||
108 | */ |
||
109 | public static function computeUserEntryRev2($userPassword, $ownerEntry, $userPermissionFlags, $idEntry) |
||
115 | |||
116 | /** |
||
117 | * Computes the user entry (rev 3 or greater) as defined by algorithm 3.5 in 3.5.2. |
||
118 | * |
||
119 | * @param string $userPassword |
||
120 | * @param int $revision |
||
121 | * @param int $keyLength |
||
122 | * @param string $ownerEntry |
||
123 | * @param int $permissions |
||
124 | * @param string $idEntry |
||
125 | * @return string[] |
||
126 | */ |
||
127 | public static function computeUserEntryRev3OrGreater( |
||
141 | |||
142 | /** |
||
143 | * Native RC4 encryption. |
||
144 | * |
||
145 | * @param string $key |
||
146 | * @param string $plaintext |
||
147 | * @return string |
||
148 | */ |
||
149 | public static function rc4($key, $plaintext) |
||
180 | |||
181 | /** |
||
182 | * Applies loop RC4 encryption. |
||
183 | * |
||
184 | * @param string $value |
||
185 | * @param string $key |
||
186 | * @param int $keyLength |
||
187 | * @return string |
||
188 | */ |
||
189 | private static function applyRc4Loop($value, $key, $keyLength) |
||
203 | } |
||
204 |