bug70438.phpt 969 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Request #70438: Add IV parameter for openssl_seal and openssl_open
  3. --EXTENSIONS--
  4. openssl
  5. --SKIPIF--
  6. <?php
  7. if (!in_array('AES-128-CBC', openssl_get_cipher_methods(true))) {
  8. print "skip";
  9. }
  10. ?>
  11. --FILE--
  12. <?php
  13. $data = "openssl_seal() test";
  14. $cipher = 'AES-128-CBC';
  15. $pub_key = "file://" . __DIR__ . "/public.key";
  16. $priv_key = "file://" . __DIR__ . "/private_rsa_1024.key";
  17. try {
  18. openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $cipher);
  19. } catch (\ValueError $e) {
  20. echo $e->getMessage() . \PHP_EOL;
  21. }
  22. openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), 'sparkles', $iv);
  23. openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $cipher, $iv);
  24. openssl_open($sealed, $decrypted, $ekeys[0], $priv_key, $cipher, $iv);
  25. echo $decrypted;
  26. ?>
  27. --EXPECTF--
  28. openssl_seal(): Argument #6 ($iv) cannot be null for the chosen cipher algorithm
  29. Warning: openssl_seal(): Unknown cipher algorithm in %s on line %d
  30. openssl_seal() test