Dear all, I am using owncloud 7.0.2-1 on Debian 7.7 with the encryption app enabled.
Having an external backup of the encrypted files I need some possibility to decrypt these files 'by hand', in case of a corrupted owncloud installation or data loss. Therefore, I decided to test the recovery of data from my backup. However, I did not succeed so far. My php script is given below, it is mainly based on [1]. test/test.txt contains a simple 'ok'. The script executes without errors, but the result is something like 'ÍZþhª0`¹!Ô_2LÄo7RØ' and not 'ok'. Obviously there is something wrong. Any ideas how to debug this? Step 1 (user key decryption) is not the problem, therefore the error is probably in the file-key step or in the final decryption of the file content. Thanks a lot. best regards, Smu [1] http://blog.schiessle.org/2013/05/28/introduction-to-the-new-owncloud-encryption-app/comment-page-1/#comment-61180 --- php ---- <?php $path = '__owncloud-root__/apps/files_encryption/lib/'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'crypt.php'; use OCA\Encryption; $OWNCLOUD_ROOT="__owncloud-root__" ; // or backup location # a test file $filename = "test/test.txt"; $user='__username__'; $pw = "__pw__"; // first get users private key and decrypt it $encryptedUserKey = file_get_contents($OWNCLOUD_ROOT."/data/".$user."/files_encryption/".$user.".private.key"); $decryptedUserKey = OCA\Encryption\Crypt::decryptPrivateKey($encryptedUserKey, $pw); if(!$decryptedUserKey) { echo "failed to decrypt private key of user ". $user. "\n"; exit; } // now we need to decrypt the file-key, therefore we use our private key and the share key $shareKey = file_get_contents($OWNCLOUD_ROOT."/data/".$user."/files_encryption/share-keys/".$filename.".".$user.".shareKey"); $encryptedKeyfile = file_get_contents($OWNCLOUD_ROOT."/data/".$user."/files_encryption/keyfiles/".$filename.".key"); $decryptedKeyfile = OCA\Encryption\Crypt::multiKeyDecrypt($encryptedKeyfile, $shareKey, $decryptedUserKey); // finally we can use the decrypted file-key to decrypt the file $encryptedContent = file_get_contents($OWNCLOUD_ROOT."/data/".$user."/files/".$filename); $decryptedContent = OCA\Encryption\Crypt::symmetricDecryptFileContent($encryptedContent, $decryptedKeyfile); echo $decryptedContent ; ?> ------------ _______________________________________________ User mailing list [email protected] http://mailman.owncloud.org/mailman/listinfo/user
