Examples of NewCrypt


Examples of com.l2jfrozen.crypt.NewCrypt

  {
    /*if (_blowfish == null)
    {*/
    BlowFishKey bfk = new BlowFishKey(data, _privateKey);
    _blowfishKey = bfk.getKey();
    _blowfish = new NewCrypt(_blowfishKey);

    if(Config.DEBUG)
    {
      _log.info("New BlowFish key received, Blowfih Engine initialized:");
    }
View Full Code Here

Examples of com.l2jfrozen.crypt.NewCrypt

    }

    KeyPair pair = GameServerTable.getInstance().getKeyPair();
    _privateKey = (RSAPrivateKey) pair.getPrivate();
    _publicKey = (RSAPublicKey) pair.getPublic();
    _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
  }
View Full Code Here

Examples of com.l2jfrozen.crypt.NewCrypt

          _out = new BufferedOutputStream(_loginSocket.getOutputStream());
                 
       
        //init Blowfish
        _blowfishKey = generateHex(40);
        _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
        while(!_interrupted)
        {
          lengthLo = _in.read();
          lengthHi = _in.read();
          length = lengthHi * 256 + lengthLo;

          if(lengthHi < 0)
          {
            _log.finer("LoginServerThread: Login terminated the connection.");
            break;
          }

          byte[] incoming = new byte[length];
          incoming[0] = (byte) lengthLo;
          incoming[1] = (byte) lengthHi;

          int receivedBytes = 0;
          int newBytes = 0;
          while(newBytes != -1 && receivedBytes < length - 2)
          {
            newBytes = _in.read(incoming, 2, length - 2);
            receivedBytes = receivedBytes + newBytes;
          }

          if(receivedBytes != length - 2)
          {
            _log.warning("Incomplete Packet is sent to the server, closing connection.(LS)");
            break;
          }

          byte[] decrypt = new byte[length - 2];
          System.arraycopy(incoming, 2, decrypt, 0, decrypt.length);
          // decrypt if we have a key
          decrypt = _blowfish.decrypt(decrypt);
          checksumOk = NewCrypt.verifyChecksum(decrypt);

          if(!checksumOk)
          {
            _log.warning("Incorrect packet checksum, ignoring packet (LS)");
            break;
          }

          if(Config.DEBUG)
          {
            _log.warning("[C]\n" + Util.printData(decrypt));
          }

          int packetType = decrypt[0] & 0xff;
          switch(packetType)
          {
            case 00:
              InitLS init = new InitLS(decrypt);
              if(Config.DEBUG)
              {
                _log.info("Init received");
              }
              if(init.getRevision() != REVISION)
              {
                //TODO: revision mismatch
                _log.warning("/!\\ Revision mismatch between LS and GS /!\\");
                break;
              }
              try
              {
                KeyFactory kfac = KeyFactory.getInstance("RSA");
                BigInteger modulus = new BigInteger(init.getRSAKey());
                RSAPublicKeySpec kspec1 = new RSAPublicKeySpec(modulus, RSAKeyGenParameterSpec.F4);
                _publicKey = (RSAPublicKey) kfac.generatePublic(kspec1);
                if(Config.DEBUG)
                {
                  _log.info("RSA key set up");
                }
              }

              catch(GeneralSecurityException e)
              {
                if(Config.ENABLE_ALL_EXCEPTIONS)
                  e.printStackTrace();
               
                _log.warning("Troubles while init the public key send by login");
                break;
              }
              //send the blowfish key through the rsa encryption
              BlowFishKey bfk = new BlowFishKey(_blowfishKey, _publicKey);
              sendPacket(bfk);
              if(Config.DEBUG)
              {
                _log.info("Sent new blowfish key");
              }
              //now, only accept paket with the new encryption
              _blowfish = new NewCrypt(_blowfishKey);
              if(Config.DEBUG)
              {
                _log.info("Changed blowfish key");
              }
              AuthRequest ar = new AuthRequest(_requestID, _acceptAlternate, _hexID, _gameExternalHost, _gameInternalHost, _gamePort, _reserveHost, _maxPlayer);
View Full Code Here

Examples of l2p.loginserver.crypt.NewCrypt

    }
  }

  public void initBlowfish(byte[] key)
  {
    crypt = key == null ? ConnectionCryptDummy.instance : new NewCrypt(key);
    log.info("Init connection crypt for gameserver " + getConnectionIpAddress() + ": " + crypt.getClass().getSimpleName());
  }
View Full Code Here

