Exemple #1
0
void check_mrf(void)
{
  DEBUG_PRINTLN("check_mrf");
  int pan = mrf.get_pan();
  DEBUG_PRINTLN2H("pan ", pan);

  int addr = mrf.address16_read();
  DEBUG_PRINTLN2H("addr ", addr);

  DEBUG_SHORT(MRF_PACON2);
  DEBUG_SHORT(MRF_TXSTBL);

  DEBUG_LONG(MRF_RFCON0);
  DEBUG_LONG(MRF_RFCON1);
  DEBUG_LONG(MRF_RFCON2);
  DEBUG_LONG(MRF_RFCON6);
  DEBUG_LONG(MRF_RFCON7);
  DEBUG_LONG(MRF_RFCON8);
  DEBUG_LONG(MRF_SLPCON1);

  DEBUG_SHORT(MRF_BBREG2);
  DEBUG_SHORT(MRF_CCAEDTH);
  DEBUG_SHORT(MRF_BBREG6);

  DEBUG_PRINTLN("done check_mrf");
}
Exemple #2
0
void slab_debug( slab_t *slab )
{
	uint8_t cnt = 0;
	slab_item_t *itr = slab->head;
	DEBUG("slab size = %d, num item per pool = %d, empty vector = %x\n", slab->item_size, slab->num_items_per_pool, slab->empty_vector);
	
	while( itr != NULL ) {
		uint8_t i;
		uint8_t mask = 0x01;
		
		for( i = 0; i < slab->num_items_per_pool; i++, mask<<=1 ) {
			if( itr->alloc & mask ) {
				uint8_t *m = itr->mem;
				uint8_t j;
				
				m += (i * slab->item_size);
				DEBUG_SHORT("addr = %d: ", (int)m);
				
				for( j = 0; j < slab->item_size; j++ ) {
					DEBUG_SHORT("%d ", m[j]);
				}
				DEBUG_SHORT("\n");
			}
		}
		cnt++;
		itr = itr->next;
	}
	DEBUG("number of pools = %d\n", cnt);
}
Exemple #3
0
static void print_msg_name(uint8_t type)
{
	if(type < MOD_MSG_START) {
		DEBUG_SHORT("%s", ker_msg_name[type]);
	} else {
		DEBUG_SHORT("+%d", type - MOD_MSG_START);
	}
}
Exemple #4
0
void msg_print(Message *msg)
{
	DEBUG_SHORT(" < %d > ", msg->daddr);
	print_mod_id(msg->did);
	DEBUG_SHORT("   <--- ");
	print_msg_name(msg->type);
	DEBUG_SHORT("( %d ) ----   < %d > ", msg->len, msg->saddr);
	print_mod_id(msg->sid);
	DEBUG_SHORT("\n");
}
Exemple #5
0
static void print_mod_id(sos_pid_t pid)
{
	if(pid <= KER_MOD_MAX_PID) {
		DEBUG_SHORT("%s", ker_pid_name[pid]);
	} else if(pid >= APP_MOD_MIN_PID) {
		DEBUG_SHORT("%s", mod_pid_name[pid - APP_MOD_MIN_PID]); 
	} else {
		DEBUG_SHORT("unknown %d", pid);
	}
}
Exemple #6
0
void msg_trace(Message *msg, bool out)
{
	if(out) {
		DEBUG_SHORT("<OUT>  ");
	} else {
		if(msg->saddr == node_address) {
			DEBUG_SHORT("<LOCAL>");
		} else {
			DEBUG_SHORT("<IN>   ");
		}
	}
	msg_print(msg);
}
int
rsa_verify (const uint8_t *pubkey, const uint8_t *hash, const uint8_t *sig)
{
  int r;

  rsa_init (&rsa_ctx, RSA_PKCS_V15, 0);
  rsa_ctx.len = KEY_CONTENT_LEN;
  mpi_lset (&rsa_ctx.E, 0x10001);
  mpi_read_binary (&rsa_ctx.N, pubkey, KEY_CONTENT_LEN);

  DEBUG_INFO ("RSA verify...");

  r = rsa_pkcs1_verify (&rsa_ctx, RSA_PUBLIC, SIG_RSA_SHA256, 32, hash, sig);

  rsa_free (&rsa_ctx);
  if (r < 0)
    {
      DEBUG_INFO ("fail:");
      DEBUG_SHORT (r);
      return r;
    }
  else
    {
      DEBUG_INFO ("verified.\r\n");
      return 0;
    }
}
int
rsa_decrypt (const uint8_t *input, uint8_t *output, int msg_len,
	     struct key_data *kd)
{
  mpi P1, Q1, H;
  int r;
  int output_len;

