示例#1
0
Combinaison* getCombinaisonsNumbersLevel(Combinaison* previous_level, int niveau, int nb_colonnes)
{
	Combinaison* courant_combi = previous_level;
	Combinaison* dump = NULL;
	Combinaison* parcours;
	Entier* temp_tuple;
	Entier* temp_ot;
	int i, x;

	while (courant_combi != NULL)
	{
		x = get_last_tuple_value(courant_combi->combi);
		for (i=x+1; i<nb_colonnes; i++)
		{
			// dupliquer pour ne pas écraser l'ancienne combinaison
			temp_tuple = copie_tuple(courant_combi->combi);
			temp_ot = (Entier*)malloc(sizeof(Entier));
			temp_ot->val = i;
			temp_ot->suiv = NULL;
			temp_tuple = append_tuple(temp_tuple, temp_ot);
			dump = appendElementCombinaison(dump, temp_tuple);
		}
		courant_combi = courant_combi->suiv;
	}

	return dump;
}
示例#2
0
文件: be-encfs.c 项目: 0ndorio/gnupg
/* Create a new session key and append it as a tuple to the memory
   buffer MB.

   The EncFS daemon takes a passphrase from stdin and internally
   mangles it by means of some KDF from OpenSSL.  We want to store a
   binary key but we need to make sure that certain characters are not
   used because the EncFS utility reads it from stdin and obviously
   acts on some of the characters.  This we replace CR (in case of an
   MSDOS version of EncFS), LF (the delimiter used by EncFS) and Nul
   (because it is unlikely to work).  We use 32 bytes (256 bit)
   because that is sufficient for the largest cipher (AES-256) and in
   addition gives enough margin for a possible entropy degradation by
   the KDF.  */
gpg_error_t
be_encfs_create_new_keys (membuf_t *mb)
{
  char *buffer;
  int i, j;

  /* Allocate a buffer of 32 bytes plus 8 spare bytes we may need to
     replace the unwanted values.  */
  buffer = xtrymalloc_secure (32+8);
  if (!buffer)
    return gpg_error_from_syserror ();

  /* Randomize the buffer.  STRONG random should be enough as it is a
     good compromise between security and performance.  The
     anticipated usage of this tool is the quite often creation of new
     containers and thus this should not deplete the system's entropy
     tool too much.  */
  gcry_randomize (buffer, 32+8, GCRY_STRONG_RANDOM);
  for (i=j=0; i < 32; i++)
    {
      if (buffer[i] == '\r' || buffer[i] == '\n' || buffer[i] == 0 )
        {
          /* Replace.  */
          if (j == 8)
            {
              /* Need to get more random.  */
              gcry_randomize (buffer+32, 8, GCRY_STRONG_RANDOM);
              j = 0;
            }
          buffer[i] = buffer[32+j];
          j++;
        }
    }

  /* Store the key.  */
  append_tuple (mb, KEYBLOB_TAG_ENCKEY, buffer, 32);

  /* Free the temporary buffer.  */
  wipememory (buffer, 32+8);  /*  A failsafe extra wiping.  */
  xfree (buffer);

  return 0;
}
示例#3
0
CodeVar* ASTFactory::
build_codeRef(CvarSymbolTable::Entry e, POETCode* args, POETCode* attr)
     {
     POETCode* pars=e.get_param();
     if (pars != 0 && args != 0) {
        e.get_symTable()->push_table(false);
        if (!match_parameters(pars, args, MATCH_PAR_MOD_CODE))
             CVAR_MISMATCH(e.get_name(), pars, args);
     }
     int size = e.attr_size();
     if (size > 0 && attr == 0) {
        if (size == 1) attr = eval_AST(e.get_attr(0)->get_entry().get_code());
        else { 
            attr = new_pair(eval_AST(e.get_attr(0)->get_entry().get_code()), 
                       eval_AST(e.get_attr(1)->get_entry().get_code()));
            for (int i = 2; i < size; ++i) 
               attr = append_tuple(attr, 
                    eval_AST(e.get_attr(i)->get_entry().get_code()));
         }
     }
     if (pars != 0 && args != 0) e.get_symTable()->pop_table();
     CvarTable* m = get_cvarTable(e);
     return static_cast<CodeVar*>(m->new_item(args, attr));
   }
