/// <summary>Verifies a message signed with the SignHmacSha512 method.</summary> /// <param name="message">The message.</param> /// <param name="signature">The 64 byte signature.</param> /// <param name="key">The 32 byte key.</param> /// <returns>True if verified.</returns> /// <exception cref="KeyOutOfRangeException"></exception> /// <exception cref="SignatureOutOfRangeException"></exception> public static bool VerifyHmacSha512(byte[] message, byte[] signature, byte[] key) { //validate the length of the key if (key == null || key.Length != CRYPTO_AUTH_HMACSHA512_KEY_BYTES) { throw new KeyOutOfRangeException("key", (key == null) ? 0 : key.Length, string.Format("key must be {0} bytes in length.", CRYPTO_AUTH_HMACSHA512_KEY_BYTES)); } //validate the length of the signature if (signature == null || signature.Length != CRYPTO_AUTH_HMACSHA512_BYTES) { throw new SignatureOutOfRangeException("signature", (signature == null) ? 0 : signature.Length, string.Format("signature must be {0} bytes in length.", CRYPTO_AUTH_HMACSHA512_BYTES)); } var ret = SodiumLibrary.crypto_auth_hmacsha512_verify(signature, message, message.Length, key); return(ret == 0); }