You are here

public static function ParagonIE_Sodium_Compat::crypto_sign 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()

Returns a signed message. You probably want crypto_sign_detached() instead, which only returns the signature.

Algorithm: Ed25519 (EdDSA over Curve25519)

@psalm-suppress MixedArgument @psalm-suppress MixedInferredReturnType @psalm-suppress MixedReturnStatement

Parameters

string $message Message to be signed.:

string $secretKey Secret signing key.:

Return value

string Signed message (signature is prefixed).

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Compat::crypto_sign()
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 2570

Class

ParagonIE_Sodium_Compat

Code

public static function crypto_sign($message, $secretKey) {

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

  /* Input validation: */
  if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_SIGN_SECRETKEYBYTES) {
    throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
  }
  if (self::useNewSodiumAPI()) {
    return sodium_crypto_sign($message, $secretKey);
  }
  if (self::use_fallback('crypto_sign')) {
    return (string) call_user_func('\\Sodium\\crypto_sign', $message, $secretKey);
  }
  if (PHP_INT_SIZE === 4) {
    return ParagonIE_Sodium_Crypto32::sign($message, $secretKey);
  }
  return ParagonIE_Sodium_Crypto::sign($message, $secretKey);
}