Example #1
0
int decrypt(WORDSIZE* data, WORDSIZE* decryption_iv, WORDSIZE* keym, 
            WORDSIZE* extra_data, WORDSIZE* tag, 
             unsigned long data_size, unsigned long extra_data_size){
    REGISTER a, b, c, d, t;    
    unsigned long index;
    load_register(d, decryption_iv, 4);
    load_register(c, decryption_iv, 0);
    load_register(t, keym, 4);
    d ^= t;
    load_register(t, keym, 0);
    c ^= t;
            
    unsigned long block_number = data_size / 8;    
    while (block_number-- > 0){        
        load_register(a, data, (block_number * 8));
        load_register(b, data, (block_number * 8) + 4);
        inverse_permutation(a, b, c, d);
        store_register(a, data, (block_number * 8));
        store_register(b, data, (block_number * 8) + 4);}          
            
    WORDSIZE _tag[8], keyr[8];
    store_register(c, keyr, 0);
    store_register(d, keyr, 4);
    keyed_hash_function(keyr, extra_data, extra_data_size, _tag);
    
    REGISTER tag_a, tag_b, _tag_a, _tag_b, valid;
    load_register(tag_a, tag, 0); load_register(tag_b, tag, 4);
    load_register(_tag_a, _tag, 0); load_register(_tag_b, tag, 4);    
    valid[0] = 0xFFFFFFFF; valid[1] = 0xFFFFFFFF; valid[2] = 0xFFFFFFFF; valid[3] = 0xFFFFFFFF;
    valid = (_tag_a ^ tag_a ^ 0xFFFFFFFF) & valid;
    valid = (_tag_b ^ tag_b ^ 0xFFFFFFFF) & valid;    
    return valid[0] & valid[1] & valid[2] & valid[3];}                   
static void
store_ppc_registers (int tid)
{
  int i;
  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
  
  for (i = 0; i < ppc_num_gprs; i++)
    store_register (tid, tdep->ppc_gp0_regnum + i);
  if (tdep->ppc_fp0_regnum >= 0)
    for (i = 0; i < ppc_num_fprs; i++)
      store_register (tid, tdep->ppc_fp0_regnum + i);
  store_register (tid, PC_REGNUM);
  if (tdep->ppc_ps_regnum != -1)
    store_register (tid, tdep->ppc_ps_regnum);
  if (tdep->ppc_cr_regnum != -1)
    store_register (tid, tdep->ppc_cr_regnum);
  if (tdep->ppc_lr_regnum != -1)
    store_register (tid, tdep->ppc_lr_regnum);
  if (tdep->ppc_ctr_regnum != -1)
    store_register (tid, tdep->ppc_ctr_regnum);
  if (tdep->ppc_xer_regnum != -1)
    store_register (tid, tdep->ppc_xer_regnum);
  if (tdep->ppc_mq_regnum != -1)
    store_register (tid, tdep->ppc_mq_regnum);
  if (tdep->ppc_fpscr_regnum != -1)
    store_register (tid, tdep->ppc_fpscr_regnum);
  if (have_ptrace_getvrregs)
    if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
      store_altivec_registers (tid);
  if (tdep->ppc_ev0_upper_regnum >= 0)
    store_spe_register (tid, -1);
}
void
store_inferior_registers (int regnum)
{
  if (regnum == -1)
    for (regnum = 0; regnum < NUM_REGS; regnum++)
      store_register (regnum);
  else
    store_register (regnum);
}
Example #4
0
void
store_inferior_registers (int regno)
{
  if (-1 == regno)
    {
      for (regno = 0; regno < NUM_REGS; regno++)
	store_register (regno);
    }
  else
    {
      store_register (regno);
    }
}
static void
hppa_linux_store_inferior_registers (int regno)
{
  if (-1 == regno)
    {
      for (regno = 0; regno < NUM_REGS; regno++)
	store_register (regno);
    }
  else
    {
      store_register (regno);
    }
}
Example #6
0
void permutation(WORDSIZE* state){        
    REGISTER t, a, b, c, d;    
    load_register(a, state, 0); load_register(b, state, 4); 
    load_register(c, state, 8); load_register(d, state, 12);           
    
    int index;                
    WORDSIZE round_constants[4] = {1, 0, 0, 0};    
    
    for (index = 1; index < ROUNDS + 1; index++){
        add_constant(a);
        mix_slice(a, b, c, d);
        shift_sections(b, c, d);}    
        
    store_register(a, state, 0); store_register(b, state, 4);
    store_register(c, state, 8); store_register(d, state, 12);}                