Examples of l2p.loginserver.crypt.NewCrypt

        data[i] = (byte) Rnd.get(256);
      }
    }
    synchronized(sendPacketQueue)
    {
      crypt = data == null ? ConnectionCryptDummy.instance : new NewCrypt(data);
      sendPacketQueue.addFirst(new Auth());
      sendPacketQueue.addFirst(new BlowFishKey(data, this));
    }
    if(Config.DEBUG_GS_LS)
    {
View Full Code Here

Examples of net.sf.l2j.loginserver.crypt.NewCrypt

        _in = _loginSocket.getInputStream();
        _out = new BufferedOutputStream(_loginSocket.getOutputStream());

        //init Blowfish
        _blowfishKey = generateHex(40);
        _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
        while (true)
        {
          lengthLo = _in.read();
          lengthHi = _in.read();
          length= lengthHi*256 + lengthLo;

          if (lengthHi < 0 )
          {
            _log.finer("LoginServerThread: Login terminated the connection.");
            break;
          }

          byte[] incoming = new byte[length];
          incoming[0] = (byte) lengthLo;
          incoming[1] = (byte) lengthHi;

          int receivedBytes = 0;
          int newBytes = 0;
          while (newBytes != -1 && receivedBytes<length-2)
          {
            newBytes =  _in.read(incoming, 2, length-2);
            receivedBytes = receivedBytes + newBytes;
          }

          if (receivedBytes != length-2)
          {
            _log.warning("Incomplete Packet is sent to the server, closing connection.(LS)");
            break;
          }

          byte[] decrypt = new byte[length - 2];
          System.arraycopy(incoming, 2, decrypt, 0, decrypt.length);
          // decrypt if we have a key
          decrypt = _blowfish.decrypt(decrypt);
          checksumOk = NewCrypt.verifyChecksum(decrypt);

          if (!checksumOk)
          {
            _log.warning("Incorrect packet checksum, ignoring packet (LS)");
            break;
          }

          if (Config.DEBUG)
            _log.warning("[C]\n"+Util.printData(decrypt));

          int packetType = decrypt[0]&0xff;
          switch (packetType)
          {
          case 00:
            InitLS init = new InitLS(decrypt);
            if (Config.DEBUG) _log.info("Init received");
            if(init.getRevision() != REVISION)
            {
              //TODO: revision mismatch
              _log.warning("/!\\ Revision mismatch between LS and GS /!\\");
              break;
            }
            try
            {
              KeyFactory kfac = KeyFactory.getInstance("RSA");
              BigInteger modulus = new BigInteger(init.getRSAKey());
              RSAPublicKeySpec kspec1 = new RSAPublicKeySpec(modulus, RSAKeyGenParameterSpec.F4);
              _publicKey = (RSAPublicKey)kfac.generatePublic(kspec1);
              if (Config.DEBUG) _log.info("RSA key set up");
            }

            catch (GeneralSecurityException e)
            {
              _log.warning("Troubles while init the public key send by login");
              break;
            }
            //send the blowfish key through the rsa encryption
            BlowFishKey bfk = new BlowFishKey(_blowfishKey,_publicKey);
            sendPacket(bfk);
            if (Config.DEBUG)_log.info("Sent new blowfish key");
            //now, only accept paket with the new encryption
            _blowfish = new NewCrypt(_blowfishKey);
            if (Config.DEBUG)_log.info("Changed blowfish key");
            AuthRequest ar = new AuthRequest(_requestID, _acceptAlternate, _hexID, _gameExternalHost, _gameInternalHost, _gamePort, _reserveHost, _maxPlayer);
            sendPacket(ar);
            if (Config.DEBUG)_log.info("Sent AuthRequest to login");
            break;
View Full Code Here

Examples of net.sf.l2j.loginserver.crypt.NewCrypt

  {
    /*if (_blowfish == null)
    {*/
    BlowFishKey bfk = new BlowFishKey(data,_privateKey);
    _blowfishKey = bfk.getKey();
    _blowfish = new NewCrypt(_blowfishKey);
    if (Config.DEBUG)
    {
      _log.info("New BlowFish key received, Blowfih Engine initialized:");
    }
    /*}
 
View Full Code Here

Examples of net.sf.l2j.loginserver.crypt.NewCrypt

      e.printStackTrace();
    }
    KeyPair pair = GameServerTable.getInstance().getKeyPair();
    _privateKey = (RSAPrivateKey) pair.getPrivate();
    _publicKey = (RSAPublicKey) pair.getPublic();
    _blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
    start();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.