1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Signed-off-by: Rogiel <rogiel@rogiel.com>

This commit is contained in:
2011-05-18 19:59:27 -03:00
parent 4c27add4ef
commit 9bb83652e4
242 changed files with 7180 additions and 4199 deletions

View File

@@ -34,10 +34,10 @@ import com.l2jserver.game.net.Lineage2PipelineFactory;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.blowfish.BlowfishKeygenService;
import com.l2jserver.service.configuration.ConfigurationService;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.service.logging.LoggingService;
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
import com.l2jserver.util.factory.CollectionFactory;
/**

View File

@@ -0,0 +1,23 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.network.keygen;
import com.l2jserver.service.Service;
public interface BlowfishKeygenService extends Service {
byte[] generate();
}

View File

@@ -0,0 +1,58 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.network.keygen;
import java.util.Random;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
public class PseudoRandomBlowfishKeygenService extends AbstractService
implements BlowfishKeygenService {
private Random random;
@Override
protected void doStart() throws ServiceStartException {
random = new Random();
}
@Override
public byte[] generate() {
final byte[] key = new byte[16];
// randomize the 8 first bytes
for (int i = 0; i < key.length; i++) {
key[i] = (byte) random.nextInt(255);
}
// the last 8 bytes are static
key[8] = (byte) 0xc8;
key[9] = (byte) 0x27;
key[10] = (byte) 0x93;
key[11] = (byte) 0x01;
key[12] = (byte) 0xa1;
key[13] = (byte) 0x6c;
key[14] = (byte) 0x31;
key[15] = (byte) 0x97;
return key;
}
@Override
protected void doStop() throws ServiceStopException {
random = null;
}
}

View File

@@ -0,0 +1,69 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.network.keygen;
import org.apache.commons.math.random.RandomData;
import org.apache.commons.math.random.RandomDataImpl;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
/**
* This implementation of {@link BlowfishKeygenService} generates
* cryptographically safe keys but at the cost of speed. The key generation is
* much slower than on a pseudo-random generator.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class SecureBlowfishKeygenService extends AbstractService implements
BlowfishKeygenService {
/**
* The random number generator
*/
private RandomData random;
@Override
protected void doStart() throws ServiceStartException {
random = new RandomDataImpl();
}
@Override
public byte[] generate() {
final byte[] key = new byte[16];
// randomize the 8 first bytes
for (int i = 0; i < key.length; i++) {
key[i] = (byte) random.nextSecureInt(0, 255);
}
// the last 8 bytes are static
key[8] = (byte) 0xc8;
key[9] = (byte) 0x27;
key[10] = (byte) 0x93;
key[11] = (byte) 0x01;
key[12] = (byte) 0xa1;
key[13] = (byte) 0x6c;
key[14] = (byte) 0x31;
key[15] = (byte) 0x97;
return key;
}
@Override
protected void doStop() throws ServiceStopException {
random = null;
}
}