Skip to content

Commit

Permalink
fixup! fix(migration): Decrypt ownCloud secrets v2
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Nov 28, 2024
1 parent d6861a8 commit d5b2ba0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/private/Security/Crypto.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ private function decryptWithoutSecret(string $authenticatedCiphertext, string $p
* beginning.
*/
$originalParts = $parts;
$isOwCloudV2Migration = $partCount === 4 && $originalParts[0] === 'v2';
if ($isOwCloudV2Migration) {
$isOwnCloudV2Migration = $partCount === 4 && $originalParts[0] === 'v2';
if ($isOwnCloudV2Migration) {
$parts = [
$parts[1],
$parts[2],
Expand All @@ -143,7 +143,7 @@ private function decryptWithoutSecret(string $authenticatedCiphertext, string $p
$iv = $this->hex2bin($iv);
}

if ($version === '3' || $isOwCloudV2Migration) {
if ($version === '3' || $isOwnCloudV2Migration) {
$keyMaterial = hash_hkdf('sha512', $password);
$encryptionKey = substr($keyMaterial, 0, 32);
$hmacKey = substr($keyMaterial, 32);
Expand All @@ -152,7 +152,7 @@ private function decryptWithoutSecret(string $authenticatedCiphertext, string $p
$this->cipher->setPassword($encryptionKey);
$this->cipher->setIV($iv);

if ($isOwCloudV2Migration) {
if ($isOwnCloudV2Migration) {
// ownCloud uses the binary IV for HMAC calculation
if (!hash_equals($this->calculateHMAC($parts[0] . $iv, $hmacKey), $hmac)) {
throw new Exception('HMAC does not match.');
Expand Down

0 comments on commit d5b2ba0

Please sign in to comment.