]> granicus.if.org Git - php/commit
Allow passing $tag for non-authenticated encryption
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 13 Oct 2020 14:46:32 +0000 (16:46 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 14 Oct 2020 08:54:06 +0000 (10:54 +0200)
commit6c6a58e930c5863ab1bd11f6a19cbf22aa2f20d4
treeb46dcd1ceec97bd434d56c9956fcb3439a981d9e
parentd9058b61fb3e1ef0697433324716a8843e92c115
Allow passing $tag for non-authenticated encryption

openssl_encrypt() currently throws a warning if the $tag out
parameter is passed for a non-authenticated cipher. This violates
the principle that a function should behave the same if a parameter
is not passed, and if the default value is passed for the parameter.

I believe this warning should simply be dropped and the $tag be
populated with null, as is already the case. Otherwise, it is not
possible to use openssl_encrypt() in generic wrapper APIs, that are
compatible with both authenticated and non-authenticated encryption.

Closes GH-6333.
ext/openssl/openssl.c
ext/openssl/tests/openssl_decrypt_basic.phpt
ext/openssl/tests/openssl_decrypt_error.phpt
ext/openssl/tests/openssl_encrypt_error.phpt