示例#4
0
 message_builder& append_tuple(std::tuple<Ts...> xs) {
   append_tuple(std::integral_constant<size_t, 0>{},
                std::integral_constant<size_t, sizeof...(Ts)>{}, xs);
 }
示例#5
0
 message_builder& append_tuple(std::integral_constant<size_t, I>,
                               std::integral_constant<size_t, N> e,
                               std::tuple<Ts...>& xs) {
   append(std::move(std::get<I>(xs)));
   append_tuple(std::integral_constant<size_t, I + 1>{}, e, xs);
 }
示例#6
0
Dependancies* dependances(Set_Of_Attrs* agree, Line_data* tab_data, int nb_lignes, int nb_colonnes)
{
	Dependancies* dump = NULL;
	Dependancies* temp_dep;
	Dependancies* param;
	Set_Of_Attrs* courant_agree = agree;
	Chaine* courant_chaine;
	Entier* temp_tuple;
	Entier* tuples;
	Couples* couples = NULL;
	Couples* courant_couple;
	Chaine* determinant;
	Chaine* soumis;

	while (courant_agree != NULL)
	{
		courant_chaine = courant_agree->attributs;
		if (taille_chaine(courant_chaine) >= 2)
		{
			tuples = NULL;
			while (courant_chaine != NULL)
			{
				temp_tuple = (Entier*)malloc(sizeof(Entier));
				temp_tuple->val = colonne(courant_chaine->attribut, tab_data, nb_colonnes);
				temp_tuple->suiv = NULL;
				tuples = append_tuple(tuples, temp_tuple);
				courant_chaine = courant_chaine->suiv;
			}
			couples = getCouplesCombinaisons(tuples);
			courant_couple = couples;
			// Pour les dépendances fonctionnelles élémentaires
			while (courant_couple != NULL)
			{
				if (dependanceFonctionnelle(courant_couple->cpl[0], courant_couple->cpl[1], tab_data, nb_lignes) )
				{
					determinant = (Chaine*)malloc(sizeof(Chaine));
					determinant->attribut = (char*)malloc(sizeof(char)*NMAX);
					strcpy( determinant->attribut, attribut(courant_couple->cpl[0], tab_data));
					determinant->suiv = NULL;
					soumis = (Chaine*)malloc(sizeof(Chaine));
					soumis->attribut = (char*)malloc(sizeof(char)*NMAX);
					strcpy( soumis->attribut, attribut(courant_couple->cpl[1], tab_data));
					soumis->suiv = NULL;
					temp_dep = createCellDependance(determinant, soumis);
					dump = appendDependance(dump, temp_dep);
				}
				if (dependanceFonctionnelle(courant_couple->cpl[1], courant_couple->cpl[0], tab_data, nb_lignes) )
				{
					determinant = (Chaine*)malloc(sizeof(Chaine));
					determinant->attribut = (char*)malloc(sizeof(char)*NMAX);
					strcpy( determinant->attribut, attribut(courant_couple->cpl[1], tab_data));
					determinant->suiv = NULL;
					soumis = (Chaine*)malloc(sizeof(Chaine));
					soumis->attribut = (char*)malloc(sizeof(char)*NMAX);
					strcpy( soumis->attribut, attribut(courant_couple->cpl[0], tab_data));
					soumis->suiv = NULL;
					temp_dep = createCellDependance(determinant, soumis);
					dump = appendDependance(dump, temp_dep);
				}
				courant_couple = courant_couple->suiv;
			}
		}
		courant_agree = courant_agree->suiv;
	}
	return dump;
}