Annotation of embedaddon/php/ext/openssl/tests/openssl_decrypt_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: openssl_decrypt() error tests
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("openssl")) print "skip"; ?>
                      5: --FILE--
                      6: <?php
                      7: $data = "openssl_decrypt() tests";
                      8: $method = "AES-128-CBC";
                      9: $password = "openssl";
                     10: $wrong = "wrong";
                     11: $iv = str_repeat("\0", openssl_cipher_iv_length($method));
                     12: 
                     13: $encrypted = openssl_encrypt($data, $method, $password);
                     14: var_dump($encrypted); /* Not passing $iv should be the same as all-NULL iv, but with a warning */
                     15: var_dump(openssl_encrypt($data, $method, $password, false, $iv)); 
                     16: var_dump(openssl_decrypt($encrypted, $method, $wrong));
                     17: var_dump(openssl_decrypt($encrypted, $wrong, $password));
                     18: var_dump(openssl_decrypt($wrong, $method, $password));
                     19: var_dump(openssl_decrypt($wrong, $wrong, $password));
                     20: var_dump(openssl_decrypt($encrypted, $wrong, $wrong));
                     21: var_dump(openssl_decrypt($wrong, $wrong, $wrong));
                     22: var_dump(openssl_decrypt(array(), $method, $password));
                     23: var_dump(openssl_decrypt($encrypted, array(), $password));
                     24: var_dump(openssl_decrypt($encrypted, $method, array()));
                     25: ?>
                     26: --EXPECTF--
                     27: 
                     28: Warning: openssl_encrypt(): Using an empty Initialization Vector (iv) is potentially insecure and not recommended in %s on line %d
                     29: string(44) "yof6cPPH4mLee6TOc0YQSrh4dvywMqxGUyjp0lV6+aM="
                     30: string(44) "yof6cPPH4mLee6TOc0YQSrh4dvywMqxGUyjp0lV6+aM="
                     31: bool(false)
                     32: 
                     33: Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
                     34: bool(false)
                     35: bool(false)
                     36: 
                     37: Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
                     38: bool(false)
                     39: 
                     40: Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
                     41: bool(false)
                     42: 
                     43: Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
                     44: bool(false)
                     45: 
                     46: Warning: openssl_decrypt() expects parameter 1 to be string, array given in %s on line %d
                     47: NULL
                     48: 
                     49: Warning: openssl_decrypt() expects parameter 2 to be string, array given in %s on line %d
                     50: NULL
                     51: 
                     52: Warning: openssl_decrypt() expects parameter 3 to be string, array given in %s on line %d
                     53: NULL

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>