コード例 #1
0
        public bool LoadAICHHashsetFromFile(Mpd.Generic.IO.FileDataIO pFile, bool bVerify)
        {
            m_aAICHPartHashSet.Clear();
            AICHHash masterHash =
                MuleApplication.Instance.AICHObjectManager.CreateAICHHash(pFile);

            if (HasAICHHash && masterHash != AICHHash)
            {
                return(false);
            }
            ushort nCount = pFile.ReadUInt16();

            for (int i = 0; i < nCount; i++)
            {
                m_aAICHPartHashSet.Add(MuleApplication.Instance.AICHObjectManager.CreateAICHHash(pFile));
            }
            if (bVerify)
            {
                return(VerifyAICHHashSet());
            }
            else
            {
                return(true);
            }
        }
コード例 #2
0
        public bool LoadMD4HashsetFromFile(Mpd.Generic.IO.FileDataIO file, bool bVerifyExistingHash)
        {
            byte[] checkid = new byte[16];
            file.ReadHash16(checkid);
            DeleteMD4Hashset();

            uint parts = file.ReadUInt16();

            //TRACE("Nr. hashs: %u\n", (uint)parts);
            if (bVerifyExistingHash &&
                (MpdUtilities.Md4Cmp(MD4Hash, checkid) != 0 ||
                 parts != TheoreticalMD4PartHashCount))
            {
                return(false);
            }
            for (uint i = 0; i < parts; i++)
            {
                byte[] cur_hash = new byte[16];
                file.ReadHash16(cur_hash);
                m_aMD4HashSet.Add(cur_hash);
            }

            if (!bVerifyExistingHash)
            {
                MpdUtilities.Md4Cpy(MD4Hash, checkid);
            }

            // Calculate hash out of hashset and compare to existing filehash
            if (m_aMD4HashSet.Count > 0)
            {
                return(CalculateMD4HashByHashSet(true, true));
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        public bool ReadHashSetsFromPacket(Mpd.Generic.IO.FileDataIO pFile, ref bool rbMD4, ref bool rbAICH)
        {
            byte byOptions    = pFile.ReadUInt8();
            bool bMD4Present  = (byOptions & 0x01) > 0;
            bool bAICHPresent = (byOptions & 0x02) > 0;

            // We don't abort on unkown option, because even if there is another unknown hashset, there is no data afterwards we
            // try to read on the only occasion this function is used. So we might be able to add optional flags in the future
            // without having to adjust the protocol any further (new additional data/hashs should not be appended without adjustement however)

            if (bMD4Present && !rbMD4)
            {
                // Even if we don't want it, we still have to read the file to skip it
                byte[] tmpHash = new byte[16];
                pFile.ReadHash16(tmpHash);
                uint parts = pFile.ReadUInt16();
                for (uint i = 0; i < parts; i++)
                {
                    pFile.ReadHash16(tmpHash);
                }
            }
            else if (!bMD4Present)
            {
                rbMD4 = false;
            }
            else if (bMD4Present && rbMD4)
            {
                if (!LoadMD4HashsetFromFile(pFile, true))
                {       // corrupt
                    rbMD4  = false;
                    rbAICH = false;
                    return(false);
                }
            }

            if (bAICHPresent && !rbAICH)
            {
                // Even if we don't want it, we still have to read the file to skip it
                AICHHash tmpHash =
                    MuleApplication.Instance.AICHObjectManager.CreateAICHHash(pFile);
                ushort nCount = pFile.ReadUInt16();
                for (int i = 0; i < nCount; i++)
                {
                    tmpHash.Read(pFile);
                }
            }
            else if (!bAICHPresent || !HasAICHHash)
            {
                rbAICH = false;
            }
            else if (bAICHPresent && rbAICH)
            {
                if (!LoadAICHHashsetFromFile(pFile, true))
                {       // corrupt
                    if (rbMD4)
                    {
                        DeleteMD4Hashset();
                        rbMD4 = false;
                    }
                    rbAICH = false;
                    return(false);
                }
            }
            return(true);
        }