Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions lib/Crypto/Crypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,19 @@ protected function isValidPrivateKey($plainKey) {
public function symmetricDecryptFileContent($keyFileContents, $passPhrase, $cipher = self::DEFAULT_CIPHER, $version = 0, $position = 0, $binaryEncode = false) {
$catFile = $this->splitMetaData($keyFileContents, $cipher);

if ($catFile['signature'] !== false) {
try {
$this->checkSignature($catFile['encrypted'], $passPhrase . $version . "-" . $position, $catFile['signature']);
} catch (HintException $e) {
// Check legacy format...
$this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']);

if (\getenv('ENCRYPTION_DISABLE_SIGNATURE', false) === false) {
if ($catFile['signature'] !== false) {
try {
$this->checkSignature($catFile['encrypted'], $passPhrase . $version . "-" . $position, $catFile['signature']);
} catch (HintException $e) {
// Check legacy format...
$this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']);
}
}
}


return $this->decrypt(
$catFile['encrypted'],
$catFile['iv'],
Expand Down Expand Up @@ -601,9 +605,11 @@ private function hasSignature($catFile, $cipher) {
$meta = \substr($catFile, -93);
$signaturePosition = \strpos($meta, '00sig00');

// enforce signature for the new 'CTR' ciphers
if ($signaturePosition === false && \strpos(\strtolower($cipher), 'ctr') !== false) {
throw new HintException('Missing Signature', $this->l->t('Missing Signature'));
if (\getenv('ENCRYPTION_DISABLE_SIGNATURE', false) === false) {
// enforce signature for the new 'CTR' ciphers
if ($signaturePosition === false && \strpos(\strtolower($cipher), 'ctr') !== false) {
throw new HintException('Missing Signature', $this->l->t('Missing Signature'));
}
}

return ($signaturePosition !== false);
Expand Down