Exemple #1
0
        /*
         * BBMac functions.
         */

        public static int sceDrmBBMacInit(Crypto.MAC_KEY mkey, int type)
        {
            //var temp = (Crypto.MAC_KEY*)(mkey);
            mkey.type     = type;
            mkey.pad_size = 0;

            return(0);
        }
Exemple #2
0
        public static uint sceNpDrmGetFixedKey(ref byte key, ref string npstr, int type)
        {
            Crypto.AES_ctx akey   = new Crypto.AES_ctx();
            Crypto.MAC_KEY mkey   = new Crypto.MAC_KEY();
            string         strbuf = new string(new char[0x30]);
            int            retv;

            if ((type & 0x01000000) == 0)
            {
                return(0x80550901);
            }

            type &= 0x000000ff;

            strbuf = npstr.Substring(0, 0x30);

            retv = sceDrmBBMacInit(mkey, 1);

            if (retv != 0)
            {
                return((uint)retv);
            }

            //retv = sceDrmBBMacUpdate(mkey, (byte)strbuf, 0x30);

            //if (retv != 0)
            //{
            //    return retv;
            //}

            //retv = sceDrmBBMacFinal(mkey, ref key, npdrm_fixed_key);

            if (retv != 0)
            {
                return(0x80550902);
            }

            if (type == 0)
            {
                return(0);
            }
            if (type > 3)
            {
                return(0x80550901);
            }

            type = (type - 1) * 16;

            // Crypto.AES_set_key(akey, npdrm_enc_keys[type], 128);
            //   Crypto.AES_encrypt(akey, key, ref key);

            return(0);
        }
Exemple #3
0
        public static uint sceDrmBBMacUpdate(Crypto.MAC_KEY mkey, byte buf, int size)
        {
            uint retv = 0;

            //int ksize;
            //int p;
            //int type;
            ////C++ TO C# CONVERTER TODO TASK: C# does not have an equivalent to pointers to value types:
            ////ORIGINAL LINE: byte *kbuf;
            //byte[] kbuf = new byte[kirk_buf.Length + 0x14];

            //if (mkey.pad_size > 16)
            //{
            //    retv = 0x80510302;
            //    goto _exit;
            //}

            //if (mkey.pad_size + size <= 16)
            //{
            //    //C++ TO C# CONVERTER TODO TASK: The memory management function 'memcpy' has no equivalent in C#:
            //    PointerUtils.Memcpy(mkey.pad + mkey.pad_size, buf, size);
            //    mkey.pad_size += size;
            //    retv = 0;
            //}
            //else
            //{


            //    //kbuf = kirk_buf + 0x14;
            //    //C++ TO C# CONVERTER TODO TASK: The memory management function 'memcpy' has no equivalent in C#:
            //    PointerUtils.Memcpy(kbuf, mkey.pad, mkey.pad_size);

            //    p = mkey.pad_size;

            //    mkey.pad_size += size;
            //    mkey.pad_size &= 0x0f;
            //    if (mkey.pad_size == 0)
            //    {
            //        mkey.pad_size = 16;
            //    }

            //    size -= mkey.pad_size;
            //    //C++ TO C# CONVERTER TODO TASK: The memory management function 'memcpy' has no equivalent in C#:
            //    PointerUtils.Memcpy(mkey.pad, buf + size, mkey.pad_size);

            //    type = (mkey.type == 2) ? 0x3A : 0x38;

            //    while (size != 0)
            //    {
            //        ksize = (size + p >= 0x0800) ? 0x0800 : size + p;
            //        //C++ TO C# CONVERTER TODO TASK: The memory management function 'memcpy' has no equivalent in C#:
            //        PointerUtils.Memcpy(kbuf, buf, ksize - p);
            //        retv = encrypt_buf(kirk_buf, ksize, mkey.key, type);

            //        if (retv != 0)
            //        {
            //            goto _exit;
            //        }

            //        size -= (ksize - p);
            //        buf += ksize - p;
            //        p = 0;
            //    }
            //}

            //_exit:
            return(retv);
        }