|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2017-04-25 13:01 UTC] bukka@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: bukka
[2017-04-25 13:01 UTC] bukka@php.net
[2017-07-02 17:38 UTC] bukka@php.net
[2017-07-02 17:38 UTC] bukka@php.net
-Status: Assigned
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 21:00:01 2025 UTC |
Description: ------------ OpenSSL provides two functions: openssl_seal and openssl_open which are basically just handy shortcuts to manually: - generating envelope key (CS-random string) - encrypting it with public key - encrypting data itself with that envelope key - storing both encrypted data and encrypted envelope One can successfully do this manually via openssl command line tool: i.e. encrypt envelope/data with openssl cli and unseal with PHP or vice versa. But PHP's openssl_open() seems to have a bug: it will return some junk instead of decrypted plaintext if envelope's key is shorter than 16 bytes long. It will work fine if it's 16 bytes long or longer. Since openssl_seal() generates 128-bit key it's not a high-priority problem but at least openssl_open() should emit a warning if for whatever the reason it's not possible to fix the behaviour. This was confirmed on RC4 cipher (default method). Test script: --------------- function test($envkey) { // $publicKey, $privateKey are OpenSSL Key resources. openssl_public_encrypt($envkey, $envelope, openssl_pkey_get_public($publicKey)); $sealed = openssl_encrypt('plaintext', 'rc4', $envkey, OPENSSL_RAW_DATA); openssl_open($sealed, $output, $envelope, $privateKey, 'rc4'); assert($output === 'plaintext'); } // works - key of 16 bytes test('1234567890123456'); // fails - key of 15 bytes test('123456789012345'); Expected result: ---------------- openssl_open() should return original plaintext as long as supplied keys are correct, regardless of the envelope key's length. Actual result: -------------- openssl_open() returns some junk with no warning or other indication if data was encrypted with envelope key shorter than 16 bytes, at least if using RC4 cipher, even when given correct keys.