Support the no-MDC (resync) case

This commit is contained in:
Stephen Paul Weber 2013-01-26 11:17:11 -05:00
parent 47a7f6e25c
commit 8c60f4e37b
2 changed files with 16 additions and 6 deletions

View File

@ -50,7 +50,17 @@ class OpenPGP_Crypt_AES_TripleDES {
} catch (Exception $ex) { $msg = NULL; } } catch (Exception $ex) { $msg = NULL; }
if($msg) return $msg; /* Otherwise keep trying */ if($msg) return $msg; /* Otherwise keep trying */
} else { } else {
// TODO (resync) // No MDC mean decrypt with resync
$iv = substr($epacket->data, 2, $key_block_bytes);
$edata = substr($epacket->data, $key_block_bytes + 2);
$cipher->setIV($iv);
$data = substr($cipher->decrypt($edata . str_repeat("\0", $padAmount)), 0, strlen($edata));
try {
$msg = OpenPGP_Message::parse($data);
} catch (Exception $ex) { $msg = NULL; }
if($msg) return $msg; /* Otherwise keep trying */
} }
} else { } else {
// TODO // TODO

View File

@ -88,9 +88,9 @@ class Decryption extends PHPUnit_Framework_TestCase {
public function testDecryptSessionKey() { public function testDecryptSessionKey() {
$this->oneSymmetric("hello", "PGP\n", "symmetric-with-session-key.gpg"); $this->oneSymmetric("hello", "PGP\n", "symmetric-with-session-key.gpg");
} }
*/
public function testDecryptNoMDC() { public function testDecryptNoMDC() {
$this->oneSymmetric("hello", "PGP\n", "symmetric-no-mdc.gpg"); $this->oneSymmetric("hello", "PGP\n", "symmetric-no-mdc.gpg");
} }
*/
} }