예제 #1
0
        public FieldLevelEncryption(byte[] rawPublicKeyData, byte[] rawPrivateKeyData, Config config, String publicKeyFingerprint, X509KeyStorageFlags keyStorageFlags = X509KeyStorageFlags.DefaultKeySet)
        {
            if (rawPublicKeyData != null && rawPublicKeyData.LongLength > 0L)
            {
                var tmpPublicCertificate = new X509Certificate2(rawPublicKeyData, String.Empty, keyStorageFlags);
                this.publicKey = (RSACng)tmpPublicCertificate.GetRSAPublicKey();

                if (publicKeyFingerprint != null)
                {
                    this.publicKeyFingerPrint = publicKeyFingerprint;
                }
                else
                {
                    this.publicKeyFingerPrint = tmpPublicCertificate.Thumbprint;
                }
            }

            if (rawPrivateKeyData != null)
            {
                string fullText = Encoding.UTF8.GetString(rawPrivateKeyData);
                this.privateKey = CryptUtil.GetRSAFromPrivateKeyString(fullText);
            }


            this.configuration = config;
        }
예제 #2
0
        public FieldLevelEncryption(String publicKeyLocation, String privateKeyLocation, Config config, String publicKeyFingerprint, X509KeyStorageFlags keyStorageFlags = X509KeyStorageFlags.DefaultKeySet)
        {
            if (publicKeyLocation != null)
            {
                var tmpPublicCertificate = new X509Certificate2(publicKeyLocation, String.Empty, keyStorageFlags);
                this.publicKey = (RSACng)tmpPublicCertificate.GetRSAPublicKey();
                if (publicKeyFingerprint != null)
                {
                    this.publicKeyFingerPrint = publicKeyFingerprint;
                }
                else
                {
                    this.publicKeyFingerPrint = tmpPublicCertificate.Thumbprint;
                }
            }

            if (privateKeyLocation != null)
            {
                string fullText = File.ReadAllText(privateKeyLocation);
                this.privateKey = CryptUtil.GetRSAFromPrivateKeyString(fullText);
            }


            this.configuration = config;
        }
예제 #3
0
        public MDESCryptography(string publicKeyLocation, string privateKeyLocation)
        {
            X509Certificate2 x509Certificate = new X509Certificate2(publicKeyLocation);

            this.publicKey            = x509Certificate.GetRSAPublicKey();
            this.publicKeyFingerPrint = x509Certificate.Thumbprint;
            string text = File.ReadAllText(privateKeyLocation);

            this.privateKey = CryptUtil.GetRSAFromPrivateKeyString(text);
        }
예제 #4
0
        public MDESCryptography(String publicKeyLocation, String privateKeyLocation)
        {
            var tmpPublicCertificate = new X509Certificate2(publicKeyLocation);

            this.publicKey            = tmpPublicCertificate.GetRSAPublicKey();
            this.publicKeyFingerPrint = tmpPublicCertificate.Thumbprint;

            string fullText = File.ReadAllText(privateKeyLocation);

            this.privateKey = CryptUtil.GetRSAFromPrivateKeyString(fullText) as RSA;
        }