From 7ae4d539f2333e7b199ef658f8c93fab1c3a84e0 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sat, 14 Sep 2013 11:28:35 -0500 Subject: [PATCH] Better errors for unsupported ciphers. --- lib/openpgp_crypt_aes_tripledes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/openpgp_crypt_aes_tripledes.php b/lib/openpgp_crypt_aes_tripledes.php index 9609ce1..4f208bf 100644 --- a/lib/openpgp_crypt_aes_tripledes.php +++ b/lib/openpgp_crypt_aes_tripledes.php @@ -9,6 +9,7 @@ require_once 'Crypt/Random.php'; class OpenPGP_Crypt_AES_TripleDES { public static function encrypt($passphrases_and_keys, $message, $symmetric_algorithm=9) { list($cipher, $key_bytes, $key_block_bytes) = self::getCipher($symmetric_algorithm); + if(!$cipher) throw new Exception("Only AES/3DES are supported."); $prefix = crypt_random_string($key_block_bytes); $prefix .= substr($prefix, -2); @@ -73,6 +74,7 @@ class OpenPGP_Crypt_AES_TripleDES { $packet = clone $packet; // Do not mutate orinigal list($cipher, $key_bytes, $key_block_bytes) = self::getCipher($packet->symmetric_algorithm); + if(!$cipher) throw new Exception("Only AES/3DES are supported."); $cipher->setKey($packet->s2k->make_key($pass, $key_bytes)); $cipher->setIV(substr($packet->encrypted_data, 0, $key_block_bytes)); $material = $cipher->decrypt(substr($packet->encrypted_data, $key_block_bytes));