Пример #1
0
 public void SignAndVerifySignatureECDsa()
 {
     byte[] signature = WinRTCrypto.CryptographicEngine.Sign(this.ecdsaSigningKey, this.data);
     Assert.IsTrue(WinRTCrypto.CryptographicEngine.VerifySignature(this.ecdsaSigningKey, this.data, signature));
     Assert.IsFalse(WinRTCrypto.CryptographicEngine.VerifySignature(this.ecdsaSigningKey, PclTestUtilities.Tamper(this.data), signature));
     Assert.IsFalse(WinRTCrypto.CryptographicEngine.VerifySignature(this.ecdsaSigningKey, this.data, PclTestUtilities.Tamper(signature)));
 }
Пример #2
0
 public void SignAndVerifySignatureRsaSha256()
 {
     try
     {
         byte[] signature = WinRTCrypto.CryptographicEngine.Sign(this.rsaSha256SigningKey, this.data);
         Assert.IsTrue(WinRTCrypto.CryptographicEngine.VerifySignature(this.rsaSha256SigningKey, this.data, signature));
         Assert.IsFalse(WinRTCrypto.CryptographicEngine.VerifySignature(this.rsaSha256SigningKey, PclTestUtilities.Tamper(this.data), signature));
         Assert.IsFalse(WinRTCrypto.CryptographicEngine.VerifySignature(this.rsaSha256SigningKey, this.data, PclTestUtilities.Tamper(signature)));
     }
     catch (NotSupportedException)
     {
         Debug.WriteLine("Not supported by the platform.");
     }
 }
Пример #3
0
 public void SignHashedData_VerifySignatureWithHashInput_Sha256()
 {
     try
     {
         byte[] hash = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithm.Sha256)
                       .HashData(this.data);
         byte[] signature = WinRTCrypto.CryptographicEngine.SignHashedData(this.rsaSha256SigningKey, hash);
         Assert.IsTrue(WinRTCrypto.CryptographicEngine.VerifySignatureWithHashInput(this.rsaSha256SigningKey, hash, signature));
         Assert.IsFalse(WinRTCrypto.CryptographicEngine.VerifySignatureWithHashInput(this.rsaSha256SigningKey, hash, PclTestUtilities.Tamper(signature)));
         Assert.IsFalse(WinRTCrypto.CryptographicEngine.VerifySignatureWithHashInput(this.rsaSha256SigningKey, PclTestUtilities.Tamper(this.data), signature));
     }
     catch (NotSupportedException)
     {
         // Not all platforms support this.
         Debug.WriteLine("Skipped test for unsupported functionality on this platform.");
     }
 }