public static function ParagonIE_Sodium_Compat::crypto_sign_open in Automatic Updates 7
Same name and namespace in other branches
- 8 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::crypto_sign_open()
Validates a signed message then returns the message.
@psalm-suppress MixedArgument @psalm-suppress MixedInferredReturnType @psalm-suppress MixedReturnStatement
Parameters
string $signedMessage A signed message:
string $publicKey A public key:
Return value
string The original message (if the signature is valid for this public key)
Throws
SodiumException
TypeError
2 calls to ParagonIE_Sodium_Compat::crypto_sign_open()
- 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 2606
Class
Code
public static function crypto_sign_open($signedMessage, $publicKey) {
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($signedMessage, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2);
/* Input validation: */
if (ParagonIE_Sodium_Core_Util::strlen($signedMessage) < self::CRYPTO_SIGN_BYTES) {
throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_BYTES long.');
}
if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_SIGN_PUBLICKEYBYTES) {
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
}
if (self::useNewSodiumAPI()) {
/**
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress FalsableReturnStatement
*/
return sodium_crypto_sign_open($signedMessage, $publicKey);
}
if (self::use_fallback('crypto_sign_open')) {
return call_user_func('\\Sodium\\crypto_sign_open', $signedMessage, $publicKey);
}
if (PHP_INT_SIZE === 4) {
return ParagonIE_Sodium_Crypto32::sign_open($signedMessage, $publicKey);
}
return ParagonIE_Sodium_Crypto::sign_open($signedMessage, $publicKey);
}