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."); } }
////[Fact] ////public void SignedDataVerifyInterop() ////{ ////} ////[Fact] ////public void SignedHashVerifyInterop() ////{ ////} private void LogRSAParameterComparison(string p1Name, RSAParameters p1, string p2Name, RSAParameters p2) { int alignment = Math.Max(p1Name.Length, p2Name.Length) + 1; string prefix = "{0,-" + alignment + "}"; this.logger.WriteLine(prefix + "P: {1}", p1Name, PclTestUtilities.Hex(p1.P)); this.logger.WriteLine(prefix + "P: {1}", p2Name, PclTestUtilities.Hex(p2.P)); this.logger.WriteLine(prefix + "Q: {1}", p1Name, PclTestUtilities.Hex(p1.Q)); this.logger.WriteLine(prefix + "Q: {1}", p2Name, PclTestUtilities.Hex(p2.Q)); this.logger.WriteLine(prefix + "D: {1}", p1Name, PclTestUtilities.Hex(p1.D)); this.logger.WriteLine(prefix + "D: {1}", p2Name, PclTestUtilities.Hex(p2.D)); this.logger.WriteLine(prefix + "DP: {1}", p1Name, PclTestUtilities.Hex(p1.DP)); this.logger.WriteLine(prefix + "DP: {1}", p2Name, PclTestUtilities.Hex(p2.DP)); this.logger.WriteLine(prefix + "DQ: {1}", p1Name, PclTestUtilities.Hex(p1.DQ)); this.logger.WriteLine(prefix + "DQ: {1}", p2Name, PclTestUtilities.Hex(p2.DQ)); this.logger.WriteLine(prefix + "InverseQ: {1}", p1Name, PclTestUtilities.Hex(p1.InverseQ)); this.logger.WriteLine(prefix + "InverseQ: {1}", p2Name, PclTestUtilities.Hex(p2.InverseQ)); }
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)); }