Exemplo n.º 1
0
        private static byte[] GetEntropy()
        {
            byte[] h1 = HashControl.GetSHA512ManagedHash(Constants.CONST1, Constants.CONST6);
            byte[] h2 = HashControl.GetSHA512ManagedHash(Constants.CONST2, Constants.CONST5);
            byte[] h3 = HashControl.GetSHA512ManagedHash(Constants.CONST3, Constants.CONST4);

            byte[] retVal;

            byte[] salt         = Utils.ConcatByteArrarys(h1, h2);
            string base64edSalt = Utils.BytesToBase64String(salt);

            retVal = HashControl.DerivePasswordBytes(base64edSalt, h3, 1024);

            return(retVal);
        }
Exemplo n.º 2
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.º 3
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));
        }