it is ok to export to eu RSA.java package JTrek.rsa; import java.math.BigInteger; public class RSA { public RSA() { } private static String swapEndian(String s) { char c[] = s.toCharArray(); StringBuffer buffer = new StringBuffer(c.length); for(int i = c.length; (i -= 2) >= 0;) { buffer.append(c[i]); buffer.append(c[i + 1]); } return buffer.toString(); } private static byte[] swapEndian(byte in[]) { byte out[] = new byte[in.length]; for(int i = 0; i < in.length; i++) out[i] = in[in.length - i - 1]; return out; } private static byte[] bigIntegerToByteArray(BigInteger value) { byte bytes[] = value.toByteArray(); if(bytes.length > 32) { byte temp[] = new byte[32]; System.arraycopy(bytes, bytes.length - 32, temp, 0, 32); bytes = temp; } else if(bytes.length < 32) { byte temp[] = new byte[32]; System.arraycopy(bytes, 0, temp, 32 - bytes.length, bytes.length); bytes = temp; } return bytes; } public static byte[] generateRSAResponse(byte data[]) { byte buffer[] = new byte[96]; byte temp[] = swapEndian(bigIntegerToByteArray(GLOBAL_KEY)); System.arraycopy(temp, 0, buffer, 0, 32); temp = swapEndian(bigIntegerToByteArray(PUBLIC_KEY)); System.arraycopy(temp, 0, buffer, 32, 32); data = swapEndian(data); BigInteger value = new BigInteger(1, data); value = value.modPow(PRIVATE_KEY, GLOBAL_KEY); temp = swapEndian(bigIntegerToByteArray(value)); System.arraycopy(temp, 0, buffer, 64, 32); System.out.println("RSA->generateRSAResponse.buffer="+buffer); return buffer; } public static final String VERSION = "RSA v2.0 CLIENT"; public static final int KEY_SIZE = 32; private static BigInteger GLOBAL_KEY = new BigInteger(swapEndian("ef5dee63d00d4b69a3bd8a09ae2bf570870200f27853a4a4e9c00c063c6077bb"), 16); private static BigInteger PUBLIC_KEY = new BigInteger(swapEndian("31cdad80215d377788ee3ccd2b4f3f72a33e67c9c7c09072403493ea846c4b97"), 16); private static BigInteger PRIVATE_KEY = new BigInteger(swapEndian("91d82c09f98c0b5b024516ab1a4eb08b8d000000000000000000000000000000"), 16); } > ----- Original Message ----- > From: Narcis <narcis at luky.nl> > To: netrek-dev at us.netrek.org > Subject: [netrek-dev] RSA.java > Date: Thu, 21 Sep 2006 23:11:10 +0200 > > > Hi > > i am working a bit with the JTrek Client, but the RSA code is very > optimized :-) does anyone have the original RSA.java code ? is should > be okay to export it to europe by now. > > regards > > Chris > > _______________________________________________ > netrek-dev mailing list > netrek-dev at us.netrek.org > http://mailman.us.netrek.org/mailman/listinfo/netrek-dev > -- ___________________________________________________ Play 100s of games for FREE! http://games.mail.com