openssl_pkey_derive

FunctionMisc changes in PHP 8.2

Computes shared secret for public value of remote and local DH or ECDH key.

PHP 5
PHP 7.0-7.2
PHP 7.3
Added
PHP 7.4
PHP 8.0
Improved
PHP 8.1
PHP 8.2
Changed
PHP 8.3
PHP 8.4
PHP 8.5
PHP 8.6

openssl_pkey_derive Function synopsis

openssl_pkey_derive(
    $public_key,
    $private_key,
    int $key_length = 0
  ): string|false

Parameters

$public_key

$public_key is the public key for the derivation. See Public/Private Key parameters for a list of valid values.

$private_key

$private_key is the private key for the derivation. See Public/Private Key parameters for a list of valid values.

$key_length

OptionalTypeintDefault value0

If not zero, will attempt to set the desired length of the derived secret.

Return value

Typestring|false

The derived secret on success or false on failure.

Changes to the openssl_pkey_derive Function

PHP 8.2

PHP 8.0

  • Return type added: string|false
  • Parameter name of parameter #1 changed: $peer_pub_key to $public_key
  • Parameter name of parameter #2 changed: $priv_key to $private_key
  • Parameter name of parameter #3 changed: $keylen to $key_length
  • Parameter type added for parameter #3 ($key_length): int
  • Parameter default value added for position #3 ($key_length): 0
  openssl_pkey_derive(
-     $peer_pub_key,
+     $public_key,
-     $priv_key,
+     $private_key,
-     $keylen
+     int $key_length = 0
-   )
+   ): string|false

PHP 7.3

  • Function added

openssl_pkey_derive Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported No
PHP 7.1Unsupported No
PHP 7.0Unsupported No
PHP 5.6Unsupported No
PHP 5.5Unsupported No
PHP 5.4Unsupported No
PHP 5.3Unsupported No