protected static function verifyMAC(string $mac, string $message, string $authKey, SymmetricConfig $config) : bool
{
if (CryptoUtil::safeStrlen($mac) !== $config->MAC_SIZE) {
throw new InvalidSignature('Argument 1: Message Authentication Code is not the correct length; is it encoded?');
}
if ($config->MAC_ALGO === 'BLAKE2b') {
$calc = \Sodium\crypto_generichash($message, $authKey, $config->MAC_SIZE);
$res = \hash_equals($mac, $calc);
\Sodium\memzero($calc);
return $res;
}
throw new InvalidMessage('Invalid Halite version');
}