Example #1
0
        public void PublicCertificateTest()
        {
            var input     = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
            var target    = GetCipher();
            var encrypted = target.Encrypt(input);

            target = new EncryptedKeyCipher(CertificateFactory.GetEncryptingCertificate(), null, _keyFileName);

            var output = target.Decrypt(encrypted);
        }
Example #2
0
        public static void ClassCleanup()
        {
            var keyManagement = new EncryptedKeyCipher(CertificateFactory.GetEncryptingCertificate(), null, _keyFileName) as IKeyManagement;

            if (keyManagement.KeyLocation.EndsWith(_keyFileName, StringComparison.InvariantCultureIgnoreCase) &&
                File.Exists(keyManagement.KeyLocation))
            {
                File.Delete(keyManagement.KeyLocation);
            }
        }
Example #3
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);
            }
        }
Example #4
0
 public override ICipherAsync GetPublicCertCipher(bool base64 = false)
 => new EncryptedNewKeyCipher(CertificateFactory.GetEncryptingCertificate())
 {
     Base64Encoded = base64,
 };
Example #5
0
 public override ICipherAsync GetPublicCertCipher(bool base64 = false)
 => new EncryptedKeyCipher(CertificateFactory.GetEncryptingCertificate(), null, _keyFileName)
 {
     Base64Encoded = base64,
 };
Example #6
0
 public InheritedEncryptedKeyCipher()
     : base(null, CertificateFactory.GetEncryptingCertificate())
 {
 }
Example #7
0
 public InheritedEncryptedNewKeySignedCipher()
     : base(CertificateFactory.GetEncryptingCertificate(), CertificateFactory.GetSigningCertificate(), null)
 {
 }
Example #8
0
            CertificateFactory.GetSigningCertificate());                                             // SHA1 also works with this cert

        static ICipherAsync GetPublicCertCipherImpl() => new EncryptedNewKeySignedCipher(
            CertificateFactory.GetEncryptingCertificate(),
            CertificateFactory.GetSigningCertificate());                                                     // default SHA1, SHA256 doesn't work here
Example #9
0
 public InheritedEncryptedKeyCipher()
     : base(CertificateFactory.GetEncryptingCertificate(), Algorithms.Symmetric.Default, null)
 {
 }
Example #10
0
#pragma warning disable CS0618 // Type or member is obsolete
        public override ICipherTasks GetPublicCertCipher(bool base64 = false) => new EncryptedNewKeyHashedCipher(CertificateFactory.GetEncryptingCertificate(), Algorithms.Hash.MD5, Algorithms.Symmetric.Aes);