|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-10-14 01:41 UTC] divinity76 at gmail dot com
[2020-10-14 10:33 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2020-10-14 10:33 UTC] nikic@php.net
[2020-10-14 16:55 UTC] divinity76 at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ it seems some openssl_decrypt() decryption error with aes-128-ocb fail to register on openssl_error_string() Test script: --------------- <?php declare(strict_types=1); ini_set('display_errors','On'); error_reporting(E_ALL); header("Content-Type: text/plain;charset=utf-8"); ini_set('html_errors','0'); $algo = 'aes-128-ocb'; $data_to_encrypt = $key = $iv = str_repeat("\x00", openssl_cipher_iv_length($algo)); $opts = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING; $encrypted = openssl_encrypt($data_to_encrypt, $algo, $key, $opts , $iv); if(false===$encrypted || openssl_error_string() !== false){ die("encryption error ".openssl_error_string()); } $decrypted = openssl_decrypt($encrypted, $algo, $key, $opts, $iv); if(($encrypted !== $data_to_encrypt) && ($data_to_encrypt === $decrypted)){ echo "ok"; }else{ echo "error: "; var_dump([ "original"=>$data_to_encrypt, "encrypted"=>$encrypted, "decrypted"=>$decrypted, "openssl_error_string" => openssl_error_string() ]); } Expected result: ---------------- i either expected "ok", or expected openssl_error_string() to contain something other than bool(false) Actual result: -------------- error: array(4) { ["original"]=> string(12) "������������" ["encrypted"]=> string(12) "{��f�g]�WG�" ["decrypted"]=> bool(false) ["openssl_error_string"]=> bool(false) }