Re: Encrytion paquet 4
Il manque l'AES Key dans ton code qui a été ajoutée récemment.
Elle doit être générée donc au moment d'envoyer le paquet 4, tu dois la stoquer, elle te permettera de décrypter le tiquet par la suite lors du switch vers le serveur de jeu.
Elle est générée de cette manière:
com/ankamagames/dofus/logic/connection/managers/AuthentificationManager.as
private static const AES_KEY_LENGTH:uint = 32;
private var _AESKey:ByteArray;
public function initAESKey() : void
{
this._AESKey = this.generateRandomAESKey();
}
private function generateRandomAESKey() : ByteArray
{
var _loc1_:ByteArray = new ByteArray();
var _loc2_:* = 0;
while(_loc2_ < AES_KEY_LENGTH)
{
_loc1_[_loc2_] = Math.floor(Math.random() * 256);
_loc2_++;
}
return _loc1_;
}
Pour ce qui est de l'écriture, voici la fonction cipherRsa:
L'AES Key s'écrit après le salt.
com/ankamagames/dofus/logic/connection/managers/AuthentificationManager.as
private function cipherRsa(param1:String, param2:String, param3:TrustCertificate) : Vector.<int>
{
var baOut:ByteArray = null;
var debugOutput:ByteArray = null;
var n:int = 0;
var login:String = param1;
var pwd:String = param2;
var certificate:TrustCertificate = param3;
var baIn:ByteArray = new ByteArray();
baIn.writeUTFBytes(this._salt);
baIn.writeBytes(this._AESKey);
if(certificate)
{
baIn.writeUnsignedInt(certificate.id);
baIn.writeUTFBytes(certificate.hash);
}
baIn.writeByte(login.length);
baIn.writeUTFBytes(login);
baIn.writeUTFBytes(pwd);
try
{
if(File.applicationDirectory.resolvePath("debug-login.txt") || File.applicationDirectory.resolvePath("debuglogin.txt"))
{
_log.debug("login with certificate");
debugOutput = new ByteArray();
baIn.position = 0;
debugOutput.position = 0;
debugOutput = RSA.publicEncrypt((new PUBLIC_KEY_V2() as ByteArray).readUTFBytes((new PUBLIC_KEY_V2() as ByteArray).length),baIn);
_log.debug("Login info (RSA Encrypted, " + debugOutput.length + " bytes) : " + Base64.encodeByteArray(debugOutput));
}
}
catch(e:Error)
{
_log.error("Erreur lors du log des informations de login " + e.getStackTrace());
}
baOut = RSA.publicEncrypt(this._publicKey,baIn);
var ret:Vector.<int> = new Vector.<int>();
baOut.position = 0;
var i:int = 0;
while(baOut.bytesAvailable != 0)
{
n = baOut.readByte();
ret = n;
i++;
}
return ret;
}
EDIT: J'avais oublié l'AES_KEY_LENGTH.