Esempio n. 1
0
void		padding(t_lst **lst, t_pad *pad)
{
	t_lst	*tmp;

	tmp = *lst;
	init_pad(pad, lst);
	while (tmp->next)
	{
		if (pad->len_usr < ft_strlen(tmp->next->user_id))
			pad->len_usr = ft_strlen(tmp->next->user_id);
		if (pad->len_grp < ft_strlen(tmp->next->group_id))
			pad->len_grp = ft_strlen(tmp->next->group_id);
		if (pad->len_lnk < ft_strlen(tmp->next->link))
			pad->len_lnk = ft_strlen(tmp->next->link);
		if (pad->len_siz < ft_strlen(tmp->next->size))
			pad->len_siz = ft_strlen(tmp->next->size);
		if (pad->len_maj < ft_strlen(tmp->next->maj))
			pad->len_maj = ft_strlen(tmp->next->maj);
		if (pad->len_min < ft_strlen(tmp->next->min))
			pad->len_min = ft_strlen(tmp->next->min);
		tmp = tmp->next;
	}
	pad->len_majmin = pad->len_maj + pad->len_min;
	apply_padding(pad, lst);
}
Esempio n. 2
0
static t_level	*init_level(void)
{
	t_level	*level;

	level = (t_level *)ft_memalloc(sizeof(t_level));
	if (!level)
		exit(EXIT_FAILURE);
	level->active_bricks = 0;
	level->score = INIT_SCORE;
	level->lives = INIT_LIVES;
	level->brick_list = NULL;
	level->ball = init_ball();
	level->pad = init_pad();
	return (level);
}
Esempio n. 3
0
File: hmac.c Progetto: radcli/radcli
/**
 * HMAC MD5 algorithm (RFC-2104)
 *
 * @author mbelanger (12/14/16)
 *
 * @param data - pointer to data to be processed
 * @param data_len - length of data
 * @param key - pointer to key
 * @param key_len - length of key
 * @param digest - caller digest to be filled in
 */
void hmac_md5(uint8_t *data, size_t data_len,
              uint8_t *key,  size_t key_len, uint8_t *digest)
{
    MD5_CTX         context;
    struct padding  pad;

    init_pad(&pad, key, key_len);

    /* inner MD5 */
    MD5Init(&context);
    MD5Update(&context, pad.inner, 64);
    MD5Update(&context, data, data_len);
    MD5Final(digest, &context);

    /* outer MD5 */
    MD5Init(&context);
    MD5Update(&context, pad.outer, 64);
    MD5Update(&context, digest, 16);
    MD5Final(digest, &context);
}