Ejemplo n.º 1
0
        public CryptApi(X509Certificate cert, Byte[] clearData)
        {
            clearkey     = CATools.GetCypherKey();
            encryptedKey = Convert.ToBase64String(CATools.AsymmetricEncrypt(cert, Encoding.UTF8.GetBytes(clearkey)));

            clearDataHash = CATools.SHA1Checksum(clearData);

            encryptedData = CATools.Encrypt(clearData, clearkey);
        }
Ejemplo n.º 2
0
        private void BuildServerCert()
        {
            CertificateAuthority.subjectAltName alt = new CertificateAuthority.subjectAltName();
            alt.Dns.Add(this.dnsName);

            ServerPKCS12Cert = ca.SignCert(this.name + " (server)", false, alt, false, DateTime.Now.AddYears(10));

            Byte[] tmp = Convert.FromBase64String(ServerPKCS12Cert);

            X509Certificate cert = CATools.GetX509CertFromPKCS12(tmp, key);

            ServerCert = CATools.X509ToBase64(cert);
        }
Ejemplo n.º 3
0
        public CryptApi(X509Certificate cert, Byte[] encryptedData, String encryptedKey)
        {
            this.encryptedKey  = encryptedKey;
            this.encryptedData = encryptedData;

            Byte[] k = Convert.FromBase64String(encryptedKey);

            if ((k == null) || (k.Length <= 0))
            {
                throw new Exception("Encrypted key is empty");
            }

            clearkey = Encoding.UTF8.GetString(CATools.AsymmetricDencrypt(cert, k));

            clearData     = CATools.Dencrypt(encryptedData, clearkey);
            clearDataHash = CATools.SHA1Checksum(clearData);
        }