static void
old_store_inferior_registers (int regno)
{
  if (regno >= 0)
    {
      store_register (regno);
    }
  else
    {
      for (regno = 0; regno < NUM_REGS; regno++)
	{
	  store_register (regno);
	}
    }
}
Example #8
0
void
hppa_linux_nat_target::store_registers (struct regcache *regcache, int regno)
{
  if (-1 == regno)
    {
      for (regno = 0;
	   regno < gdbarch_num_regs (regcache->arch ());
	   regno++)
	store_register (regcache, regno);
    }
  else
    {
      store_register (regcache, regno);
    }
}
Example #9
0
static void
arm_linux_store_inferior_registers (struct target_ops *ops,
				    struct regcache *regcache, int regno)
{
  if (-1 == regno)
    {
      store_regs (regcache);
      store_fpregs (regcache);
      if (arm_linux_has_wmmx_registers)
	store_wmmx_regs (regcache);
      if (arm_linux_vfp_register_count > 0)
	store_vfp_regs (regcache);
    }
  else
    {
      if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
        store_register (regcache, regno);
      else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM))
        store_fpregister (regcache, regno);
      else if (arm_linux_has_wmmx_registers
	       && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
	store_wmmx_regs (regcache);
      else if (arm_linux_vfp_register_count > 0
	       && regno >= ARM_D0_REGNUM
	       && regno <= ARM_D0_REGNUM + arm_linux_vfp_register_count)
	store_vfp_regs (regcache);
    }
}
Example #10
0
static void
arm_linux_store_inferior_registers (struct target_ops *ops,
				    struct regcache *regcache, int regno)
{
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  if (-1 == regno)
    {
      store_regs (regcache);
      store_fpregs (regcache);
      if (tdep->have_wmmx_registers)
	store_wmmx_regs (regcache);
      if (tdep->vfp_register_count > 0)
	store_vfp_regs (regcache);
    }
  else
    {
      if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
        store_register (regcache, regno);
      else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM))
        store_fpregister (regcache, regno);
      else if (tdep->have_wmmx_registers
	       && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
	store_wmmx_regs (regcache);
      else if (tdep->vfp_register_count > 0
	       && regno >= ARM_D0_REGNUM
	       && regno <= ARM_D0_REGNUM + tdep->vfp_register_count)
	store_vfp_regs (regcache);
    }
}
Example #11
0
static void
hppa_linux_store_inferior_registers (struct target_ops *ops,
				     struct regcache *regcache, int regno)
{
  if (-1 == regno)
    {
      for (regno = 0;
	   regno < gdbarch_num_regs (get_regcache_arch (regcache));
	   regno++)
	store_register (regcache, regno);
    }
  else
    {
      store_register (regcache, regno);
    }
}
Example #12
0
static void
old_store_inferior_registers (const struct regcache *regcache, int regno)
{
  if (regno >= 0)
    {
      store_register (regcache, regno);
    }
  else
    {
      for (regno = 0;
	   regno < gdbarch_num_regs (get_regcache_arch (regcache));
	   regno++)
	{
	  store_register (regcache, regno);
	}
    }
}
/* Store register REGNO back into the child process.  If REGNO is -1,
   do this for all registers (including the floating point and SSE
   registers).  */
static void
i386_linux_store_inferior_registers (struct target_ops *ops,
				     struct regcache *regcache, int regno)
{
  int tid;

  /* Use the old method of poking around in `struct user' if the
     SETREGS request isn't available.  */
  if (!have_ptrace_getregs)
    {
      int i;

      for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
	if (regno == -1 || regno == i)
	  store_register (regcache, i);

      return;
    }

  /* GNU/Linux LWP ID's are process ID's.  */
  tid = TIDGET (inferior_ptid);
  if (tid == 0)
    tid = PIDGET (inferior_ptid); /* Not a threaded program.  */

