private string ReadString(XmlReader xr)
        {
            XorredBuffer xb = ProcessNode(xr);

            if (xb != null)
            {
                Debug.Assert(false);                 // Protected data is unexpected here
                try
                {
                    byte[] pb = xb.ReadPlainText();
                    if (pb.Length == 0)
                    {
                        return(string.Empty);
                    }
                    try { return(StrUtil.Utf8.GetString(pb, 0, pb.Length)); }
                    finally { MemUtil.ZeroByteArray(pb); }
                }
                finally { xb.Dispose(); }
            }

            m_bReadNextNode = false;             // ReadElementString skips end tag
#if ModernKeePassLib
            return(xr.ReadElementContentAsString());
#else
            return(xr.ReadElementString());
#endif
        }
Esempio n. 2
0
        public void Run()
        {
            using (StreamReader reader = File.OpenText(SourceFilePath))
            {
                ClientIdBytes = Encoding.UTF8.GetBytes(
                    reader.ReadLine().Trim());
                ClientSecretBytes = Encoding.UTF8.GetBytes(
                    reader.ReadLine().Trim());
                ClientIdPadBytes     = new byte[ClientIdBytes.Length];
                ClientSecretPadBytes = new byte[ClientSecretBytes.Length];

                using (RandomNumberGenerator rng =
                           RandomNumberGenerator.Create())
                {
                    rng.GetNonZeroBytes(ClientIdPadBytes);
                    rng.GetNonZeroBytes(ClientSecretPadBytes);
                }

                XorredBuffer clientIdBuf = new XorredBuffer(ClientIdBytes,
                                                            ClientIdPadBytes);
                XorredBuffer secretBuf = new XorredBuffer(ClientSecretBytes,
                                                          ClientSecretPadBytes);

                ClientIdCsharpConstant        = GenSrc(clientIdBuf.ReadPlainText());
                ClientIdPadCsharpConstant     = GenSrc(ClientIdPadBytes);
                ClientSecretCsharpConstant    = GenSrc(secretBuf.ReadPlainText());
                ClientSecretPadCsharpConstant = GenSrc(ClientSecretPadBytes);
            }
        }
Esempio n. 3
0
        internal string ReadString(XmlReader xr)
        {
            XorredBuffer xb = ProcessNode(xr);

            if (xb != null)
            {
                byte[] pb = xb.ReadPlainText();
                return(Encoding.UTF8.GetString(pb, 0, pb.Length));
            }

            m_bReadNextNode = false;             // ReadElementString skips end tag
            return(xr.ReadElementString());
        }
Esempio n. 4
0
        private string ReadString(XmlReader xr)
        {
            XorredBuffer xb = ProcessNode(xr);

            if (xb != null)
            {
                byte[] pb = xb.ReadPlainText();
                if (pb.Length == 0)
                {
                    return(string.Empty);
                }
                return(StrUtil.Utf8.GetString(pb, 0, pb.Length));
            }

            m_bReadNextNode = false;             // ReadElementString skips end tag
            return(xr.ReadElementString());
        }