PacketDocu: 0x0065 - Send Crypt (login server)

Discussions on various DOL development features

Moderator: Support Team

PacketDocu: 0x0065 - Send Crypt (login server)

Postby duff » Sat Jul 19, 2003 4:23 pm

packet send by login server to client to send crypte key on connection of client
Code: Select all
Packet Structure:
//packet hdr
0x02 bytes = UNKNOWN
0x02 bytes = Packet Size (always 22)
0x02 bytes = code of packet (0x0065)
0x01 bytes = checksum (65)
0x01 bytes = sequence (0x6e)
//packet data
0x01 bytes = 0x01
0x01 bytes = 0x00
0x0D bytes = crypte key
0x03 bytes = 0x000000
Vive DOL vive DAOC
Image
membre de MatrixTC :mappeur,codeur :) plus d info:http://www.halflifedesign.net
User avatar
duff
Inactive Staff Member
 
Posts: 1682
Joined: Fri Jun 20, 2003 5:27 pm

Postby wad » Tue Jan 27, 2004 12:00 pm

In version 1.66+ this packet have a new format.
Code: Select all
Packet header...
...
End of packet header.
Packet body (all words is in network bytes order):
offset 0: word - crypt version (1 - new);
offset 2: word - unknown (not important);
offset 4: word - size of crypt block;
Begin of crypt block:
offset 6: word - size of crypt key;
offset 8: X bytes - RSA public key in special exported format from
[url]http://math.libtomcrypt.org[/url]
Functions for key creation:
rsa_make_key( &prng, find_prng( "sprng"), 2048 / 8, 65537, &key);
rsa_export( outbuf, &outlen, PK_PUBLIC, &key);

NOTE: Please use only TomCrypt version 9.1, exported key have version of this lib inside.
User avatar
wad
DOL Novice
 
Posts: 56
Joined: Sat Jun 21, 2003 10:28 am
Website: http://wad.times.lv

Postby duff » Tue Jan 27, 2004 12:35 pm

hmmm
hi wad but for moment we can just make a quick hack and put it later because do not think it s really important
Vive DOL vive DAOC
Image
membre de MatrixTC :mappeur,codeur :) plus d info:http://www.halflifedesign.net
User avatar
duff
Inactive Staff Member
 
Posts: 1682
Joined: Fri Jun 20, 2003 5:27 pm

Postby wad » Tue Jan 27, 2004 12:40 pm

i don't care, i just dig and share information :cool:
User avatar
wad
DOL Novice
 
Posts: 56
Joined: Sat Jun 21, 2003 10:28 am
Website: http://wad.times.lv

Postby duff » Sun Feb 01, 2004 9:55 pm

lib is for c and we are in c#but thanks for that
Vive DOL vive DAOC
Image
membre de MatrixTC :mappeur,codeur :) plus d info:http://www.halflifedesign.net
User avatar
duff
Inactive Staff Member
 
Posts: 1682
Joined: Fri Jun 20, 2003 5:27 pm

Postby wad » Mon Feb 02, 2004 11:27 am

No way to make tomcryptlib.dll and use it in the DOL?
User avatar
wad
DOL Novice
 
Posts: 56
Joined: Sat Jun 21, 2003 10:28 am
Website: http://wad.times.lv

Postby duff » Mon Feb 02, 2004 11:52 am

yes we can but .net ever done a great part of RSA so no need of that
Vive DOL vive DAOC
Image
membre de MatrixTC :mappeur,codeur :) plus d info:http://www.halflifedesign.net
User avatar
duff
Inactive Staff Member
 
Posts: 1682
Joined: Fri Jun 20, 2003 5:27 pm

Postby wad » Mon Feb 02, 2004 12:23 pm

and this 'great part of rsa' in the .net have compatibly with tomcrypt? :)
User avatar
wad
DOL Novice
 
Posts: 56
Joined: Sat Jun 21, 2003 10:28 am
Website: http://wad.times.lv

Postby duff » Mon Feb 02, 2004 1:31 pm

