/// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        //public TestContext TestContext { get; set; }

        public override IHasherTasks GetHasher()
        {
            using (var cipher = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), _keyFileName, hashAlgorithmName: null))
            {
                return(cipher.CloneLightHasher() as IHasherTasks);
            }
        }
Exemple #2
0
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        //public TestContext TestContext { get; set; }

        public override IHasherAsync GetHasher()
        {
            using (var cipher = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), null, keyFileName))
            {
                return(cipher.CloneLightHasher() as IHasherAsync);
            }
        }
Exemple #3
0
 protected virtual EncryptedKeyCipher GetCipher(bool base64 = false)
 {
     using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName))
     {
         cipher.Base64Encoded = base64;
         return(cipher.CloneLightCipher() as EncryptedKeyCipher);
     }
 }
Exemple #4
0
        public override ICipherTasks GetCipher(bool base64 = false)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var cipher = new EncryptedNewKeyHashedCipher(CertificateFactory.GetDecryptingCertificate(), Algorithms.Hash.MD5, Algorithms.Symmetric.Aes);
#pragma warning restore CS0618 // Type or member is obsolete

            // ignore the parameter base64
            return(cipher);
        }
Exemple #5
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);
        }
Exemple #7
0
        public void StrippedCanVerifyItsOwn()
        {
            const string expected = "The quick fox jumps over the lazy dog.";

            using (var stripped = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), null, keyFileName).ReleaseCertificate())
            {
                var hash = stripped.Hash(expected);

                Assert.IsTrue(stripped.TryVerifyHash(expected, hash));
            }
        }
        public void CloneCanVerifyItsOwn()
        {
            const string expected = "The quick fox jumps over the lazy dog.";

            using (var hasher = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), _keyFileName, hashAlgorithmName: null))
                using (var clone = hasher.CloneLightHasher())
                {
                    var hash = clone.Hash(expected);

                    Assert.IsTrue(clone.TryVerifyHash(expected, hash));
                }
        }
        public void OriginalCanVerifyStripped()
        {
            const string expected = "The quick fox jumps over the lazy dog.";

            using (var stripped = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), _keyFileName, hashAlgorithmName: null).ReleaseCertificate())
                using (var original = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), _keyFileName, hashAlgorithmName: null))
                {
                    var hash = stripped.Hash(expected);

                    Assert.IsTrue(original.TryVerifyHash(expected, hash));
                }
        }
Exemple #10
0
        public void OriginalCanVerifyClone()
        {
            const string expected = "The quick fox jumps over the lazy dog.";

            using (var hasher = new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), null, keyFileName))
                using (var clone = hasher.CloneLightHasher())
                {
                    var hash = clone.Hash(expected);

                    Assert.IsTrue(hasher.TryVerifyHash(expected, hash));
                }
        }
        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);
            }
        }
Exemple #12
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);
                }
            }
        }
Exemple #13
0
 public InheritedHasher()
     : base(CertificateFactory.GetDecryptingCertificate())
 {
 }
Exemple #14
0
 static IHasherAsync GetHasherImpl() => new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), null, "encryptedHashKey.key");
Exemple #15
0
 public InheritedEncryptedNewKeyCipher()
     : base(CertificateFactory.GetDecryptingCertificate(), null)
 {
 }
Exemple #16
0
 public override ICipherAsync GetCipher(bool base64 = false)
 => new EncryptedNewKeyCipher(CertificateFactory.GetDecryptingCertificate())
 {
     Base64Encoded = base64,
 };
Exemple #17
0
 public override IHasherAsync GetHasher() => new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), null, keyFileName).ReleaseCertificate();
Exemple #18
0
 public override ICipherAsync GetCipher(bool base64 = false)
 => new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), null, _keyFileName)
 {
     Base64Encoded = base64,
 };
Exemple #19
0
 public void GetCipherNullSignCertTest()
 {
     new EncryptedNewKeySignedCipher(CertificateFactory.GetDecryptingCertificate(), null); // default SHA1, SHA256 doesn't work here
 }
 public override IHasherTasks GetHasher() => new KeyedHasher(CertificateFactory.GetDecryptingCertificate(), _keyFileName, hashAlgorithmName: null).ReleaseCertificate();
 public InheritedEncryptedKeyCipher()
     : base(CertificateFactory.GetDecryptingCertificate(), Algorithms.Symmetric.Default, null)
 {
 }