Exemplo n.º 1
0
        private static byte[] GetIV(string containerName)
        {
            byte[] e, m = null;
            byte[] s    = Utils.StringToUTF8Bytes(Constants.CONST2);

            string xmlKey = RSACipher.ExportKeyAsXmlString(containerName);
            RSACryptoServiceProvider rsa = RSACipher.ImportKeyFromXmlString(containerName, xmlKey);

            RSACipher.QueryRsaKeyParameters(rsa, out m, out e);

            byte[] h3       = HashControl.GetSHA512ManagedHash(m, e);
            string h3Base64 = Utils.BytesToBase64String(h3);

            return(HashControl.DerivePasswordBytes(h3Base64, h3, 32));
        }
Exemplo n.º 2
0
        private static byte[] GetKey(string containerName)
        {
            byte[] d, p, q = null;
            byte[] s       = Utils.StringToUTF8Bytes(Constants.CONST1);

            string xmlKey = RSACipher.ExportKeyAsXmlString(containerName);
            RSACryptoServiceProvider rsa = RSACipher.ImportKeyFromXmlString(containerName, xmlKey);

            RSACipher.QueryRsaKeyParameters(rsa, out d, out p, out q);

            byte[] h1 = HashControl.GetSHA512ManagedHash(d, p);
            byte[] h2 = HashControl.GetSHA512ManagedHash(q, s);

            string h1Base64 = Utils.BytesToBase64String(h1);

            return(HashControl.DerivePasswordBytes(h1Base64, h2, 32));
        }