|
|
|
@ -34,7 +34,6 @@ use OCA\Encryption\Vendor\PBKDF2Fallback; |
|
|
|
use OCP\Encryption\Exceptions\GenericEncryptionException; |
|
|
|
use OCP\IConfig; |
|
|
|
use OCP\ILogger; |
|
|
|
use OCP\IUser; |
|
|
|
use OCP\IUserSession; |
|
|
|
|
|
|
|
class Crypt { |
|
|
|
@ -146,7 +145,7 @@ class Crypt { |
|
|
|
/** |
|
|
|
* @param string $plainContent |
|
|
|
* @param string $passPhrase |
|
|
|
* @return bool|string |
|
|
|
* @return false|string |
|
|
|
* @throws GenericEncryptionException |
|
|
|
*/ |
|
|
|
public function symmetricEncryptFileContent($plainContent, $passPhrase) { |
|
|
|
@ -273,7 +272,7 @@ class Crypt { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param $data |
|
|
|
* @param string $data |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
private function addPadding($data) { |
|
|
|
@ -326,7 +325,7 @@ class Crypt { |
|
|
|
* @param string $privateKey |
|
|
|
* @param string $password |
|
|
|
* @param string $uid for regular users, empty for system keys |
|
|
|
* @return bool|string |
|
|
|
* @return false|string |
|
|
|
*/ |
|
|
|
public function encryptPrivateKey($privateKey, $password, $uid = '') { |
|
|
|
$cipher = $this->getCipher(); |
|
|
|
@ -343,7 +342,7 @@ class Crypt { |
|
|
|
* @param string $privateKey |
|
|
|
* @param string $password |
|
|
|
* @param string $uid for regular users, empty for system keys |
|
|
|
* @return bool|string |
|
|
|
* @return false|string |
|
|
|
*/ |
|
|
|
public function decryptPrivateKey($privateKey, $password = '', $uid = '') { |
|
|
|
|
|
|
|
@ -386,7 +385,7 @@ class Crypt { |
|
|
|
/** |
|
|
|
* check if it is a valid private key |
|
|
|
* |
|
|
|
* @param $plainKey |
|
|
|
* @param string $plainKey |
|
|
|
* @return bool |
|
|
|
*/ |
|
|
|
protected function isValidPrivateKey($plainKey) { |
|
|
|
@ -402,7 +401,7 @@ class Crypt { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param $keyFileContents |
|
|
|
* @param string $keyFileContents |
|
|
|
* @param string $passPhrase |
|
|
|
* @param string $cipher |
|
|
|
* @return string |
|
|
|
@ -424,7 +423,7 @@ class Crypt { |
|
|
|
* remove padding |
|
|
|
* |
|
|
|
* @param $padded |
|
|
|
* @return bool|string |
|
|
|
* @return string|false |
|
|
|
*/ |
|
|
|
private function removePadding($padded) { |
|
|
|
if (substr($padded, -2) === 'xx') { |
|
|
|
@ -436,8 +435,8 @@ class Crypt { |
|
|
|
/** |
|
|
|
* split iv from encrypted content |
|
|
|
* |
|
|
|
* @param $catFile |
|
|
|
* @return array |
|
|
|
* @param string|false $catFile |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
private function splitIv($catFile) { |
|
|
|
// Fetch encryption metadata from end of file
|
|
|
|
@ -457,8 +456,8 @@ class Crypt { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param $encryptedContent |
|
|
|
* @param $iv |
|
|
|
* @param string $encryptedContent |
|
|
|
* @param string $iv |
|
|
|
* @param string $passPhrase |
|
|
|
* @param string $cipher |
|
|
|
* @return string |
|
|
|
@ -479,7 +478,7 @@ class Crypt { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param $data |
|
|
|
* @param string $data |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
protected function parseHeader($data) { |
|
|
|
@ -551,7 +550,7 @@ class Crypt { |
|
|
|
* @param $encKeyFile |
|
|
|
* @param $shareKey |
|
|
|
* @param $privateKey |
|
|
|
* @return mixed |
|
|
|
* @return string |
|
|
|
* @throws MultiKeyDecryptException |
|
|
|
*/ |
|
|
|
public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) { |
|
|
|
|