Ejemplo n.º 1
0
  public void setAuthKey(byte[] value) {
    if (value == null || value.length == 0) {
      auth_key = new byte[0];
      auth_key_aux_hash = auth_key_id = 0;
      return;
    }
    auth_key = value;
    dcState.set("auth_key", auth_key);

    byte[] auth_hash = Common.getSHA1(auth_key);
    auth_key_aux_hash = Common.toLong(Common.ASUB(auth_hash, 0, 8));
    auth_key_id = Common.toLong(Common.ASUB(auth_hash, 12, 8));
  }
Ejemplo n.º 2
0
  private void TL_Set_client_DH_params_answer(TL.Object obj) {
    if (obj.name.equals("dh_gen_ok")) {
      // check auth key
      /*
      if (!Arrays.equals( obj.getBytes("new_nonce_hash1"), GEN_nonce_hash(1))) {
      	Common.logError("auth_key check failed");
      	setAuthKey(null);
      	auth();
      //	transport.disconnect();
      	return;
      }
      */

      // done MTProto authorization
      server_salt =
          Common.toLong(Common.AXOR(Common.ASUB(new_nonce, 0, 8), Common.ASUB(sv_nonce, 0, 8)));

      // clean temporary data
      cl_nonce = sv_nonce = new_nonce = null;
      g = g_a = dh_prime = null;
      fp = 0;
      onAuthorized();
    }

    if (obj.name.equals("dh_gen_retry")) send_client_DH_inner_data(auth_key_aux_hash);

    if (obj.name.equals("dh_gen_fail")) transport.disconnect();
  }