  /* Use the PTRACE_SETFPXREGS requests whenever possible, since it
     transfers more registers in one system call.  But remember that
     store_fpxregs can fail, and return zero.  */
  if (regno == -1)
    {
      store_regs (regcache, tid, regno);
      if (store_fpxregs (regcache, tid, regno))
	return;
      store_fpregs (regcache, tid, regno);
      return;
    }

  if (GETREGS_SUPPLIES (regno))
    {
      store_regs (regcache, tid, regno);
      return;
    }

  if (GETFPXREGS_SUPPLIES (regno))
    {
      if (store_fpxregs (regcache, tid, regno))
	return;

      /* Either our processor or our kernel doesn't support the SSE
	 registers, so just write the FP registers in the traditional
	 way.  */
      store_fpregs (regcache, tid, regno);
      return;
    }

  internal_error (__FILE__, __LINE__,
		  _("Got request to store bad register number %d."), regno);
}
Example #14
0
void encrypt(WORDSIZE* data, WORDSIZE* keyr, WORDSIZE* keym, 
             WORDSIZE* extra_data, WORDSIZE* tag, WORDSIZE* decryption_iv,
             unsigned long data_size, unsigned long extra_data_size){
    REGISTER a, b, c, d, t;    
    unsigned long index;
    
    keyed_hash_function(keyr, extra_data, extra_data_size, tag);
    load_register(c, keyr, 0); load_register(d, keyr, 4);
    unsigned long block_number;    
    for (block_number = 0; block_number < data_size / 8; block_number++){        
        load_register(a, data, (block_number * 8));
        load_register(b, data, ((block_number * 8) + 4));        
        permutation(a, b, c, d);
        store_register(a, data, (block_number * 8));
        store_register(b, data, ((block_number * 8) + 4));}          
    
    load_register(t, keym, 0);
    c ^= t;
    load_register(t, keym, 4);
    d ^= t;
    store_register(c, decryption_iv, 0); 
    store_register(d, decryption_iv, 4);}
static void
ppc_linux_store_inferior_registers (int regno)
{
  /* Overload thread id onto process id */
  int tid = TIDGET (inferior_ptid);

  /* No thread id, just use process id */
  if (tid == 0)
    tid = PIDGET (inferior_ptid);

  if (regno >= 0)
    store_register (tid, regno);
  else
    store_ppc_registers (tid);
}
Example #16
0
void
store_inferior_registers (int regno)
{
  if (regno >= 0)
    {
      if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
	store_register (regno);
      else
	store_fp_register (regno);
    }
  else
    {
      store_regs ();
      store_fp_regs ();
    }
}
Example #17
0
static void
armnbsd_store_registers (struct target_ops *ops,
			 struct regcache *regcache, int regno)
{
  if (regno >= 0)
    {
      if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
	store_register (regcache, regno);
      else
	store_fp_register (regcache, regno);
    }
  else
    {
      store_regs (regcache);
      store_fp_regs (regcache);
    }
}
Example #18
0
void
store_inferior_registers (int regno)
{
  if (-1 == regno)
    {
      store_regs ();
      store_fpregs ();
    }
  else
    {
      if ((regno < F0_REGNUM) || (regno > FPS_REGNUM))
        store_register (regno);

      if ((regno >= F0_REGNUM) && (regno <= FPS_REGNUM))
        store_fpregister (regno);
    }
}
Example #19
0
void	and_op(t_proc *proc, t_op_arg args[3])
{
	int		sum;
	int		a;
	int		b;

	a = get_value(proc, args, 0, 0);
	b = get_value(proc, args, 1, 0);
	if (g_corewar.reg_error)
		return ;
	sum = a & b;
	store_register(get_register(proc->reg, args[2].value), (char *)&sum);
	if (g_corewar.reg_error)
		return ;
	if (sum != 0)
		proc->carry = 0;
	else
		proc->carry = 1;
}
Example #20
0
static void
store_ppc_registers (const struct regcache *regcache, int tid)
{
  int i;
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  
  for (i = 0; i < ppc_num_gprs; i++)
    store_register (regcache, tid, tdep->ppc_gp0_regnum + i);
  if (tdep->ppc_fp0_regnum >= 0)
    for (i = 0; i < ppc_num_fprs; i++)
      store_register (regcache, tid, tdep->ppc_fp0_regnum + i);
  store_register (regcache, tid, gdbarch_pc_regnum (gdbarch));
  if (tdep->ppc_ps_regnum != -1)
    store_register (regcache, tid, tdep->ppc_ps_regnum);
  if (tdep->ppc_cr_regnum != -1)
    store_register (regcache, tid, tdep->ppc_cr_regnum);
  if (tdep->ppc_lr_regnum != -1)
    store_register (regcache, tid, tdep->ppc_lr_regnum);
  if (tdep->ppc_ctr_regnum != -1)
    store_register (regcache, tid, tdep->ppc_ctr_regnum);
  if (tdep->ppc_xer_regnum != -1)
    store_register (regcache, tid, tdep->ppc_xer_regnum);
  if (tdep->ppc_mq_regnum != -1)
    store_register (regcache, tid, tdep->ppc_mq_regnum);
  if (tdep->ppc_fpscr_regnum != -1)
    store_register (regcache, tid, tdep->ppc_fpscr_regnum);
  if (ppc_linux_trap_reg_p (gdbarch))
    {
      store_register (regcache, tid, PPC_ORIG_R3_REGNUM);
      store_register (regcache, tid, PPC_TRAP_REGNUM);
    }
  if (have_ptrace_getvrregs)
    if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
      store_altivec_registers (regcache, tid);
  if (have_ptrace_getsetvsxregs)
    if (tdep->ppc_vsr0_upper_regnum != -1)
      store_vsx_registers (regcache, tid);
  if (tdep->ppc_ev0_upper_regnum >= 0)
    store_spe_register (regcache, tid, -1);
}
Example #21
0
static void
rs6000_store_inferior_registers (struct target_ops *ops,
                                 struct regcache *regcache, int regno)
{
    struct gdbarch *gdbarch = get_regcache_arch (regcache);
    if (regno != -1)
        store_register (regcache, regno);

