private User(TL.Object user) { photo = null; // photo_small = null; if (!user.name.equals("userFull")) { user = TL.newObject( "userFull", user, TL.newObject( "contacts.link", TL.newObject("contacts.myLinkEmpty"), TL.newObject("contacts.foreignLinkUnknown"), user), TL.newObject("photoEmpty", 0L), TL.newObject("peerNotifySettingsEmpty"), false, "", ""); update(user); synchronized (fullInfoQuery) { fullInfoQuery.add(this); } } else update(user); }
private void send_client_DH_inner_data(long retry_id) { byte[] b_data = new byte[256]; Common.random.nextBytes(b_data); BigInteger b = new BigInteger(1, b_data); BigInteger g_b = g.modPow(b, dh_prime); Common.logError( "g_b length: " + g_b.toByteArray().length + " -> " + Common.toBytes(g_b).length); BigInteger akey = g_a.modPow(b, dh_prime); Common.logError("auth_key: " + akey.toString()); setAuthKey(Common.toBytes(akey)); // gen data (client_DH_inner_data) TL.Object data_obj = TL.newObject("client_DH_inner_data", cl_nonce, sv_nonce, retry_id, g_b); byte[] data = data_obj.serialize(); byte[] hash = Common.getSHA1(data); byte[] data_with_hash = new byte[(hash.length + data.length + 15) / 16 * 16]; System.arraycopy(hash, 0, data_with_hash, 0, hash.length); System.arraycopy(data, 0, data_with_hash, hash.length, data.length); // send set_client_DH_params TL.Object req_obj = TL.newObject("set_client_DH_params", cl_nonce, sv_nonce, aes.IGE(data_with_hash, true)); send(req_obj, false, false); }
/* public byte[] GEN_nonce_hash(int id) { byte[] nonce_data = Common.ASUM(Common.ASUM(new_nonce, new byte[]{(byte) id}), auth_key_aux_hash); return Common.ASUB(Common.getSHA1(nonce_data), 4, 16); } */ private void send_accept() { if (msg_ack.size() == 0) return; /* Common.logInfo("send accept:"); for (int i = 0; i < msg_ack.size(); i++) Common.logInfo(" - " + getMessageTime(msg_ack.get(i)) + " " + msg_ack.get(i)); */ TL.Object msgs_ack = TL.newObject("msgs_ack", TL.newVector(msg_ack.toArray())); send(msgs_ack, true, false); msg_ack.clear(); }
public static void init() { mtp.clear(); dcStates.clear(); // dcStates.add(TL.newObject("joim.dcState", 0, "95.142.192.65", 80, new byte[0], false, // Common.random.nextLong(), 0L, 0)); // dcStates.add(TL.newObject("joim.dcState", 1, "173.240.5.253", 443, new byte[0], false, // Common.random.nextLong(), 0L, 0)); dcStates.add( TL.newObject( "joim.dcState", 0, "173.240.5.1", 443, new byte[0], false, GEN_session_id(), 0L, 0)); dc_date = dc_this = upd_date = upd_pts = upd_seq = 0; }
private void TL_Pong(TL.Object obj) { if (obj.name.equals("ping")) send(TL.newObject("pong", 0L, obj.getLong("ping_id")), true, false); if (obj.name.equals("pong")) { /* if (!ready) { send_queue(); ready = true; } */ } }
private void TL_ResPQ(TL.Object obj) { sv_nonce = obj.getBytes("server_nonce"); BigInteger pq = new BigInteger(1, obj.getBytes("pq")); TL.Vector v_fp = obj.getVector("server_public_key_fingerprints"); fp = v_fp.getLong(0); Common.logError("pq: " + pq.toString()); // prime factorization for pq BigInteger q = Common.rho(pq); BigInteger p = pq.divide(q); if (p.compareTo(q) > 0) { BigInteger t = p; p = q; q = t; } SecureRandom rnd = new SecureRandom(); new_nonce = new byte[32]; rnd.nextBytes(new_nonce); // generate encrypted_data TL.Object data_obj = TL.newObject("p_q_inner_data", pq, p, q, cl_nonce, sv_nonce, new_nonce); byte[] data = data_obj.serialize(); byte[] hash = Common.getSHA1(data); byte[] data_with_hash = new byte[255]; System.arraycopy(hash, 0, data_with_hash, 0, hash.length); System.arraycopy(data, 0, data_with_hash, hash.length, data.length); GEN_random_bytes(data_with_hash, data.length + hash.length, 255); byte[] encrypted_data = Common.RSA(RSA_MODULUS, RSA_EXPONENT, data_with_hash); // req_DH_params TL.Object req_obj = TL.newObject("req_DH_params", cl_nonce, sv_nonce, p, q, fp, encrypted_data); send(req_obj, false, false); }
private void TL_Config(TL.Object obj) { dc_date = obj.getInt("date"); MTProto.dc_this = obj.getInt("this_dc"); dcState.set("id", dc_this); updateDcStates(); TL.Vector dc_options = obj.getVector("dc_options"); ArrayList<TL.Object> new_dcStates = new ArrayList<TL.Object>(); for (int i = 0; i < dc_options.count; i++) { TL.Object dcObj = dc_options.getObject(i); int id = dcObj.getInt("id"); TL.Object state = TL.newObject( "joim.dcState", id, dcObj.getString("ip_address"), dcObj.getInt("port"), new byte[0], false, GEN_session_id(), 0L, 0); for (int j = 0; j < MTProto.dcStates.size(); j++) { TL.Object item = MTProto.dcStates.get(j); if (id == item.getInt("id") && state.getString("ip").equals(item.getString("ip"))) { state.set("auth_key", item.getBytes("auth_key")); state.set("bind", item.getBool("bind")); state.set("session", item.getLong("session")); state.set("server_salt", item.getLong("server_salt")); state.set("seqno", item.getInt("seqno")); if (state.getInt("port") == item.getInt("port")) dcState = state; break; } } new_dcStates.add(state); } dcStates = new_dcStates; send_queue(); cb.onReady(); }
public static void init() { users.clear(); fullInfoQuery.clear(); self = addUser(TL.newObject("userEmpty", 0)); contacts_hash = ""; // update typing updater = new Updater( 3 * 1000, new Runnable() { @Override public void run() { int time = Common.getUnixTime(); for (int i = 0; i < User.users.size(); i++) { User user = User.users.get(User.users.keyAt(i)); if (user.typing && user.typing_time < time) user.setTyping(user.typing_chat_id, false); } } }); updater.startUpdates(); }
private void send_ping() { send(TL.newObject("ping", Common.random.nextLong()), true, false); }
public void auth() { Common.logError("auth"); TL.Object req_pq = TL.newObject("req_pq", cl_nonce = GEN_random_bytes(16)); send(req_pq, false, false); }
// API public void api(TL.OnResultRPC result, Object param, String method, Object... params) { send(TL.newObject(method, params), true, true, result, param); }
public TL.Object getInputPeer() { if (this == User.self) return TL.newObject("inputPeerSelf"); if (!contact) return TL.newObject("inputPeerForeign", id, access_hash); return TL.newObject("inputPeerContact", id); }