Exemple #1
0
#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
        public void DecryptMismatch(AuthenticatedEncryptionTestParams theoryParams)
        {
            try
            {
                theoryParams.Provider.Decrypt(theoryParams.EncryptionResults.Ciphertext, theoryParams.AuthenticatedData, theoryParams.EncryptionResults.IV, theoryParams.EncryptionResults.AuthenticationTag);
                theoryParams.EE.ProcessNoException();
            }
            catch (Exception ex)
            {
                theoryParams.EE.ProcessException(ex);
            }
        }
 public void ValidateKeySize(AuthenticatedEncryptionTestParams theoryParams)
 {
     try
     {
         var provider = theoryParams.Provider as DerivedAuthenticatedEncryptionProvider;
         provider.ValidateKeySizePublic(theoryParams.DecryptKey, theoryParams.DecryptAlgorithm);
         theoryParams.EE.ProcessNoException();
     }
     catch (Exception ex)
     {
         theoryParams.EE.ProcessException(ex);
     }
 }
 public void GetKeyBytes(AuthenticatedEncryptionTestParams theoryParams)
 {
     try
     {
         var provider = theoryParams.Provider as DerivedAuthenticatedEncryptionProvider;
         var result   = provider.GetKeyBytesPublic(theoryParams.DecryptKey);
         Assert.True(Utility.AreEqual(result, theoryParams.Bytes));
         theoryParams.EE.ProcessNoException();
     }
     catch (Exception ex)
     {
         theoryParams.EE.ProcessException(ex);
     }
 }
        public void IsSupportedAlgorithm(AuthenticatedEncryptionTestParams theoryParams)
        {
            try
            {
                var provider = theoryParams.Provider as DerivedAuthenticatedEncryptionProvider;
                var result   = provider.IsSupportedAlgorithmPublic(theoryParams.DecryptKey, theoryParams.DecryptAlgorithm);

                Assert.True(result == theoryParams.IsSupportedAlgorithm);
                theoryParams.EE.ProcessNoException();
            }
            catch (Exception ex)
            {
                theoryParams.EE.ProcessException(ex);
            }
        }
Exemple #5
0
#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
        public void EncryptDecrypt(AuthenticatedEncryptionTestParams theoryParams)
        {
            try
            {
                // use a different provider for encrypting and decrypting to ensure key creation / privated vars are set correctly
                var encryptionProvider = new AuthenticatedEncryptionProvider(theoryParams.EncryptKey, theoryParams.DecryptAlgorithm);
                var decryptionProvider = new AuthenticatedEncryptionProvider(theoryParams.DecryptKey, theoryParams.EncryptAlgorithm);
                var results            = encryptionProvider.Encrypt(theoryParams.Plaintext, theoryParams.AuthenticatedData);
                var cleartext          = decryptionProvider.Decrypt(results.Ciphertext, theoryParams.AuthenticatedData, results.IV, results.AuthenticationTag);

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

                theoryParams.EE.ProcessNoException();
            }
            catch (Exception ex)
            {
                theoryParams.EE.ProcessException(ex);
            }
        }