Ejemplo n.º 1
0
        private bool checkNPDHash1(String filename, byte[] npd)
        {
            byte[] fileBytes = ConversionUtils.charsToByte(filename.ToCharArray());
            byte[] data1     = new byte[0x30 + fileBytes.Length];
            ConversionUtils.arraycopy(npd, 0x10, data1, 0, 0x30);
            ConversionUtils.arraycopy(fileBytes, 0x00, data1, 0x30, fileBytes.Length);
            byte[] hash1   = ToolsImpl.CMAC128(EDATKeys.npdrm_omac_key3, data1, 0, data1.Length);
            bool   result1 = compareBytes(hash1, 0, npd, 0x50, 0x10);

            if (result1)
            {
                Console.WriteLine("NPD hash 1 is valid (" + ConversionUtils.getHexString(hash1) + ")");
            }
            return(result1);
        }
Ejemplo n.º 2
0
        private byte[] createNPDHash1(String filename, byte[] npd)
        {
            byte[] fileBytes = ConversionUtils.charsToByte(filename.ToCharArray());
            byte[] data1     = new byte[0x30 + fileBytes.Length];
            ConversionUtils.arraycopy(npd, 0x10, data1, 0, 0x30);
            ConversionUtils.arraycopy(fileBytes, 0x00, data1, 0x30, fileBytes.Length);
            byte[] hash1 = ToolsImpl.CMAC128(EDATKeys.npdrm_omac_key3, data1, 0, data1.Length);
            ConversionUtils.arraycopy(hash1, 0, npd, 0x50, 0x10);
            bool result1 = compareBytes(hash1, 0, npd, 0x50, 0x10);

            if (result1)
            {
                return(hash1);
            }
            return(null);
        }
Ejemplo n.º 3
0
        private byte[] writeValidNPD(String filename, byte[] devKLic, NPD[] npdPtr, FileStream fin, byte[] contentID, byte[] flags, byte[] version, byte[] type)
        {
            byte[] npd = new byte[0x80];
            //NPD Magic
            //ConversionUtils.arraycopy(npd, 0, result.magic, 0, 4);
            npd[0] = 0x4E;
            npd[1] = 0x50;
            npd[2] = 0x44;
            npd[3] = 0x00;
            //Version 3
            //result.version = ConversionUtils.be32(npd, 4);
            npd[4] = 0x00;
            npd[5] = 0x00;
            npd[6] = 0x00;
            npd[7] = version[0];
            //License 2 ref 3 klic /* 1 network, 2 local, 3 free */
            //result.license = ConversionUtils.be32(npd, 8);
            npd[8]  = 0x00;
            npd[9]  = 0x00;
            npd[10] = 0x00;
            npd[11] = 0x03;


            //Type /* 1 exec, 21 update */
            //result.type = ConversionUtils.be32(npd, 0xC);
            npd[12] = 0x00;
            npd[13] = 0x00;
            npd[14] = 0x00;
            npd[15] = type[0];

            //No Idea where I get the content_id
            //ConversionUtils.arraycopy(npd, 0x10, result.content_id, 0, 0x30
            for (int i = 0; i < 0x30; i++)
            {
                npd[0x10 + i] = contentID[i];
            }



            //Used to create IV
            //ConversionUtils.arraycopy(npd, 0x40, result.digest, 0, 0x10);
            byte[] iv = ConversionUtils.charsToByte(("FixedLicenseEDAT").ToCharArray());
            ConversionUtils.arraycopy(iv, 0, npd, 0x40, 0x10);

            //I guess it's a full file hash
            //ConversionUtils.arraycopy(npd, 0x50, result.titleHash, 0, 0x10);
            byte[] hash = createNPDHash1(filename, npd);
            ConversionUtils.arraycopy(hash, 0x00, npd, 0x50, 0x10);


            //Used to create Blockkey
            //ConversionUtils.arraycopy(npd, 0x60, result.devHash, 0, 0x10);
            byte[] devHash = createNPDHash2(devKLic, npd);
            ConversionUtils.arraycopy(devHash, 0, npd, 0x60, 0x10);

            //NPD EOF?!?!?!
            //result.unknown3 = ConversionUtils.be64(npd, 0x70);
            //result.unknown4 = ConversionUtils.be64(npd, 0x78);
            for (int i = 0; i < 16; i++)
            {
                npd[0x70 + i] = 0x00;
            }

            npdPtr[0] = NPD.createNPD(npd);
            return(npd);
        }