public static bool Verify(byte[] publicKey, byte[] signature, Stream stream) { #if Mono throw new NotSupportedException(); #else try { using (ECDsaCng ecdsa = new ECDsaCng()) { ecdsa.FromXmlString(Encoding.ASCII.GetString(publicKey), ECKeyXmlFormat.Rfc4050); ecdsa.HashAlgorithm = CngAlgorithm.Sha256; return ecdsa.VerifyData(stream, signature); } } catch (Exception) { return false; } #endif }
public FakeEccKeyRepository(CngKey key) { _key = key; var xml = new ECDsaCng(_key).ToXmlString(ECKeyXmlFormat.Rfc4050); _public = new ECDsaCng(); _public.FromXmlString(xml, ECKeyXmlFormat.Rfc4050); }