示例#1
0
 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)));
 }
示例#2
0
 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.");
     }
 }
示例#3
0
 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));
 }