public void DecryptMismatch(AuthenticatedEncryptionTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.DecryptMismatch", theoryData);

            try
            {
                theoryData.Provider.Decrypt(theoryData.EncryptionResults.Ciphertext, theoryData.AuthenticatedData, theoryData.EncryptionResults.IV, theoryData.EncryptionResults.AuthenticationTag);
                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
        public void ValidateKeySize(AuthenticatedEncryptionTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.ValidateKeySize", theoryData);

            try
            {
                var provider = theoryData.Provider as DerivedAuthenticatedEncryptionProvider;
                provider.ValidateKeySizePublic(theoryData.DecryptKey, theoryData.DecryptAlgorithm);
                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
        public void GetKeyBytes(AuthenticatedEncryptionTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.GetKeyBytes", theoryData);

            try
            {
                var provider = theoryData.Provider as DerivedAuthenticatedEncryptionProvider;
                var result   = provider.GetKeyBytesPublic(theoryData.DecryptKey);
                Assert.True(Utility.AreEqual(result, theoryData.Bytes));
                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
        public void IsSupportedAlgorithm(AuthenticatedEncryptionTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.IsSupportedAlgorithm", theoryData);

            try
            {
                var provider = theoryData.Provider as DerivedAuthenticatedEncryptionProvider;
                var result   = provider.IsSupportedAlgorithmPublic(theoryData.DecryptKey, theoryData.DecryptAlgorithm);

                Assert.True(result == theoryData.IsSupportedAlgorithm);
                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
        public void EncryptDecrypt(AuthenticatedEncryptionTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.EncryptDecrypt", theoryData);

            try
            {
                // use a different provider for encrypting and decrypting to ensure key creation / privated vars are set correctly
                var encryptionProvider = new AuthenticatedEncryptionProvider(theoryData.EncryptKey, theoryData.DecryptAlgorithm);
                var decryptionProvider = new AuthenticatedEncryptionProvider(theoryData.DecryptKey, theoryData.EncryptAlgorithm);
                var results            = encryptionProvider.Encrypt(theoryData.Plaintext, theoryData.AuthenticatedData);
                var cleartext          = decryptionProvider.Decrypt(results.Ciphertext, theoryData.AuthenticatedData, results.IV, results.AuthenticationTag);

                Assert.True(Utility.AreEqual(theoryData.Plaintext, cleartext), "theoryParams.PlainText != clearText");

                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
        public void Dispose(AuthenticatedEncryptionTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.Dispose", theoryData);

            try
            {
                var results   = theoryData.EncryptionProvider.Encrypt(theoryData.Plaintext, theoryData.AuthenticatedData);
                var cleartext = theoryData.DecryptionProvider.Decrypt(results.Ciphertext, theoryData.AuthenticatedData, results.IV, results.AuthenticationTag);

                if (!Utility.AreEqual(theoryData.Plaintext, cleartext))
                {
                    context.AddDiff($"theoryParams.PlainText != clearText. plaintext: '{theoryData.Plaintext}', clearText: '{cleartext}'.");
                }

                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }