mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-01 09:24:36 +08:00
Bugfix: store private key failed
This commit is contained in:
parent
d4bac30719
commit
f8da8b5135
2 changed files with 11 additions and 5 deletions
|
@ -37,7 +37,9 @@ class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
|
||||||
} else if (StorageType::SESSION === $iStorageType) {
|
} else if (StorageType::SESSION === $iStorageType) {
|
||||||
$sDataPath .= '/.sessions';
|
$sDataPath .= '/.sessions';
|
||||||
} else if (StorageType::PGP === $iStorageType) {
|
} else if (StorageType::PGP === $iStorageType) {
|
||||||
$sDataPath = '/.pgp';
|
$sDataPath .= '/.pgp';
|
||||||
|
$sDataPath = "{$this->sDataPath}/demo.pgp/.pgp";
|
||||||
|
$bMkDir = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bMkDir && !\is_dir($sDataPath) && !\mkdir($sDataPath, 0700, true))
|
if ($bMkDir && !\is_dir($sDataPath) && !\mkdir($sDataPath, 0700, true))
|
||||||
|
|
|
@ -184,11 +184,13 @@ trait Pgp
|
||||||
if ('.asc' === \substr($file, -4)) {
|
if ('.asc' === \substr($file, -4)) {
|
||||||
$keys[] = \file_get_contents($file);
|
$keys[] = \file_get_contents($file);
|
||||||
} else if ('.key' === \substr($file, -4)) {
|
} else if ('.key' === \substr($file, -4)) {
|
||||||
$data = \json_decode(\file_get_contents($file), true);
|
$key = \json_decode(\file_get_contents($file), true);
|
||||||
$mac = \array_pop($sKey);
|
$mac = \array_pop($key);
|
||||||
$hash = $oAccount->CryptKey();
|
$hash = $oAccount->CryptKey();
|
||||||
if ($mac === \hash_hmac('sha1', $data[2], $hash)) {
|
if ($mac === \hash_hmac('sha1', $key[2], $hash)) {
|
||||||
$keys[] = \SnappyMail\Crypt::Decrypt($data, $hash);
|
$key[1] = \base64_decode($key[1]);
|
||||||
|
$key[2] = \base64_decode($key[2]);
|
||||||
|
$keys[] = \SnappyMail\Crypt::Decrypt($key, $hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,6 +255,8 @@ trait Pgp
|
||||||
if (\str_contains($key, 'PGP PRIVATE KEY')) {
|
if (\str_contains($key, 'PGP PRIVATE KEY')) {
|
||||||
$hash = $oAccount->CryptKey();
|
$hash = $oAccount->CryptKey();
|
||||||
$key = \SnappyMail\Crypt::Encrypt($key, $hash);
|
$key = \SnappyMail\Crypt::Encrypt($key, $hash);
|
||||||
|
$key[1] = \base64_encode($key[1]);
|
||||||
|
$key[2] = \base64_encode($key[2]);
|
||||||
$key[] = \hash_hmac('sha1', $key[2], $hash);
|
$key[] = \hash_hmac('sha1', $key[2], $hash);
|
||||||
return !!\file_put_contents("{$dir}/{$keyId}.key", \json_encode($key));
|
return !!\file_put_contents("{$dir}/{$keyId}.key", \json_encode($key));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue