Esempio n. 1
0
        public void TestRoundTripeEmpty()
        {
            const string TestString = "";

            CertificateHelper.InvokeWithDummyCert(
                (fingerprint) =>
            {
                var encrypted = DataTransform.Encrypt(fingerprint, TestString);
                var decrypted = DataTransform.Decrypt(encrypted);

                Assert.AreEqual(decrypted, TestString);
            });
        }
Esempio n. 2
0
        public void TestRoundTrip2()
        {
            const string TestString =
                "asdfasdfas;dlffkjpowQYB93YRY7982UO1HQW AHAUI FACPWUH F CAHGUIWEA RY93QRCHWEFCS;DHFVOAWGOSE7R HAE";

            CertificateHelper.InvokeWithDummyCert(
                (fingerprint) =>
            {
                var encrypted = DataTransform.Encrypt(fingerprint, TestString);
                var decrypted = DataTransform.Decrypt(encrypted);

                Assert.AreEqual(decrypted, TestString);
            });
        }
Esempio n. 3
0
        private CertificateHelper()
        {
            this.store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            this.store.Open(OpenFlags.MaxAllowed);
            var found = this.store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, $"CN={CertificateHelper.CertificateName}", false);

            if (found.Count == 0)
            {
                CertificateHelper.CreateX509Certificate();
                found = this.store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, $"CN={CertificateHelper.CertificateName}", false);
            }

            if (found.Count != 1)
            {
                throw new Exception("CERTIFICATE FAILURE");
            }

            this.cert = found[0];
        }