bug73833.phpt 685 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. Bug #73833: null character not allowed in openssl_pkey_get_private
  3. --EXTENSIONS--
  4. openssl
  5. --FILE--
  6. <?php
  7. $passwords = ["abc\x00defghijkl", "abcdefghikjl"];
  8. $conf = ['config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'];
  9. foreach($passwords as $password) {
  10. $key = openssl_pkey_new($conf);
  11. if (openssl_pkey_export($key, $privatePEM, $password, $conf) === false) {
  12. echo "Failed to encrypt.\n";
  13. } else {
  14. echo "Encrypted!\n";
  15. }
  16. if (openssl_pkey_get_private($privatePEM, $password) === false) {
  17. echo "Failed to decrypt.\n";
  18. } else {
  19. echo "Decrypted!\n";
  20. }
  21. }
  22. ?>
  23. --EXPECT--
  24. Encrypted!
  25. Decrypted!
  26. Encrypted!
  27. Decrypted!