Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Sorc.Polgara on November 02, 2005, 10:04 PM

Title: [SRP] Converting Java code to C++
Post by: Sorc.Polgara on November 02, 2005, 10:04 PM
Ok, so I was looking at iago's SRP.java (http://www.javaop.com/javaop2/src/BNetLogin/src/password/SRP.java) and saw the use of several classes that are come with Java.

java.util.Random;
java.math.BigInteger;
java.security.MessageDigest;

Now, converting code between languages is something totally new to me.  I've never really done something like this before.  I thought it would be fairly easy to convert Java code to C++, however the use of these classes that come with Java really make the job harder than I thought.  I must now somehow find a way to do what these classes are doing in iago's code using C++.

What I need to know is, does C++ have libraries that do what these Java classes do so that converting this code will be not as hard as I think?

The MessageDigest class looks like it will prove to be a huge problem.
Title: Re: [SRP] Converting Java code to C++
Post by: Warrior on November 02, 2005, 10:08 PM
You need to find your own BigInteger library.
Title: Re: [SRP] Converting Java code to C++
Post by: K on November 02, 2005, 10:45 PM
Check out the gmp library:
http://www.swox.com/gmp/
Title: Re: [SRP] Converting Java code to C++
Post by: iago on November 02, 2005, 10:53 PM
GMP library is GNU, though, so if you use it then your code is automatically also GNU. 

Random is just a normal random library.  Just use rand()/srand() or whatever your libraries provide. 

BigInteger is an implementation of arbitrary precision integers.  In other words, integers that can expand to any length.  There are several implementations out there, I can't say what's better or worse.

The MessageDigest I use is just for a simple implementation of SHA1.  Find any SHA1 library or class, and you're set. 

Title: Re: [SRP] Converting Java code to C++
Post by: MyndFyre on November 02, 2005, 10:58 PM
Quote from: iago on November 02, 2005, 10:53 PM
GMP library is GNU, though, so if you use it then your code is automatically also GNU. 
Well I was about to suggest thumbing through BNCSUtil's source, but of course I believe that's GPL'd too.  Actually, it's LGPL'd.  *shrug* http://bncsutil.ionws.com/
Title: Re: [SRP] Converting Java code to C++
Post by: Kp on November 02, 2005, 11:22 PM
Consider using OpenSSL (http://www.openssl.org/) if you require a non-GPL/non-LGPL library.  In order to support SSL transactions, OpenSSL (http://www.openssl.org/) requires a variety of message digest algorithms, as well as support for very large numbers.  You can get what you need from libcrypto.a, and leave the SSL stuff alone.