Ejemplo n.º 1
0
 protected virtual EncryptedKeyCipher GetCipher(bool base64 = false)
 {
     using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName))
     {
         cipher.Base64Encoded = base64;
         return(cipher.CloneLightCipher() as EncryptedKeyCipher);
     }
 }
Ejemplo n.º 2
0
        public void GetDuplicateWithShouldEncryptIVTest()
        {
            var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName)
            {
                ShouldEncryptIV = true,
            };

            cipher.CloneLightCipher();
        }
        protected override EncryptedKeyCipher GetCipher(bool base64 = false)
        {
            var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName)
            {
                Base64Encoded = base64,
            };

            cipher.ReleaseCertificate();
            return(cipher);
        }
Ejemplo n.º 4
0
        public static void ClassCleanup()
        {
            const string expected      = "The quick fox jumps over the lazy dog.";
            var          keyManagement = new EncryptedKeyCipher(CertificateFactory.GetEncryptingCertificate(), null, expected) as IKeyManagement;

            if (keyManagement.KeyLocation.EndsWith(expected, StringComparison.InvariantCultureIgnoreCase) &&
                File.Exists(keyManagement.KeyLocation))
            {
                File.Delete(keyManagement.KeyLocation);
            }
        }
Ejemplo n.º 5
0
        public virtual void OriginalCanDecryptFromDuplicate()
        {
            const string expected = "The quick fox jumps over the lazy dog.";

            using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), expected))
            {
                cipher.ExportSymmetricKey();

                using (var dupe = cipher.CloneLightCipher())
                {
                    var encrypted = dupe.Encrypt(expected);
                    var decrypted = cipher.Decrypt <string>(encrypted);

                    Assert.AreEqual(expected, decrypted);
                }
            }
        }
        public override void DuplicateCanDecryptFromOriginal()
        {
            const string expected = "The quick fox jumps over the lazy dog.";

            using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName))
            {
                cipher.ExportSymmetricKey();

                var encrypted = cipher.Encrypt(expected);

                cipher.ReleaseCertificate();

                var decrypted = cipher.Decrypt <string>(encrypted);

                Assert.AreEqual(expected, decrypted);
            }
        }