for the special exported format
i try to use the
return keyexchangeformatter.CreateKeyExchange(rgbldata);
function of .net framework
but you put special so i think rgbldata are fixed so what is it?
Vive DOL vive DAOC
Image
membre de MatrixTC :mappeur,codeur :) plus d info:http://www.halflifedesign.net
User avatar
duff
Inactive Staff Member
 
Posts: 1682
Joined: Fri Jun 20, 2003 5:27 pm

Postby wad » Mon Feb 02, 2004 1:54 pm

i think - microsoft stuff is not compatible with anything :)
You must use only the tomcrypt library, and only the version 9.1.
Not MS Crypt, not OpenSSL or SSLEay - only TomCrypt. sorry.
User avatar
wad
DOL Novice
 
Posts: 56
Joined: Sat Jun 21, 2003 10:28 am
Website: http://wad.times.lv

Postby Technoboy » Mon Feb 02, 2004 3:14 pm

Format of the public key

4 bytes - signature from TomCrypt
Then
BIGNUM - Public key modulus
BIGNUM - Public key Exp

With
BIGNUM:
4 bytes - Length
* bytes - Number

As an add-on, everything uses the PKCS#1 padding.
Technoboy
CoAD
Technoboy
DOL Apprentice
 
Posts: 46
Joined: Sat Jan 24, 2004 11:54 am
ICQ: 2931484
Website: http://www.coadserver.com

Postby wad » Mon Feb 02, 2004 3:26 pm

and how you will convert this from CreateKeyExchange(), Technoboy?
User avatar
wad
DOL Novice
 
Posts: 56
Joined: Sat Jun 21, 2003 10:28 am
Website: http://wad.times.lv

Postby Technoboy » Mon Feb 02, 2004 3:54 pm

Ok, additions, and answers:

The header is basically first byte as version. TomCrypt only look at it being <= 0x91 so put whatever you want with it.

To get the public key from the MS api, just use the ExportParameter method on your crypto provider, and generate the key by using the mod and exp

This public key goes to the client side, the client uses it to encrypt a random number that is generated by using the pseudo random generator from the plain C++ CryptoAPI (AcquireContext and friends). This is absolutely equivalent to do the CreateKeyExchange, as from what i understand what is sent by the server is its public key and only that.

Once the key exchange hash is generated on the client it sends it back in 0x14B

If you look at the code for a CreateKeyExchange that you created from a provider created itself from the given public key, the call will resolve to provider.Encrypt() and return you with the encryption of the data with the public key.
Technoboy
CoAD
Technoboy
DOL Apprentice
 
Posts: 46
Joined: Sat Jan 24, 2004 11:54 am
ICQ: 2931484
Website: http://www.coadserver.com

Postby duff » Wed Apr 14, 2004 3:06 pm

can i have some log about crypt key and logger on login server to see order of packet send and see the exacte packet headler because not sure for version example if it s 0x0091 (it s a ushort) do i put write(00) and after write(91) or just add with low endian write(91) and afer(00)
same for modulus lenght and exponent lenght (it s int but do not know if put the begin or the end before)
to sum up :like a stack or not?
Vive DOL vive DAOC
Image
membre de MatrixTC :mappeur,codeur :) plus d info:http://www.halflifedesign.net
User avatar
duff
Inactive Staff Member
 
Posts: 1682
Joined: Fri Jun 20, 2003 5:27 pm

Postby Smallhorse » Wed Apr 14, 2004 6:36 pm

Ah duff, for login server you need to make it different :) You get this packet from the gameclient -> Server and inside the server you need to extract the "public key" from the message (its in tomcrypt format, just like in my example) ... but you need to import the public key to the RSAManaged class, not export it... so it ís easier :) and then you need to do Crypt on outgoing packet
SmallHorse
Project Ex-Administrator with too little time to be of much use currently :)
Smallhorse
Inactive Staff Member
 
Posts: 2919
Joined: Sun Jun 22, 2003 5:54 pm
ICQ: 11718314


Return to “%s” DOL Development Discussion

Who is online

Users browsing this forum: No registered users and 1 guest