  DEBUG_INFO ("RSA decrypt:");
  DEBUG_WORD ((uint32_t)&output_len);

  mpi_init (&P1, &Q1, &H, NULL);
  rsa_init (&rsa_ctx, RSA_PKCS_V15, 0);

  rsa_ctx.len = msg_len;
  DEBUG_WORD (msg_len);

  mpi_lset (&rsa_ctx.E, 0x10001);
  mpi_read_binary (&rsa_ctx.P, &kd->data[0], KEY_CONTENT_LEN / 2);
  mpi_read_binary (&rsa_ctx.Q, &kd->data[KEY_CONTENT_LEN/2],
		   KEY_CONTENT_LEN / 2);
#if 0 /* Using CRT, we don't use N */
  mpi_mul_mpi (&rsa_ctx.N, &rsa_ctx.P, &rsa_ctx.Q);
#endif
  mpi_sub_int (&P1, &rsa_ctx.P, 1);
  mpi_sub_int (&Q1, &rsa_ctx.Q, 1);
  mpi_mul_mpi (&H, &P1, &Q1);
  mpi_inv_mod (&rsa_ctx.D , &rsa_ctx.E, &H);
  mpi_mod_mpi (&rsa_ctx.DP, &rsa_ctx.D, &P1);
  mpi_mod_mpi (&rsa_ctx.DQ, &rsa_ctx.D, &Q1);
  mpi_inv_mod (&rsa_ctx.QP, &rsa_ctx.Q, &rsa_ctx.P);
  mpi_free (&P1, &Q1, &H, NULL);

  DEBUG_INFO ("RSA decrypt ...");

  r = rsa_pkcs1_decrypt (&rsa_ctx, RSA_PRIVATE, &output_len,
			 input, output, MAX_RES_APDU_DATA_SIZE);
  rsa_free (&rsa_ctx);
  if (r < 0)
    {
      DEBUG_INFO ("fail:");
      DEBUG_SHORT (r);
      return r;
    }
  else
    {
      res_APDU_size = output_len;
      DEBUG_INFO ("done.\r\n");
      GPG_SUCCESS ();
      return 0;
    }
}
int
rsa_sign (const uint8_t *raw_message, uint8_t *output, int msg_len,
	  struct key_data *kd)
{
  mpi P1, Q1, H;
  int r;
  unsigned char temp[RSA_SIGNATURE_LENGTH];

  mpi_init (&P1, &Q1, &H, NULL);
  rsa_init (&rsa_ctx, RSA_PKCS_V15, 0);

