public void RSASignVerifyData(RSACryptoServiceProviderProxyTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.RSASignVerifyData", theoryData); try { var proxy = new RSACryptoServiceProviderProxy(theoryData.RsaCryptoServiceProvider); var signatureProxy = proxy.SignData(theoryData.Input, theoryData.HashAlgorithm); var signatureRsa = theoryData.RsaCryptoServiceProvider.SignData(theoryData.Input, theoryData.HashAlgorithm); IdentityComparer.AreBytesEqual(signatureProxy, signatureRsa, context); if (!proxy.VerifyData(theoryData.Input, theoryData.HashAlgorithm, signatureRsa)) { context.AddDiff("!proxy.VerifyData(theoryData.Input, theoryData.HashAlgorithm, signatureRsa)"); } if (!theoryData.RsaCryptoServiceProvider.VerifyData(theoryData.Input, theoryData.HashAlgorithm, signatureProxy)) { context.AddDiff("!theoryData.RsaCryptoServiceProvider.VerifyData(theoryData.Input, theoryData.HashAlgorithm, signatureProxy)"); } } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public void RSADecryptValue(RSACryptoServiceProviderProxyTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.RSADecryptValue", theoryData); try { var proxy = new RSACryptoServiceProviderProxy(theoryData.RsaCryptoServiceProvider); proxy.DecryptValue(theoryData.Input); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public void RSAVerifyData(RSACryptoServiceProviderProxyTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.RSAVerifyData", theoryData); try { var proxy = new RSACryptoServiceProviderProxy(theoryData.RsaCryptoServiceProvider); proxy.VerifyData(theoryData.Input, theoryData.HashAlgorithm, theoryData.Signature); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public void RSAEncryptDecryptValue(RSACryptoServiceProviderProxyTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.RSAEncryptDecryptValue", theoryData); try { var proxy = new RSACryptoServiceProviderProxy(theoryData.RsaCryptoServiceProvider); var cipherTextProxy = proxy.EncryptValue(theoryData.Input); var cipherTextRsa = theoryData.RsaCryptoServiceProvider.EncryptValue(theoryData.Input); IdentityComparer.AreBytesEqual( proxy.DecryptValue(cipherTextProxy), theoryData.RsaCryptoServiceProvider.DecryptValue(cipherTextRsa), context); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }