public byte[] Hash( Key key, ReadOnlySpan <byte> data, int hashSize) { if (key == null) { throw Error.ArgumentNull_Key(nameof(key)); } if (key.Algorithm != this) { throw Error.Argument_KeyWrongAlgorithm(nameof(key), key.Algorithm.GetType().FullName, GetType().FullName); } if (hashSize < MinHashSize || hashSize > MaxHashSize) { throw Error.ArgumentOutOfRange_HashSize(nameof(hashSize), hashSize.ToString(), MinHashSize.ToString(), MaxHashSize.ToString()); } byte[] hash = new byte[hashSize]; HashCore(key.Handle, data, hash); return(hash); }
public void Hash( Key key, ReadOnlySpan <byte> data, Span <byte> hash) { if (key == null) { throw Error.ArgumentNull_Key(nameof(key)); } if (key.Algorithm != this) { throw Error.Argument_KeyWrongAlgorithm(nameof(key), key.Algorithm.GetType().FullName, GetType().FullName); } if (hash.Length < MinHashSize || hash.Length > MaxHashSize) { throw Error.Argument_HashSize(nameof(hash), hash.Length.ToString(), MinHashSize.ToString(), MaxHashSize.ToString()); } HashCore(key.Handle, data, hash); }
public void Verify( Key key, ReadOnlySpan <byte> data, ReadOnlySpan <byte> hash) { if (key == null) { throw Error.ArgumentNull_Key(nameof(key)); } if (key.Algorithm != this) { throw Error.Argument_KeyWrongAlgorithm(nameof(key), key.Algorithm.GetType().FullName, GetType().FullName); } if (hash.Length < MinHashSize || hash.Length > MaxHashSize) { throw Error.Argument_HashSize(nameof(hash), hash.Length.ToString(), MinHashSize.ToString(), MaxHashSize.ToString()); } if (!TryVerifyCore(key.Handle, data, hash)) { throw Error.Cryptographic_VerificationFailed(); } }