Hello there. I have an existing, working version of the method GSSecKey that is coded in Delphi 5. That is, it works before the idea of enctype encoding was around. I am attempting to add enctype encoding to it. The goal is to get the UT3 master server list. I get as far as asking for the master server list, but I do not get a response from GameSpy. I will post all that I am using, maybe you can spot something I need to tweak.
First, I ask for and successfully receive the basic secure key. An example response:
Code:
\basic\\secure\FKFGOD
Then I call the GSSecKey method something like this:
Code:
var ConvertedKey: string;
ConvertedKey := GSSecKey('FKFGOD', 'UebAWH', 2);
Note that the string 'UebAWH' I got from your
http://aluigi.altervista.org/papers/gslist.cfg page.
Ok now I will post all the code I use for GSSecKey, then I will comment on it.
Code:
const
AEncodeType1_data: array[0..255] of integer = (1,186,250,178,81,0,84,128,117,
22,142,142,2,8,54,165,45,5,13,22,82,7,180,34,140,233,9,214,185,38,0,4,6,5,
0,19,24,196,30,91,29,118,116,252,80,81,6,22,0,81,40,0,4,10,41,120,81,0,1,17,
82,22,6,74,32,132,1,162,30,22,71,22,50,81,154,196,3,42,115,225,45,79,24,75,
147,76,15,57,10,0,4,192,18,12,154,94,2,179,24,184,7,12,205,33,5,192,169,65,
67,4,60,82,117,236,152,128,29,8,2,29,88,132,1,78,59,106,83,122,85,86,87,30,
127,236,184,173,0,112,31,130,216,252,151,139,240,131,254,14,118,3,190,57,41,
119,48,224,43,255,183,158,1,4,248,1,14,232,83,255,148,12,178,69,158,10,199,6,
24,1,100,176,3,152,1,235,2,176,1,180,18,73,7,31,95,94,93,160,79,91,160,90,89,
88,207,82,84,208,184,52,2,252,14,66,41,184,218,0,186,177,240,18,253,35,174,182,
69,169,187,6,184,136,20,36,169,0,20,203,36,18,174,204,87,86,238,253,8,48,217,253,
139,62,10,132,70,250,119,184);
function GSSecKey(SecureKey, HandOff: String; AEncodeType: Integer): String;
var
Table: Array[0..255] Of Byte;
Key: Array of Byte;
Len: Array[0..1] Of Byte;
Temp: Array[0..3] Of Byte;
i: Integer;
Validate: String;
begin
FillChar(Temp,4,0);
for i := 0 to 255 do
Table[i] := I;
Len[0] := Length(Handoff);
Len[1] := Length(SecureKey);
for i := 0 to 255 do begin
Temp[0] := (Temp[0] + Table[i] + Ord(Handoff[i mod Len[0] + 1])) AND 255;
Temp[1] := Table[Temp[0]];
Table[Temp[0]] := Table[i];
Table[i] := Temp[1];
end;
Temp[0] := 0;
SetLength(Key, Len[1]);
for i := 0 to High(Key) do begin
Key[i] := Ord(SecureKey[i+1]);
Temp[0] := (Temp[0] + Key[i] + 1) AND 255;
Temp[1] := Table[Temp[0]];
Temp[2] := (Temp[2] + Temp[1]) AND 255;
Temp[3] := Table[Temp[2]];
Table[Temp[2]] := Temp[1];
Table[Temp[0]] := Temp[3];
Key[i] := Key[i] XOR Table[(Temp[1] + Temp[3]) AND 255];
end;
// -- Adding enctype management -- //
if AEncodeType = 1 then
begin
for i:=0 to High(Key) do
Key[i] := AEncodeType1_data[Key[i]];
end
else if AEncodeType = 2 then
begin
for i:=0 to High(Key) do
Key[i] := Key[i] xor Ord(Handoff[i mod Len[1] + 1]);
end;
// ------------------------------- //
Len[1] := Len[1] Div 3;
i := 0;
while Len[1] >= 1 do begin
Len[1] := Len[1] - 1;
Temp[1] := Key[i];
Temp[3] := Key[i + 1];
AddChar(Validate,(Temp[1] shr 2));
AddChar(validate,((Temp[1] AND 3) shl 4 OR Temp[3] shr 4));
Temp[1] := Key[i + 2];
AddChar(validate,((Temp[3] AND 15) shl 2 OR Temp[1] shr 6));
AddChar(validate,Temp[1] AND 63);
i := i + 3;
end;
Result := validate;
end;
function AddChar(var Validate: string; number: byte): string;
var
newchar: String;
begin
if (Number < 26) then
newchar := Chr(Number + 65)
else if (Number < 52) then
newchar := Chr(Number + 71)
else if (Number < 62) then
newchar := Chr(Number - 4)
else if (Number = 62) then
newchar := '+'
else if (Number = 63) then
newchar := '/';
Validate := validate + newchar;
end;
Ok so I have recently added the section that starts with the comment
Code:
// -- Adding enctype management -- //
I think I have translated this correctly, but this could be the issue.
Anyways, once I get my result back from GSSecKey into the variable ConvertedKey, I then attempt to ask for the master server list. For this part I have seen so many combinations on the net for what string to use; I have tried many varieties but no luck. So for example I will put the string together like this:
Code:
var s: string;
s := 'basic\gamename\ut3pc\enctype\2\validate\' + ConvertedKey + '\final\\list\\gamename\ut3pc\final\';
So this string is where the error could be as well.
I hope you find the time to take a peek at this, and if you need any more info please let me know.
Thankyou.