ok; still some bugs that had to be fixed
This commit is contained in:
parent
3be57d0169
commit
1b7e9d66b3
|
@ -392,7 +392,9 @@ class Util {
|
|||
$size = $this->view->filesize($path);
|
||||
|
||||
// open stream
|
||||
$stream = fopen($path, "r");
|
||||
$stream = $this->view->fopen($path, "r");
|
||||
|
||||
if (is_resource($stream)) {
|
||||
|
||||
// if the file contains a encryption header we
|
||||
// we set the cipher
|
||||
|
@ -415,36 +417,30 @@ class Util {
|
|||
// we have to read the last chunk, we can't just calculate it (because of padding etc)
|
||||
$lastChunkNr = ceil($size/Crypt::BLOCKSIZE)-1;
|
||||
|
||||
if (is_resource($stream)) {
|
||||
// calculate last chunk position
|
||||
$lastChunkPos = ($lastChunkNr * Crypt::BLOCKSIZE);
|
||||
|
||||
// get the content of the last chunk
|
||||
$lastChunkContentEncrypted='';
|
||||
$count=Crypt::BLOCKSIZE;
|
||||
if (@fseek($stream, $lastChunkPos, SEEK_CUR) === 0) {
|
||||
$realSize+=$lastChunkNr*6126;
|
||||
}
|
||||
$lastChunkContentEncrypted='';
|
||||
$count=Crypt::BLOCKSIZE;
|
||||
while ($count>0) {
|
||||
$data=fread($stream,Crypt::BLOCKSIZE);
|
||||
$count=strlen($data);
|
||||
$lastChunkContentEncrypted.=$data;
|
||||
}
|
||||
} else {
|
||||
while ($count>0) {
|
||||
if(strlen($lastChunkContentEncrypted)>Crypt::BLOCKSIZE) {
|
||||
$realSize+=6126;
|
||||
$lastChunkContentEncrypted=substr($lastChunkContentEncrypted,Crypt::BLOCKSIZE);
|
||||
}
|
||||
$data=fread($stream,Crypt::BLOCKSIZE);
|
||||
$count=strlen($data);
|
||||
$lastChunkContentEncrypted.=$data;
|
||||
}
|
||||
}
|
||||
|
||||
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
||||
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
|
||||
$privateKey = $session->getPrivateKey();
|
||||
$plainKeyfile = $this->decryptKeyfile($path, $privateKey);
|
||||
$shareKey = Keymanager::getShareKey($this->view, $this->keyId, $this, $path);
|
||||
$plainKeyfile = $this->decryptKeyfile($relPath, $privateKey);
|
||||
$shareKey = Keymanager::getShareKey($this->view, $this->keyId, $this, $relPath);
|
||||
|
||||
$plainKey = Crypt::multiKeyDecrypt($plainKeyfile, $shareKey, $privateKey);
|
||||
|
||||
|
|
Loading…
Reference in New Issue