/// <summary>Verifies a message signed with the Sign method.</summary> /// <param name="message">The message.</param> /// <param name="signature">The 16 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 Verify(byte[] message, byte[] signature, byte[] key) { //validate the length of the key if (key == null || key.Length != KEY_BYTES) { throw new KeyOutOfRangeException("key", (key == null) ? 0 : key.Length, string.Format("key must be {0} bytes in length.", KEY_BYTES)); } //validate the length of the signature if (signature == null || signature.Length != BYTES) { throw new SignatureOutOfRangeException("signature", (signature == null) ? 0 : signature.Length, string.Format("signature must be {0} bytes in length.", BYTES)); } var ret = SodiumLibrary.crypto_onetimeauth_verify(signature, message, message.Length, key); return(ret == 0); }