Forum Index  >>  RetroCopy General  >>  

N64 PIF/CIC-NUS-6105 Algorithm Finally Reversed... so.. uhm

      

   Page 1 of 1   

297 days ago - Wednesday, July 27, 2011
Type: Member
Posts: 117
Joined: 11/5/2009
Copy'd from emutalk.net.. may come in handy..
Although this is going beyond my knowledge ;)
----
"Recently, LaC challanged us to find a small and concise algorithm that would
emulate the behaviour of PIF/CIC-NUS-6105 challenge/response (C/R) protection
scheme. This would allow the replacement of 'pif2.dat' file of Project 64, that
contains all the 268 C/R pairs used by 'Jet Force Gemini' and 'Banjo Tooie',
with a concise algorithm. After many hours of careful, exhaustive and detailed
analysis of 'pif2.dat' C/R pairs, I'm pleased to announce that I've
finally found a very concise algorithmic representation of the C/R process,
which emulates the desired behaviour of the PIF/CIC-NUS-6105. This is the
actual C source of the algorithm:



Code:
void n64_cic_nus_6105(char chl[], char rsp[], int len)
{
static char lut0[0x10] = {
0x4, 0x7, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1,
0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9
};
static char lut1[0x10] = {
0x4, 0x1, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1,
0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9
};
char key, *lut;
int i, sgn, mag, mod;

for (key = 0xB, lut = lut0, i = 0; i < len; i++) {
rsp[i] = (key + 5 * chl[i]) & 0xF;
key = lut[rsp[i]];
sgn = (rsp[i] >> 3) & 0x1;
mag = ((sgn == 1) ? ~rsp[i] : rsp[i]) & 0x7;
mod = (mag % 3 == 1) ? sgn : 1 - sgn;
if (lut == lut1 && (rsp[i] == 0x1 || rsp[i] == 0x9))
mod = 1;
if (lut == lut1 && (rsp[i] == 0xB || rsp[i] == 0xE))
mod = 0;
lut = (mod == 1) ? lut1 : lut0;
}
} The complete software package is available online at: http://goo.gl/wNRPY

You should read the 'README' file as it contains a complete explanation of the
whole package, the purpose of each file, and the explanation of the four typos
that where found in the 'pif2.dat' file during the research process. These
'pif2.dat' challenge/response pairs were the only resource I've used during
this project. There was no kind of physical access to N64 hardware.

I truly hope this contribution helps the N64 community keeping the magical
spirit of this console alive for a long time."
----
I hope RetroRalph can use this.. :)
Edited 1 times. Last edit by DiDaDo
296 days ago - Wednesday, July 27, 2011
Type: Administrator
Posts: 1336
Joined: 7/19/2009
Nice, doesn't look too complicated but it would have still taken a while to reverse it! Good work, and thanks Didado!
296 days ago - Wednesday, July 27, 2011
Type: Member
Posts: 117
Joined: 11/5/2009
No problemo ;)
5 hours ago - Friday, May 18, 2012
Type: Member
Posts: 135
Joined: 5/8/2011
This may be useful too:

http://www.emutalk.net/threads/53938-N64-tech-documentation

   Page 1 of 1   



RetroCopy: Making emulation easy and fun.
  |   RetroCopy © 2011