ParagonIE_Sodium_Compat::crypto_auth() public WP 1.0
Authenticate a message. Uses symmetric-key cryptography.
Algorithm:
HMAC-SHA512-256. Which is HMAC-SHA-512 truncated to 256 bits. Not to be confused with HMAC-SHA-512/256 which would use the SHA-512/256 hash function (uses different initial parameters but still truncates to 256 bits to sidestep length-extension attacks).
{} It's a method of the class: ParagonIE_Sodium_Compat{}
No Hooks.
Return
String
. Message authentication code
Usage
$result = ParagonIE_Sodium_Compat::crypto_auth( $message, $key );
- $message(string) (required)
- Message to be authenticated
- $key(string) (required)
- Symmetric authentication key
Code of ParagonIE_Sodium_Compat::crypto_auth() ParagonIE Sodium Compat::crypto auth WP 5.7.1
public static function crypto_auth($message, $key)
{
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 2);
/* Input validation: */
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AUTH_KEYBYTES) {
throw new SodiumException('Argument 2 must be CRYPTO_AUTH_KEYBYTES long.');
}
if (self::useNewSodiumAPI()) {
return (string) sodium_crypto_auth($message, $key);
}
if (self::use_fallback('crypto_auth')) {
return (string) call_user_func('\\Sodium\\crypto_auth', $message, $key);
}
if (PHP_INT_SIZE === 4) {
return ParagonIE_Sodium_Crypto32::auth($message, $key);
}
return ParagonIE_Sodium_Crypto::auth($message, $key);
}