import LoginClientPacket from "./LoginClientPacket" ; export default class Init extends LoginClientPacket { PublicKey ! : Uint8Array ; BlowfishKey ! : Uint8Array ; SessionId ! : number ; ProtocolRevision ! : number ; readImpl ( ) { const _id = this . readC ( ) ; this . SessionId = this . readD ( ) ; this . ProtocolRevision = this . readD ( ) ; this . logger . debug ( "ProtocolRevision" , this . ProtocolRevision ) ; this . PublicKey = this . unscrambleModulus ( this . readB ( 128 ) ) ; const _unkn1 = this . readD ( ) ; const _unkn2 = this . readD ( ) ; const _unkn3 = this . readD ( ) ; const _unkn4 = this . readD ( ) ; this . BlowfishKey = this . readB ( 16 ) ; return true ; } private unscrambleModulus ( mods ) { for ( let i = 0 ; i < 0x40 ; i ++ ) { mods [ 0x40 + i ] = mods [ 0x40 + i ] ^ mods [ i ] ; } for ( let i = 0 ; i < 4 ; i ++ ) { mods [ 0x0d + i ] = mods [ 0x0d + i ] ^ mods [ 0x34 + i ] ; } for ( let i = 0 ; i < 0x40 ; i ++ ) { mods [ i ] = mods [ i ] ^ mods [ 0x40 + i ] ; } for ( let i = 0 ; i < 4 ; i ++ ) { const temp = mods [ 0x00 + i ] ; mods [ 0x00 + i ] = mods [ 0x4d + i ] ; mods [ 0x4d + i ] = temp ; } return mods ; } }