openssl_verify

FunctionParams changed in PHP 8.5

Verify signature.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1-8.2
PHP 8.3
PHP 8.4
PHP 8.5
Improved
PHP 8.6

openssl_verify Function synopsis

openssl_verify(
    string $data,
    string $signature,
    $public_key,
    string|int $algorithm = OPENSSL_ALGO_SHA1,
    int $padding = 0
  ): int|false

Parameters

$data

Typestring

The string of data used to generate the signature previously

$signature

Typestring

A raw binary string, generated by openssl_sign or similar means

$public_key

OpenSSLAsymmetricKey - a key, returned by openssl_get_publickey

$algorithm

OptionalTypestring|intDefault valueOPENSSL_ALGO_SHA1

int - one of these Signature Algorithms.

$padding

OptionalTypeintDefault value0

Return value

Typeint|false

Returns 1 if the signature is correct, 0 if it is incorrect, and -1 or false on error.

Changes to the openssl_verify Function

PHP 8.5

  • Optional parameter added - #5: int $padding = 0
 openssl_verify(
     string $data,
     string $signature,
     $public_key,
-    string|int $algorithm = OPENSSL_ALGO_SHA1
+    string|int $algorithm = OPENSSL_ALGO_SHA1,
+    int $padding = 0
   ): int|false

PHP 8.0

  • Return type added: int|false
  • Parameter type added for parameter #1 ($data): string
  • Parameter type added for parameter #2 ($signature): string
  • Parameter name of parameter #3 changed: $key to $public_key
  • Parameter name of parameter #4 changed: $method to $algorithm
  • Parameter type added for parameter #4 ($algorithm): string|int
  • Parameter default value added for position #4 ($algorithm): OPENSSL_ALGO_SHA1
  openssl_verify(
-     $data,
+     string $data,
-     $signature,
+     string $signature,
-     $key,
+     $public_key,
-     $method
+     string|int $algorithm = OPENSSL_ALGO_SHA1
-   )
+   ): int|false

openssl_verify Function Availability

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