doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Clarification of "public key" and "private key" in OpenSSL_decrypt/encrypt functions

Open galaxiesFarApart opened this issue 1 year ago • 1 comments

Version: 8.2 Both of the OpenSSL_decrypt/encrypt documentation use a "loose" definition/explanation of a supposed private/public key used for decryption/encryption.

Example (public_decrypt):

Parameters "public_key must be the public key corresponding that was used to encrypt the data."

First of all, this is not the "best" English grammar. Secondly, this does not explicitly clarify that the "corresponding key" is supposed to be the previously used private key used to encrypt the data.

Note: the initial statement after the function description implies the "proper key" (but still not explicit) that was used to encrypt the data:

"openssl_public_decrypt() decrypts data that was previous encrypted via openssl_private_encrypt() and stores the result into decrypted_data."

Proposed openssl_public_decrypt modification:

public_key "public_key must be the public key that corresponds to the private key that was used to encrypt the data."

Proposed openssl_private_decrypt modification: private_key

"private_key must be the private key that corresponds to the public key that was used to encrypt the data."

This clarifies the assymetric key-pair in both cases. Without this clarification, there is an apparent discrepancy between the two "descriptions of keys" used for the particular function. This should also be applied "public_encrypt .." function.

Similar modifications should also be applied to the "openssl_private..." functions.

Don't "assume" that things are (trivially) obvious.

galaxiesFarApart avatar Sep 10 '24 07:09 galaxiesFarApart

Thanks for reporting here!

Please have a look at https://github.com/php/doc-en/pull/3741, and suggest further improvements there.

cmb69 avatar Sep 12 '24 14:09 cmb69