Skip to content

Commit d1e3af2

Browse files
authored
Add files via upload
1 parent a613b06 commit d1e3af2

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

CHOVY/CHOVY.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<DependentUpon>CHOVYCmaSelector.cs</DependentUpon>
7373
</Compile>
7474
<Compile Include="cmakeys.cs" />
75+
<Compile Include="KIRK.cs" />
7576
<Compile Include="param.cs" />
7677
<Compile Include="pbp.cs" />
7778
<Compile Include="Program.cs" />

CHOVY/Chovy.Designer.cs

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHOVY/KIRK.cs

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using System.Windows.Forms;
9+
10+
namespace CHOVY
11+
{
12+
class KIRK
13+
{
14+
public MemoryStream kirk_buf = new MemoryStream(); // 1DC0 1DD4
15+
public unsafe struct MAC_KEY
16+
{
17+
public int type;
18+
public byte[] key;
19+
public byte[] pad;
20+
//public fixed byte key[0xF];
21+
//public fixed byte pad[0xF];
22+
public int pad_size;
23+
}
24+
25+
26+
public static int sceDrmBBMacInit(MAC_KEY mkey, int type)
27+
{
28+
mkey.type = type;
29+
mkey.pad_size = 0;
30+
31+
mkey.key = new byte[0xF];
32+
mkey.pad = new byte[0xF];
33+
34+
return 0;
35+
}
36+
37+
38+
39+
40+
int sceDrmBBMacUpdate(MAC_KEY mkey, Stream buf, int size)
41+
{
42+
int retv = 0;
43+
int ksize;
44+
int p;
45+
int type;
46+
kirk_buf.SetLength(0x0814);
47+
48+
49+
if (mkey.pad_size + size <= 16)
50+
{
51+
buf.Write(mkey.pad, 0x00, mkey.pad_size);
52+
buf.Seek(mkey.pad_size / -1, SeekOrigin.Current);
53+
mkey.pad_size += size;
54+
retv = 0;
55+
}
56+
else
57+
{
58+
//kbuf = kirk_buf + 0x14;
59+
kirk_buf.Seek(0x14, SeekOrigin.Begin);
60+
61+
// copy pad data first
62+
kirk_buf.Write(mkey.pad, 0x0, mkey.pad_size);
63+
kirk_buf.Seek(mkey.pad_size / -1, SeekOrigin.Current);
64+
65+
p = mkey.pad_size;
66+
67+
mkey.pad_size += size;
68+
mkey.pad_size &= 0x0f;
69+
if (mkey.pad_size == 0)
70+
mkey.pad_size = 16;
71+
72+
size -= mkey.pad_size;
73+
// save last data to pad buf
74+
buf.Seek(size, SeekOrigin.Begin);
75+
buf.Write(mkey.pad, 0x00, mkey.pad_size);
76+
77+
type = (mkey.type == 2) ? 0x3A : 0x38;
78+
79+
while (size >= 0)
80+
{
81+
ksize = (size + p >= 0x0800) ? 0x0800 : size + p;
82+
kirk_buf.Seek(p,SeekOrigin.Current);
83+
for(int i = 0; i < (ksize - p); i++)
84+
{
85+
byte by = (byte)buf.ReadByte();
86+
kirk_buf.WriteByte(by);
87+
}
88+
retv = sub_158(kirk_buf, ksize, mkey.key, type);
89+
if (retv)
90+
goto _exit;
91+
size -= (ksize - p);
92+
buf.Seek(ksize - p,SeekOrigin.Current);
93+
p = 0;
94+
}
95+
}
96+
97+
_exit:
98+
return retv;
99+
100+
}
101+
static int sub_158(byte[] buf, int size, byte[] key, int key_type)
102+
{
103+
int i, retv;
104+
105+
for (i = 0; i < 16; i++)
106+
{
107+
buf[0x14 + i] ^= key[i];
108+
}
109+
110+
retv = kirk4(buf, size, key_type);
111+
if (retv)
112+
return retv;
113+
114+
// copy last 16 bytes to keys
115+
for (i = 0; i < 16; i++)
116+
{
117+
key[i] = buf[i + size + 4];
118+
}
119+
120+
return 0;
121+
}
122+
123+
124+
[DllImport("KIRK.dll", CallingConvention = CallingConvention.Cdecl)]
125+
public static extern int kirk_init();
126+
// [DllImport("KIRK.dll", CallingConvention = CallingConvention.Cdecl)]
127+
// public unsafe static extern int sceDrmBBMacInit(MAC_KEY* mkey, int type);
128+
[DllImport("KIRK.dll", CallingConvention = CallingConvention.Cdecl)]
129+
public unsafe static extern int sceDrmBBMacUpdate(MAC_KEY* mkey, byte[] buf, int size);
130+
[DllImport("KIRK.dll", CallingConvention = CallingConvention.Cdecl)]
131+
public unsafe static extern int bbmac_getkey(MAC_KEY* mkey, byte[] bbmac, byte[] vkey);
132+
133+
134+
}
135+
}
136+
*/

0 commit comments

Comments
 (0)