Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(first) { // first packet, server sends to proxy
- Cipher cii = Cipher.getInstance("Blowfish/CFB64/NoPadding");
- Key key = new SecretKeySpec(STATIC_KEY.getBytes("ASCII"), "Blowfish");
- cii.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(" ".getBytes()));
- ByteBuffer bb = ByteBuffer.wrap(cii.doFinal(packet.array())).order(ByteOrder.LITTLE_ENDIAN);
- int len = bb.getInt(11);
- int junkLen = bb.getInt(15);
- int index = 19 + junkLen;
- byte[] serverIV = new byte[bb.getInt(index)];
- index+=4;
- System.arraycopy(bb.array(), index, serverIV, 0, serverIV.length);
- index+=serverIV.length;
- byte[] clientIV = new byte[bb.getInt(index)];
- index+=4;
- System.arraycopy(bb.array(), index, clientIV, 0, clientIV.length);
- index+=clientIV.length;
- int strLen = bb.getInt(index);
- index+=4;
- String p = new String(bb.array(), index, strLen);
- index+=strLen;
- strLen = bb.getInt(index);
- index+=4;
- String g = new String(bb.array(), index, strLen);
- index+=strLen;
- strLen = bb.getInt(index);
- index+=4;
- String pubKey = new String(bb.array(), index, strLen);
- System.out.println("Client IV Len: " + clientIV.length);
- System.out.println("Server IV Len: " + serverIV.length);
- System.out.println("Key Len: " + pubKey.length());
- // key exchange shit here right
- cii.init(Cipher.ENCRYPT_MODE, key);
- return ByteBuffer.wrap(cii.doFinal(bb.array())); // encrypt it and send it back.
Add Comment
Please, Sign In to add comment