Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 00:19

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Java] Conquer blowfish cipher implementation

Discussion on [Java] Conquer blowfish cipher implementation within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2006
Posts: 457
Received Thanks: 67
[Java] Conquer blowfish cipher implementation

Since tomas has been putting so much effort into building his proxy, I'll put up my codes for blowfish cipher so that I can help ttomas and any other java developers out there.

The main class that you will need is the BlowFishCryptor. It's a easy to use wrapper that I wrote for the other 2 blowfish classes. The other 2 files are directly translated from openssl library, and i think it is done by some guru from this forum; sparkie knows who that person is; i do not think he will mind me sharing his codes ")

Before you use them, make sure you change the package title in the codes

here is a sample of how the cryptor object should be invoked.
I have had all my ciphers implementing ConquerCipher interface. It is really up to you if you want to do that; amend your codes necessarily if you not. I have included the interface in the downloads as well.
Though this is redundant, just incase you're mentally blocked from chewing your codes and others, the way to declare cipher without implementing ConquerCipher interface is:
private/public BlowFishCryptor aCipher;
Code:
private ConquerCipher DHcipher = new GameCryptographer(), ServerCipher = null, ClientCipher = null;

The key BlowFishCryptor accepts is the 64 byte array generated by KeyAgreement.getSecret();
Code:
ServerCipher = new BlowFishCryptor(dhhandler.getProxyServerKey(), dhhandler.getServerIV(), dhhandler.getClientIV());
ClientCipher = new BlowFishCryptor(dhhandler.getProxyClientKey(), dhhandler.getClientIV(), dhhandler.getServerIV());
After instantiating your ciphers, ServerCipher can encrypt and decrypt packets between proxy and server. ClientCipher can encrypt and decrypt packets between proxy and client.
shitboi is offline  
Thanks
4 Users
Old 04/13/2011, 14:08   #2
 
TomasLT's Avatar
 
elite*gold: 0
Join Date: Nov 2006
Posts: 286
Received Thanks: 38
Thank you so much. What would I do without you

Still i have some question. How to be sure that generated ProxyServer/ProxyClient sared key is correct ? bcouse Decrypted packets dont make any sense. No TO signature in the end of the packets

Code:
public void GetProxyClientKey(String CpKey) throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException, IOException{
		cpublicKey = new DHPublicKeySpec(new BigInteger(CpKey,16), p, g); //p ir g = null !!!
		KeyAgreement ka2=KeyAgreement.getInstance("DiffieHellman");
	    KeyFactory kf2 = KeyFactory.getInstance("DiffieHellman");
	    PublicKey PubKey2=kf2.generatePublic(cpublicKey);
        ka2.init(privateKey);
        ka2.doPhase(PubKey2, true);
        byte[] SharedSecret2=ka2.generateSecret();
        ClientShared = new BigInteger(SharedSecret2);
        ClientSharedarray = ClientShared.toByteArray();
	}
And here is how do i de/en
Code:
BlowFishCryptor ServerCipher = new BlowFishCryptor(de.ServerSharedarray, bc.serverIV, bc.clientIV);
						BlowFishCryptor ClientCipher = new BlowFishCryptor(de.ClientSharedarray, bc.clientIV, bc.serverIV);
ServerCipher.Decrypt(buffer2);
						Print2("from Server2 " +sizeFromServer +" : ",buffer2);
						ClientCipher.Encrypt(buffer2);
TomasLT is offline  
Old 04/25/2011, 22:23   #3
 
elite*gold: 0
Join Date: Jul 2006
Posts: 46
Received Thanks: 3
uhhm attributes/variables & methods must/should not be written with Capitals lol
taushif is offline  
Old 04/26/2011, 02:56   #4
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,198
Quote:
Originally Posted by taushif View Post
uhhm attributes/variables & methods must/should not be written with Capitals lol
Really? I always thought that was kinda old-fashioned to write variable names without capitalization. We've always been taught to write variables like
FirstName, LastName, SelectedClient, etc.
IAmHawtness is offline  
Old 04/26/2011, 03:02   #5
 
elite*gold: 0
Join Date: Jun 2006
Posts: 457
Received Thanks: 67
Quote:
Originally Posted by IAmHawtness View Post
Really? I always thought that was kinda old-fashioned to write variable names without capitalization. We've always been taught to write variables like
FirstName, LastName, SelectedClient, etc.
he must be a good student, since he is sticking to the java convention so well, hahaha
shitboi is offline  
Thanks
1 User
Old 04/26/2011, 03:06   #6
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,198
Quote:
Originally Posted by shitboi View Post
he must be a good student, since he is sticking to the java convention so well, hahaha
Hahaha, indeed
IAmHawtness is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Reworked CO2 Cipher
01/30/2011 - CO2 PServer Guides & Releases - 0 Replies
I made a new version of the CO2 cipher used by the auth server and the game server (5017 and before). I don't use any pointers in this version. The class is based on the dotNet AsymmetricAlgorithm class. If you use this class in your projects, please mention who is the autor... Thanks. // * *************************************** // * _ _ _ // * | | (_) | // * | | ___ __ _ _| | __ // * | | / _ \ / _` | | |/ / // * |...
New Conquer Server Project [Java]
02/18/2010 - CO2 Private Server - 63 Replies
Here Hybris, Project CoLeader from CoEurope team if you guys remember the old staff ;) Wishing to build a new source code for a Conquer Private Server, but in Java this time and all brand new ^^ Need to find one or two coders that knows Java very well and who can understand UML Diagrams that i'll make. I'll help coding (much) and giving infos. Need an expert in Socket connections ^^ and someone who can use a little Sniffer with some decryption and disassembling knowledge ;) Well a bit of...
[REL] Cipher encryption class (PHP)
12/27/2009 - CO2 PServer Guides & Releases - 6 Replies
Exactly as the title says, any questions will be answered and a thanks would be appreciated. #cipher.php <?php require_once 'PEAR.php'; class Crypt_Blowfish



All times are GMT +2. The time now is 00:19.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.