Example #1
0
void output_global_data(PERF_DATA_BLOCK *data, RuntimeSettings rt, int tdb_flags)
{
    int i;
    char key[NAME_LEN];
    char sdata[NAME_LEN];
    
     /* Initialize BaseIndex */
    make_key(key, NAME_LEN, 1, NULL);
    memset(sdata, 0, NAME_LEN);
    sprintf(sdata, "%d", data->num_counters);
    add_key(rt.cnames, key, sdata, tdb_flags);
    /* Initialize PerfTime, PerfFreq and PerfTime100nSec */
    memset(sdata, 0, NAME_LEN);
    make_key(key, NAME_LEN, 0, "PerfTime");
    sprintf(sdata, "%Lu", data->PerfTime);
    add_key(rt.cdata, key, sdata, tdb_flags);
    make_key(key, NAME_LEN, 0, "PerfTime100nSec");
    memset(sdata, 0, NAME_LEN);
    sprintf(sdata, "%Lu", data->PerfTime100nSec);
    add_key(rt.cdata, key, sdata, tdb_flags);
    memset(sdata, 0, NAME_LEN);
    make_key(key, NAME_LEN, 0, "PerfFreq");
    sprintf(sdata, "%Lu", data->PerfFreq);
    add_key(rt.cnames, key, sdata, tdb_flags);

    return;
}
Example #2
0
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  static uint8_t mods_pressed;

  switch (id) {
    case 0:
      /* Handle the combined Grave/Esc key
       */
      mods_pressed = get_mods()&GRAVE_MODS; // Check to see what mods are pressed

      if (record->event.pressed) {
        /* The key is being pressed.
         */
        if (mods_pressed) {
          add_key(KC_GRV);
          send_keyboard_report();
        } else {
          add_key(KC_ESC);
          send_keyboard_report();
        }
      } else {
        /* The key is being released.
         */
        if (mods_pressed) {
          del_key(KC_GRV);
          send_keyboard_report();
        } else {
          del_key(KC_ESC);
          send_keyboard_report();
        }
      }
      break;
  }
}
Example #3
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case SFT_ESC:
      if (record->event.pressed) {
        if (get_mods() & MODS_SHIFT_MASK) {
          add_key(KC_GRV);
          send_keyboard_report();
        } else {
          add_key(KC_ESC);
          send_keyboard_report();
        }
      } else {
        if (get_mods() & MODS_SHIFT_MASK) {
          del_key(KC_GRV);
          send_keyboard_report();
        } else {
          del_key(KC_ESC);
          send_keyboard_report();
        }
      }

      return false;

    default:
      return true;
  }
}
Example #4
0
void output_perf_desc(PerfCounter counter, RuntimeSettings rt)
{
    char key[NAME_LEN];
    char sdata[NAME_LEN];

    /* First insert the counter name */
    make_key(key, NAME_LEN, counter.index, NULL);
    add_key(rt.cnames, key, counter.name, TDB_INSERT);
    /* Add the help string */
    make_key(key, NAME_LEN, counter.index + 1, NULL);
    add_key(rt.cnames, key, counter.help, TDB_INSERT);
    /* Add the relationships */
    make_key(key, NAME_LEN, counter.index, "rel");
    add_key(rt.cnames, key, counter.relationships, TDB_INSERT);
    /* Add type data if not PERF_OBJECT or PERF_INSTANCE */
    if(counter.record_type == PERF_COUNTER)
    {
	make_key(key, NAME_LEN, counter.index, "type");
	memset(sdata, 0, NAME_LEN);
	sprintf(sdata, "%d", counter.counter_type);
	add_key(rt.cnames, key, sdata, TDB_INSERT);
    }

    return;
}
Example #5
0
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  static uint8_t shift_esc_shift_mask;
  switch (id) {
    case SHIFT_ESC:
      shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
      if (record->event.pressed) {
        if (shift_esc_shift_mask) {
          add_key(KC_GRV);
        send_keyboard_report();
        } else {
          add_key(KC_ESC);
          send_keyboard_report();
        }
      } else {
        if (shift_esc_shift_mask) {
          del_key(KC_GRV);
          send_keyboard_report();
        } else {
          del_key(KC_ESC);
          send_keyboard_report();
        }
      }
      break;
  }
}
Example #6
0
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
#   define MODS_CTRL_MASK   (MOD_BIT(KC_LCTRL)|MOD_BIT(KC_RCTRL))
    static uint8_t ctrl_space_i_prev_ctrl;

    switch (id) {
    // Ctrl + Up(SpaceFN) -> PgUp
    case CTRL_SPACE_I:
        ctrl_space_i_prev_ctrl = get_mods()&MODS_CTRL_MASK;
        if (record->event.pressed) {
            if (ctrl_space_i_prev_ctrl) {
                del_mods(ctrl_space_i_prev_ctrl);   // remove Ctrl
                add_key(KC_PGUP);
                send_keyboard_report(); // send PgUp without Ctrl
                add_mods(ctrl_space_i_prev_ctrl);   // return Ctrl but not sent
            } else {
                add_key(KC_UP);
                send_keyboard_report();
            }
        } else {
            if (ctrl_space_i_prev_ctrl) {
                del_key(KC_PGUP);
                send_keyboard_report();
            } else {
                del_key(KC_UP);
                send_keyboard_report();
            }
        }
        break;
    }
}
Example #7
0
// Sends the HMDP request 'List'
// @param sockfd the socket descriptor of the server
// @param token the token used for verification
// @param list the list of files found in the clients hooli directory
void request_list(int sockfd, char *token, csv_record *list) {
    
    char *request;                          // The 'List' message
    char *list_size;                        // The size of the list of files and checksums
    
    int length;                             // The length of the 'List' message
    
    asprintf(&list_size, "%d", get_list_size(list));
    
    add_command(&request, COMMAND_LIST);    //  |-----------------|
    add_key(&request, KEY_TOKEN);           //  |List\n           |
    add_value(&request, token);             //  |-----------------|
    add_key(&request, KEY_LENGTH);          //  |Token:value\n    |
    add_value(&request, list_size);         //  |-----------------|
    delimit_header(&request);               //  |Length:value\n\n |
    add_body(&request, list);               //  |-----------------|
                                            //  |Body:            |
                                            //  |-----------------|
    length = strlen(request);
    
    // Check to see if the message sent successfully
    if (send_all(sockfd, request, &length) == -1) {
        
        syslog(LOG_ERR, "Only sent %d bytes\n", length);
        
    } //end if
    
    free(list_size);
    free(request);
    
    list_size = NULL;
    request = NULL;
    
} //end request_list
Example #8
0
// Sends the HMDP request 'Auth'
// @param sockfd the socket descriptor of the server
// @param username the username of the client
// @param password the password of the client
void request_auth(int sockfd, char *username, char *password) {
    
    char *request;                          // The 'Auth' message
    
    int length;                             // The length of the 'Auth' message
    
    add_command(&request, COMMAND_AUTH);    //  |-------------------|
    add_key(&request, KEY_USERNAME);        //  |Auth\n             |
    add_value(&request, username);          //  |-------------------|
    add_key(&request, KEY_PASSWORD);        //  |Username:value\n   |
    add_value(&request, password);          //  |-------------------|
    delimit_header(&request);               //  |Password:value\n\n |
                                            //  |-------------------|
    length = strlen(request);
    
    // Check to see if the message sent successfully
    if (send_all(sockfd, request, &length) == -1) {
        
        syslog(LOG_ERR, "Only sent %d bytes\n", length);
        
    } //end if
    
    free(request);
    request = NULL;
    
} //end request_auth
Example #9
0
		int t = result;
		while(t >= 0x0100)
		{
			num ++;
			t = t >> 1;
		}
		num --;
		result = result ^ (m << num);
	}

	temp = result;
	return temp;
}
void row_mix(unsigned char state[4][4])
{
	unsigned char temp[4][4];
	for (int i = 0 ; i < 4 ; i ++)
	{
		for(int j = 0 ; j < 4 ; j ++)
		{
			temp[i][j] = state[i][j];
		}
	}
	for(int i = 0 ; i < 4 ; i ++)
	{
		state[0][i] = mul_gf8(0x02,temp[0][i]) ^ mul_gf8(0x03,temp[1][i]) ^ mul_gf8(0x01,temp[2][i]) ^  mul_gf8(0x01,temp[3][i]);
		state[1][i] = mul_gf8(0x01,temp[0][i]) ^ mul_gf8(0x02,temp[1][i]) ^ mul_gf8(0x03,temp[2][i]) ^  mul_gf8(0x01,temp[3][i]);
		state[2][i] = mul_gf8(0x01,temp[0][i]) ^ mul_gf8(0x01,temp[1][i]) ^ mul_gf8(0x02,temp[2][i]) ^  mul_gf8(0x03,temp[3][i]);
		state[3][i] = mul_gf8(0x03,temp[0][i]) ^ mul_gf8(0x01,temp[1][i]) ^ mul_gf8(0x01,temp[2][i]) ^  mul_gf8(0x02,temp[3][i]);	
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    if (record->event.pressed) dprint("P"); else dprint("R");
    if (record->tap.interrupted) dprint("i");

#   define MODS_SHIFT_MASK   (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
    static uint8_t shift_mod;

    switch (id) {
        // Shift + Esc -> ~
        case SHIFT_ESC:
            shift_mod = get_mods()&MODS_SHIFT_MASK;
            if (record->event.pressed) {
                if (shift_mod) {
                    add_key(KC_GRV);
                    send_keyboard_report(); // send grave with shift for tilde result
                } else {
                    del_mods(shift_mod); // remove shift
                    add_key(KC_ESC);
                    send_keyboard_report(); // send escape
                    add_mods(shift_mod); // return shift but not sent
                }
            } else {
                if (shift_mod) {
                    del_key(KC_GRV);
                    send_keyboard_report();
                } else {
                    del_key(KC_ESC);
                    send_keyboard_report();
                }
            }
            break;
        case SHIFT_BSPC:
            shift_mod = get_mods()&MODS_SHIFT_MASK;
            if (record->event.pressed) {
                if (shift_mod) {
                    add_key(KC_BSLS);
                    send_keyboard_report(); // send backslash with shift for pipe result
                } else {
                    del_mods(shift_mod); // remove shift
                    add_key(KC_BSPC);
                    send_keyboard_report(); // send backspace
                    add_mods(shift_mod); // return shift but not sent
                }
            } else {
                if (shift_mod) {
                    del_key(KC_BSLS);
                    send_keyboard_report();
                } else {
                    del_key(KC_BSPC);
                    send_keyboard_report();
                }
            }
            break;
    }
}
Example #11
0
void special_esc(bool pressed) {
    if (pressed) {
        if (shifted() || guied()) {
            add_key(KC_GRV);
        } else {
            add_key(KC_ESC);
        }
        send_keyboard_report();
    } else {
        clear_keyboard_but_mods();
    }
}
Example #12
0
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  static uint8_t mods_pressed;
  static bool mod_flag;

  switch (id) {
    case 0:
      // clueboard specific hook to make escape quite tetris
      if (tetris_running) {
        tetris_running = 0;
        return;
      }
      
      /* Handle the combined Grave/Esc key
       */
      mods_pressed = get_mods()&GRAVE_MODS; // Check to see what mods are pressed

      if (record->event.pressed) {
        /* The key is being pressed.
         */
        if (mods_pressed) {
          mod_flag = true;
          add_key(KC_GRV);
          send_keyboard_report();
        } else {
          add_key(KC_ESC);
          send_keyboard_report();
        }
      } else {
        /* The key is being released.
         */
        if (mod_flag) {
          mod_flag = false;
          del_key(KC_GRV);
          send_keyboard_report();
        } else {
          del_key(KC_ESC);
          send_keyboard_report();
        }
      }
      break;
  case 1:
      if (record->event.pressed) {
        tetris_running = 1;
        tetris_timer = 0;
        tetris_keypress = 0;
        // set randomness using total number of key presses
        tetris_start(tetris_key_presses);
      }
      break;
  }
}
Example #13
0
/* emulate poll_keyboard() and poll_joystick() combined */
void poll_input()
{
   ALLEGRO_EVENT event;

   while (al_get_next_event(input_queue, &event)) {

      switch (event.type) {

	 case ALLEGRO_EVENT_KEY_DOWN:
	    key[event.keyboard.keycode] = 1;
	    add_key(&event.keyboard);
	    break;

	 case ALLEGRO_EVENT_KEY_REPEAT:
	    add_key(&event.keyboard);
	    break;

	 case ALLEGRO_EVENT_KEY_UP:
	    key[event.keyboard.keycode] = 0;
	    break;

	 case ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN:
	    if (event.joystick.button == 0)
	       joy_b1 = 1;
	    break;

	 case ALLEGRO_EVENT_JOYSTICK_BUTTON_UP:
	    if (event.joystick.button == 0)
	       joy_b1 = 0;
	    break;

	 case ALLEGRO_EVENT_JOYSTICK_AXIS:
	    if (event.joystick.stick == 0 && event.joystick.axis == 0) {
	       float pos = event.joystick.pos;
	       joy_left = (pos < 0.0);
	       joy_right = (pos > 0.0);
	    }
	    break;

	 case ALLEGRO_EVENT_TIMER:
	    /* retrace_count incremented */
	    break;

	 case ALLEGRO_EVENT_DISPLAY_EXPOSE:
	    break;
      }
   }
}
Example #14
0
/*
 * user defined action function
 */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
    keyevent_t event = record->event;
    tap_t tap = record->tap;

    switch (id) {
        case LSHIFT_LPAREN:
            // LShft + tap '('
            // NOTE: cant use register_code to avoid conflicting with magic key bind
            if (event.pressed) {
                if (tap.count == 0 || tap.interrupted) {
                    add_mods(MOD_BIT(KC_LSHIFT));
                } else {
                    add_mods(MOD_BIT(KC_LSHIFT));
                    add_key(KC_9);
                    send_keyboard_report();
                    del_mods(MOD_BIT(KC_LSHIFT));
                    del_key(KC_9);
                    send_keyboard_report();
                }
            } else {
                if (tap.count == 0 || tap.interrupted) {
                    del_mods(MOD_BIT(KC_LSHIFT));
                    //layer_off(1);
                }
            }
            break;
        case RSHIFT_RPAREN:
            // RShift + tap ')'
            if (event.pressed) {
                if (tap.count == 0 || tap.interrupted) {
                    add_mods(MOD_BIT(KC_RSHIFT));
                } else {
                    add_mods(MOD_BIT(KC_RSHIFT));
                    add_key(KC_0);
                    send_keyboard_report();
                    del_mods(MOD_BIT(KC_RSHIFT));
                    del_key(KC_0);
                    send_keyboard_report();
                }
            } else {
                if (tap.count == 0 || tap.interrupted) {
                    del_mods(MOD_BIT(KC_RSHIFT));
                }
            }
            break;
    }
}
Example #15
0
class_tag::class_tag(const config & cfg)
	: name_(cfg["name"].str())
	, min_(cfg["min"].to_int())
	, max_(cfg["max"].to_int())
	, super_("")
	, tags_()
	, keys_()
	, links_()
{
		if (max_ < 0){
			max_ = INT_MAX;
		}
		if (cfg.has_attribute("super")){
			super_ = cfg["super"].str();
		}
		foreach (const config &child, cfg.child_range("tag")) {
			class_tag child_tag (child);
			add_tag(child_tag);
		}
		foreach (const config &child, cfg.child_range("key")) {
			class_key child_key (child);
			add_key(child_key);
		}
		foreach (const config &link, cfg.child_range("link")) {
			std::string link_name = link["name"].str();
			add_link(link_name);
		}
}
Example #16
0
void hal_aes_crypt(uint8_t * dest_buf,uint8_t * src_buf)
{
    uint8_t a;

    for(a=0; a<16; a++)
    {
        aes_state[a] = src_buf[a];
    }

    //Start
    CCPDATIB = 0x02;  //Set co-prosessor the GF(2^8)*2 (used in mix-colums)
    for (a=0; a<9; a++)
    {
        add_sub_shift();
        mix_columns_hw();
        key_upgrade(a);
    }

    //FINAL	round
    add_sub_shift();
    key_upgrade(9);
    add_key();

    //Clean up
    for(a=0; a<16; a++)
    {
        aes_round_key[a]=cipher_key[a]; //Write back cipher-key
        dest_buf[a] = aes_state[a];     //Write out encrypted result
    }
}
Example #17
0
static int add_secret_to_kernel(const char *secret, const char *key_name)
{
  /* try to submit key to kernel via the keys api */
  key_serial_t serial;
  int ret;
  int secret_len = strlen(secret);
  char payload[((secret_len * 3) / 4) + 4];
  char error_buf[80];

  ret = ceph_unarmor(payload, payload+sizeof(payload), secret, secret+secret_len);
  if (ret < 0) {
    fprintf(stderr, "secret is not valid base64: %s.\n",
	    strerror_r(-ret, error_buf, sizeof(error_buf)));
    return ret;
  }

  serial = add_key("ceph", key_name, payload, sizeof(payload), KEY_SPEC_USER_KEYRING);
  if (serial < 0) {
    ret = -errno;
    fprintf(stderr, "error adding secret to kernel, key name %s: %s.\n",
	    key_name, strerror_r(-ret, error_buf, sizeof(error_buf)));
  }

  return ret;
}
Example #18
0
/*@-globs -internalglobs -mods @*/
char * _GetPass(const char * prompt)
{
    char * pw;

/*@-unrecog@*/
    pw = getpass( prompt ? prompt : "" );
/*@=unrecog@*/

#if defined(HAVE_KEYUTILS_H)
    if (_kuKeyring == 0) {
	const char * _keyutils_keyring
		= rpmExpand("%{?_keyutils_keyring}", NULL);
	_kuKeyring = (rpmuint32_t) kuValue(_keyutils_keyring);
	if (_kuKeyring == 0)
	    _kuKeyring = KEY_SPEC_PROCESS_KEYRING;
	_keyutils_keyring = _free(_keyutils_keyring);
    }

    if (pw && *pw) {
	key_serial_t keyring = (key_serial_t) _kuKeyring;
	size_t npw = strlen(pw);
	(void) add_key("user", "rpm:passwd", pw, npw, keyring);
	(void) memset(pw, 0, npw);	/* burn the password */
	pw = (char *) "@u user rpm:passwd";
    }
#endif	/* HAVE_KEYUTILS_H */

assert(pw != NULL);
/*@-observertrans -statictrans@*/
    return pw;
/*@=observertrans =statictrans@*/
}
Example #19
0
static int key(W_Event *data)
{
  if (data->y == (metaHeight-B_ADD)) return add_key(data);
  if (data->key == 113 || data->key == 196) { /* q or ^d */
    metadone();
    terminate(0);
  } else if (data->key == 114 || data->key == 210) { /* r or ^r */
    refresh();
  } else if (data->key == W_Key_Up) {
    choose(-1);
  } else if (data->key == W_Key_Down) {
    choose(1);
  } else if (data->key == '\r' || data->key == ' ') { /* enter or space */
    if (chosen != -1) return chose(chosen, W_LBUTTON);
  } else if (data->key == 'g') { /* g, for guest */
    if (chosen != -1) return chose(chosen, W_MBUTTON);
  } else if (data->key == 'o') { /* o, for observe */
    if (chosen != -1) return chose(chosen, W_RBUTTON);
  } else if (data->key == 'h') {
    toggle_help();
  } else {
    return button(data);
  }
  return 0;
}
Example #20
0
int receive_tau (void *msg)
{
	msg_s		*m = msg;
	msgbuf_s	*mb;
	packet_s	*p;
	ki_t		k;
	int		rc;

	mb = emalloc(sizeof(msgbuf_s));
	receive_tcp(mb);
//	deq_dq( &Me.pr_msgq, mb, mb_process);
//	if (!mb) return ENOMSGS;

	p = &mb->mb_packet;

	rc = p->pk_error;
	if (rc) return rc;

	k = 0;
	if (p->pk_passed_key.k_id) {
		k = add_key(p->pk_passed_key);
		if (!k) fatal("Out of keys");
	}
	p->pk_sys.q_passed_key = k;
	memmove(m, &p->pk_sys, sizeof(msg_s));
	free(mb);

	return 0;
}
Example #21
0
// keyboard service routine
void keyboard_routine(void) {
  struct list_head *e;
  struct task_struct *t;
  unsigned char c = inb(0x60);
  if ((c & 0x80) == 0) { // make
    char aux = char_map[c&0x7F];
    if (aux != '\0') {
        print_key(aux);
        add_key(aux);
        if (threads_waiting()) {
          //sys_write(1,"esperant",8);
          e = list_first(&key_buffer.keyboardqueue);
          t = list_head_to_task_struct(e);
          if (can_read(t->num_chars_to_read)) {
            sys_write(1,"llegim",6);
            list_del(e);
            list_add_tail(e, &readyqueue);
          }
        }
        //char b[1];
        //itoa(current()->num_chars_to_read,b);
        //sys_write(1,b,1);
        //print_buffer(6);
    }
    else {
      print_key('C');
    }
  }
  else { // break 
    // do nothing
  }
}
Example #22
0
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  switch (id) {
  case SPACE_FN:
    if (record->event.pressed) {
      // Change the keyboard maps.
      // Whatever even layer's are on, turn on the odd one's too.
      for (uint8_t i = 0; i < 9; i += 2) {
        if (layer_state & (1UL << i))
          layer_on(i + 1);
      }
      layer_on(1);
    } else {
      // turn off all the even layers.
      for (uint8_t i = 0; i < 9; i += 2)
        layer_off(i + 1);

      if (record->tap.count != 0) {
        // Space was tapped rather than used like a modifier.
        // So send a space up and down event.
        add_key(KC_SPC);
        send_keyboard_report();
        del_key(KC_SPC);
        send_keyboard_report();
      }
    }
    break;
  }
}
Example #23
0
int create_gate_tau (void *msg)
{
	msg_s		*m = msg;
	static u64	id = 0;
	gate_s		*gate;
	key_s		key;
	ki_t		k;

	gate = ezalloc(sizeof(*gate));
	gate->gt_id      = ++id;
	gate->gt_tag     = m->q.q_tag;
	gate->gt_type    = m->q.q_type;
	gate->gt_avatar = &Me;
	add_gate(gate);
	m->cr_id = gate->gt_id;
	key.k_length   = 0;
	key.k_node     = 0;
	key.k_type     = gate->gt_type;
	key.k_reserved = 0;
	key.k_id       = gate->gt_id;
	k = add_key(key);
	if (!k) fatal("Out of keys");
	m->q.q_passed_key = k;

	return 0;
}
Example #24
0
static int init_key(char *name, int cmd)
{
	int n;
	int sec = 1;

	n = add_key("keyring", name, NULL, 0, KEY_SPEC_THREAD_KEYRING);
	if (n == -1)
		tst_brk(TBROK | TERRNO, "add_key() failed");

	if (cmd == KEYCTL_REVOKE) {
		if (keyctl(cmd, n) == -1) {
			tst_brk(TBROK | TERRNO,	"failed to revoke a key");
		}
	}

	if (cmd == KEYCTL_SET_TIMEOUT) {
		if (keyctl(cmd, n, sec) == -1) {
			tst_brk(TBROK | TERRNO,
				"failed to set timeout for a key");
		}

		sleep(sec + 1);
	}

	return n;
}
Example #25
0
static void 
refresh_callback (SoupSession *session, SoupMessage *msg, SeahorseHKPOperation *hop) 
{
    GList *keys, *k;
    
    if (hop->cancelling)
        return;
    
    if (SOUP_MESSAGE_IS_ERROR (msg)) {
        fail_hkp_operation (hop, msg, NULL);
        return;
    }
    
    keys = parse_hkp_index (msg->response_body->data);
    
    for (k = keys; k; k = g_list_next (k))
        add_key (hop->hsrc, SEAHORSE_PGP_KEY (k->data));
    seahorse_object_list_free (keys);

    if (--hop->requests <= 0)
        seahorse_operation_mark_done (SEAHORSE_OPERATION (hop), FALSE, NULL);
    else
        seahorse_operation_mark_progress_full (SEAHORSE_OPERATION (hop), _("Searching for keys..."), 
                                               hop->requests, hop->total);
}
Example #26
0
/*
	We are adding values to the tree while insterting the to a std::unordered_set 
	as well. Afterwards we compare the set's and the tree's size and check if 
	every key found in the set can be found in the tree as well. 
*/
TEST(LibAvlBasicSanity, validate_with_set)
{
	auto n = TEST_NUMBER;
	while(n--) {
		auto keys_vec = generate_random_keys(TREE_SIZE, MAX_TEST_UINT);
		std::unordered_set<int> keys{};
		auto avl = avl::AvlTree<int>();
		uint quantity = 0;
	    for(auto value : keys_vec) {
	    	if(avl.add_key(value)) {
	    		keys.insert(value);
	    		quantity++;
	    	}
	    	else {
	    		ASSERT_TRUE(avl.find_key(value));
	    	}
	    	validate_bst(avl.get_root());
			ASSERT_EQ(quantity, get_subtree_count(avl.get_root()));
			ASSERT_EQ(quantity, keys.size());
		}
		for(const auto& value : keys_vec) {
			ASSERT_TRUE(avl.find_key(value));
		}
	}
}
Example #27
0
/*
	Function for updating the keyboard buffer and pushing back codes that haven't
	received a break code yet.
*/
void update_input_buffer( UINT8 bTimeElapsed )
{
	UINT8 bIndex = 0;
	int old_ssp = Super( 1 );
	int old_ipl;
	
	if( USER_MODE == old_ssp )
		old_ssp = Super( 0 );
	
	old_ipl = set_ipl( KEYBOARD_INTERRUPT_MASK );
	
	for( bIndex; bIndex < cHotKeyCount; bIndex++ )
	{
		if( cMakeTable[ bHotKeys[ bIndex ] ].bMakeReceived )
		{
			cMakeTable[ bHotKeys[ bIndex ] ].wDuration -= bTimeElapsed;
			
			if( cMakeTable[ bHotKeys[ bIndex ] ].wDuration == 0 || 
				cMakeTable[ bHotKeys[ bIndex ] ].wDuration > STARTING_DURATION )
			{
				add_key( bHotKeys[ bIndex ] );
				cMakeTable[ bHotKeys[ bIndex ] ].wDuration = SUBSEQUENT_DURATION;
			}
		}
	}
	
	set_ipl( old_ipl );
	
	if( SUPER_MODE != old_ssp )
		Super( old_ssp );
}
int ecryptfs_add_auth_tok_to_keyring(struct ecryptfs_auth_tok *auth_tok,
				     char *auth_tok_sig)
{
	int rc;

	rc = (int)keyctl_search(KEY_SPEC_USER_KEYRING, "user", auth_tok_sig, 0);
	if (rc != -1) { /* we already have this key in keyring; we're done */
		rc = 1;
		goto out;
	} else if ((rc == -1) && (errno != ENOKEY)) {
		int errnum = errno;

		syslog(LOG_ERR, "keyctl_search failed: %m errno=[%d]\n",
		       errnum);
		rc = (errnum < 0) ? errnum : errnum * -1;
		goto out;
	}
	rc = add_key("user", auth_tok_sig, (void *)auth_tok,
		     sizeof(struct ecryptfs_auth_tok), KEY_SPEC_USER_KEYRING);
	if (rc == -1) {
		rc = -errno;
		syslog(LOG_ERR, "Error adding key with sig [%s]; rc = [%d] "
		       "\"%m\"\n", auth_tok_sig, rc);
		if (rc == -EDQUOT)
			syslog(LOG_WARNING, "Error adding key to keyring - keyring is full\n");
		goto out;
	}
	rc = 0;
out:
	return rc;
}
Example #29
0
// Sends the HMDP response '302'
// @param connectionfd the socket descriptor of the client
// @param response_list the list of files for the client to upload
void response_302(int connectionfd, csv_record *response_list) {
    
    char *response;                         // The '302' message
    char *list_size;                        // The size of the body of the message
    
    int length;                             // The length of the message
    
    asprintf(&list_size, "%d", get_list_size(response_list));
    
    add_status(&response, STATUS_302);      //  |----------------------|
    add_message(&response, MESSAGE_302);    //  |302 Files requested\n |
    add_key(&response, KEY_LENGTH);         //  |----------------------|
    add_value(&response, list_size);        //  |Length:value\n\n      |
    delimit_header(&response);              //  |----------------------|
    add_body(&response, response_list);     //  |Body:                 |
                                            //  |----------------------|
    length = strlen(response);
    
    // Check to see if the message sent successfully
    if (send_all(connectionfd, response, &length) == -1) {
        
        syslog(LOG_ERR, "Only sent %d bytes\n", length);
        
    } //end if
    
    free(list_size);
    free(response);
    
    list_size = NULL;
    response = NULL;
    
} //end response_302
Example #30
0
PAM_EXTERN int
pam_sm_authenticate(pam_handle_t *pamh, int flags,
		int argc, const char **argv)
{
	int ret;

	char const *user;
	ret = pam_get_item(pamh, PAM_USER, (void const **)&user);
	if (ret != PAM_SUCCESS)
		return PAM_IGNORE;
	int user_len = strlen(user);

	char const *pw;
	ret = pam_get_item(pamh, PAM_AUTHTOK, (void const **)&pw);
	if (ret != PAM_SUCCESS)
		return PAM_IGNORE;
	int pw_len = strlen(pw);

	int key_len = 24;
	char key[24];

	PKCS5_PBKDF2_HMAC_SHA1(pw, pw_len, user, user_len, 1000, key_len, key);
	add_key("user", "login", key, key_len, KEY_SPEC_SESSION_KEYRING);

	return PAM_SUCCESS;
}