You are here

public static function ParagonIE_Sodium_Compat::crypto_sign_verify_detached in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::crypto_sign_verify_detached()

Verify the Ed25519 signature of a message.

@psalm-suppress MixedArgument

Parameters

string $signature Digital sginature:

string $message Message to be verified:

string $publicKey Public key:

Return value

bool TRUE if this signature is good for this public key; FALSE otherwise

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Compat::crypto_sign_verify_detached()
php72compat.php in vendor/paragonie/sodium_compat/lib/php72compat.php
sodium_compat.php in vendor/paragonie/sodium_compat/lib/sodium_compat.php

File

vendor/paragonie/sodium_compat/src/Compat.php, line 2852

Class

ParagonIE_Sodium_Compat

Code

public static function crypto_sign_verify_detached($signature, $message, $publicKey) {

  /* Type checks: */
  ParagonIE_Sodium_Core_Util::declareScalarType($signature, 'string', 1);
  ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2);
  ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 3);

  /* Input validation: */
  if (ParagonIE_Sodium_Core_Util::strlen($signature) !== self::CRYPTO_SIGN_BYTES) {
    throw new SodiumException('Argument 1 must be CRYPTO_SIGN_BYTES long.');
  }
  if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_SIGN_PUBLICKEYBYTES) {
    throw new SodiumException('Argument 3 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
  }
  if (self::useNewSodiumAPI()) {
    return sodium_crypto_sign_verify_detached($signature, $message, $publicKey);
  }
  if (self::use_fallback('crypto_sign_verify_detached')) {
    return (bool) call_user_func('\\Sodium\\crypto_sign_verify_detached', $signature, $message, $publicKey);
  }
  if (PHP_INT_SIZE === 4) {
    return ParagonIE_Sodium_Crypto32::sign_verify_detached($signature, $message, $publicKey);
  }
  return ParagonIE_Sodium_Crypto::sign_verify_detached($signature, $message, $publicKey);
}