bug71917.phpt 804 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Bug #71917: openssl_open() returns junk on envelope < 16 bytes
  3. --EXTENSIONS--
  4. openssl
  5. --SKIPIF--
  6. <?php
  7. if (!in_array('rc4', openssl_get_cipher_methods())) die('skip rc4 not available');
  8. ?>
  9. --FILE--
  10. <?php
  11. function test($envkey) {
  12. $publicKey = "file://" . __DIR__ . "/public.key";
  13. $privateKey = "file://" . __DIR__ . "/private_rsa_1024.key";
  14. openssl_public_encrypt($envkey, $envelope, $publicKey);
  15. $sealed = openssl_encrypt(
  16. 'plaintext',
  17. 'rc4', $envkey,
  18. OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY
  19. );
  20. openssl_open($sealed, $output, $envelope, $privateKey, 'rc4');
  21. var_dump($output === 'plaintext');
  22. }
  23. // works - key of 16 bytes
  24. test('1234567890123456i');
  25. // fails - key of 15 bytes
  26. test('123456789012345');
  27. ?>
  28. --EXPECT--
  29. bool(true)
  30. bool(true)