openssl_pkey_derive

PHP 7 >= 7.3.0, PHP 8
openssl_pkey_derive - Computes shared secret for public value of remote and local DH or ECDH key
Manual
Code Examples

openssl_pkey_derive(
     OpenSSLAsymmetricKey|OpenSSLCertificate|array|string$public_key,
     OpenSSLAsymmetricKey|OpenSSLCertificate|array|string$private_key,
     [int$key_length = 0]
): string|false

openssl_pkey_derive takes a set of a public_key and private_key and derives a shared secret, for either DH or EC keys.

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

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

Return Values

The derived secret on success or false on failure.

Example of openssl_pkey_derive

Show all examples for openssl_pkey_derive

PHP Version:


Function openssl_pkey_derive:

OpenSSL Functions

Most used PHP functions