    else
    {
        struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

        /* Write general purpose registers first.  */
        for (regno = tdep->ppc_gp0_regnum;
                regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
                regno++)
        {
            store_register (regcache, regno);
        }

        /* Write floating point registers.  */
        if (tdep->ppc_fp0_regnum >= 0)
            for (regno = 0; regno < ppc_num_fprs; regno++)
                store_register (regcache, tdep->ppc_fp0_regnum + regno);

        /* Write special registers.  */
        store_register (regcache, gdbarch_pc_regnum (gdbarch));
        store_register (regcache, tdep->ppc_ps_regnum);
        store_register (regcache, tdep->ppc_cr_regnum);
        store_register (regcache, tdep->ppc_lr_regnum);
        store_register (regcache, tdep->ppc_ctr_regnum);
        store_register (regcache, tdep->ppc_xer_regnum);
        if (tdep->ppc_fpscr_regnum >= 0)
            store_register (regcache, tdep->ppc_fpscr_regnum);
        if (tdep->ppc_mq_regnum >= 0)
            store_register (regcache, tdep->ppc_mq_regnum);
    }
}
Example #22
0
void
store_inferior_registers (int regno)
{
  if (regno != -1)
    store_register (regno);

  else
    {
      struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);

      /* Write general purpose registers first.  */
      for (regno = tdep->ppc_gp0_regnum;
           regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
	   regno++)
	{
	  store_register (regno);
	}

      /* Write floating point registers.  */
      if (tdep->ppc_fp0_regnum >= 0)
        for (regno = 0; regno < ppc_num_fprs; regno++)
          store_register (tdep->ppc_fp0_regnum + regno);

      /* Write special registers.  */
      store_register (PC_REGNUM);
      store_register (tdep->ppc_ps_regnum);
      store_register (tdep->ppc_cr_regnum);
      store_register (tdep->ppc_lr_regnum);
      store_register (tdep->ppc_ctr_regnum);
      store_register (tdep->ppc_xer_regnum);
      if (tdep->ppc_fpscr_regnum >= 0)
        store_register (tdep->ppc_fpscr_regnum);
      if (tdep->ppc_mq_regnum >= 0)
	store_register (tdep->ppc_mq_regnum);
    }
}