  rsa_ctx.len = KEY_CONTENT_LEN;
  mpi_lset (&rsa_ctx.E, 0x10001);
  mpi_read_binary (&rsa_ctx.P, &kd->data[0], rsa_ctx.len / 2);
  mpi_read_binary (&rsa_ctx.Q, &kd->data[KEY_CONTENT_LEN/2], rsa_ctx.len / 2);
#if 0 /* Using CRT, we don't use N */
  mpi_mul_mpi (&rsa_ctx.N, &rsa_ctx.P, &rsa_ctx.Q);
#endif
  mpi_sub_int (&P1, &rsa_ctx.P, 1);
  mpi_sub_int (&Q1, &rsa_ctx.Q, 1);
  mpi_mul_mpi (&H, &P1, &Q1);
  mpi_inv_mod (&rsa_ctx.D , &rsa_ctx.E, &H);
  mpi_mod_mpi (&rsa_ctx.DP, &rsa_ctx.D, &P1);
  mpi_mod_mpi (&rsa_ctx.DQ, &rsa_ctx.D, &Q1);
  mpi_inv_mod (&rsa_ctx.QP, &rsa_ctx.Q, &rsa_ctx.P);
  mpi_free (&P1, &Q1, &H, NULL);

  DEBUG_INFO ("RSA sign...");

  r = rsa_pkcs1_sign (&rsa_ctx, RSA_PRIVATE, SIG_RSA_RAW,
		      msg_len, raw_message, temp);
  memcpy (output, temp, RSA_SIGNATURE_LENGTH);
  rsa_free (&rsa_ctx);
  if (r < 0)
    {
      DEBUG_INFO ("fail:");
      DEBUG_SHORT (r);
      return r;
    }
  else
    {
      res_APDU_size = RSA_SIGNATURE_LENGTH;
      DEBUG_INFO ("done.\r\n");
      GPG_SUCCESS ();
      return 0;
    }
}
Exemple #10
0
static void nb_debug(nbr_state_t *s)
{
  nbr_entry_t *nb = s->nb_list;

  DEBUG("\taddr\tprnt\tmisd\trcvd\tlstS\thop\trEst\tsEst\n");
  while(nb != NULL) {
    DEBUG("\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
          nb->id,
          nb->parent,
          nb->missed,
          nb->received,
          nb->lastSeqno,
          nb->hop,
          nb->receiveEst,
          nb->sendEst);
    nb = nb->next;
  }
  DEBUG_SHORT("\n");
}
Exemple #11
0
static int
cir_getchar (uint32_t timeout)
{
  uint16_t cir_addr;
#if defined(DEBUG_CIR)
  uint16_t *p;
#endif

#if defined(DEBUG_CIR)
  cirinput_p = cirinput;
#endif

  cir_ll_init ();

  notification = 0;
  wait_usec = timeout;
  chopstx_usec_wait_var (&wait_usec);
  if (notification == 0)
    return -1;

  /* Sleep 200ms to avoid detecting chatter inputs.  */
  chopstx_usec_wait (200 * 1000);

#if defined(DEBUG_CIR)
  DEBUG_INFO ("****\r\n");
  DEBUG_SHORT (intr_ext);
  DEBUG_SHORT (intr_trg);
  DEBUG_SHORT (intr_ovf);
  DEBUG_INFO ("----\r\n");
  for (p = cirinput; p < cirinput_p; p++)
    {
      DEBUG_SHORT (*p);
    }
  DEBUG_INFO ("====\r\n");

  cirinput_p = cirinput;

  DEBUG_INFO ("**** CIR data:");
  DEBUG_WORD (cir_data);
  if (cir_seq > 48)
    {
      DEBUG_SHORT (cir_data_more);
    }
  DEBUG_BYTE (cir_seq);
#endif

  switch (cir_proto)
    {
    case CIR_PROTO_RC5:
      cir_data &= 0x003f;
      goto err;
    case CIR_PROTO_RC6:
      cir_addr = cir_data >> 8; /* in case of cir_seq == 16.  32??? */
      cir_data &= 0x00ff;
      return find_char_codetable (cir_data, cir_codetable_dell_mr425);
    case CIR_PROTO_NEC:
      cir_addr = cir_data&0xffff;
      if (cir_addr == CIR_ADDR_TOSHIBA_REGZA)
	{
	  cir_data = (cir_data >> 16) & 0x00ff;
	  return find_char_codetable (cir_data, cir_codetable_regza);
	}
      else
	goto err;