public void SignAndVerifySignatureMac() { byte[] signature = WinRTCrypto.CryptographicEngine.Sign(this.macKey, this.data); Assert.True(WinRTCrypto.CryptographicEngine.VerifySignature(this.macKey, this.data, signature)); Assert.False(WinRTCrypto.CryptographicEngine.VerifySignature(this.macKey, PclTestUtilities.Tamper(this.data), signature)); Assert.False(WinRTCrypto.CryptographicEngine.VerifySignature(this.macKey, this.data, PclTestUtilities.Tamper(signature))); }
public void SignAndVerifySignature(ICryptographicKey key) { try { byte[] signature = WinRTCrypto.CryptographicEngine.Sign(key, this.data); Assert.True(WinRTCrypto.CryptographicEngine.VerifySignature(key, this.data, signature)); Assert.False(WinRTCrypto.CryptographicEngine.VerifySignature(key, PclTestUtilities.Tamper(this.data), signature)); Assert.False(WinRTCrypto.CryptographicEngine.VerifySignature(key, this.data, PclTestUtilities.Tamper(signature))); } catch (NotSupportedException) { this.logger.WriteLine("Not supported by the platform."); } }
public void SignHashedData_VerifySignatureWithHashInput(ICryptographicKey key, HashAlgorithm hashAlgorithm) { byte[] hash = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(hashAlgorithm) .HashData(this.data); byte[] signature = WinRTCrypto.CryptographicEngine.SignHashedData(key, hash); Assert.True(WinRTCrypto.CryptographicEngine.VerifySignatureWithHashInput(key, hash, signature)); Assert.False(WinRTCrypto.CryptographicEngine.VerifySignatureWithHashInput(key, hash, PclTestUtilities.Tamper(signature))); Assert.False(WinRTCrypto.CryptographicEngine.VerifySignatureWithHashInput(key, PclTestUtilities.Tamper(this.data), signature)); }