void add_to_db(attribute_db* db, attribute* att) { int i; attribute* temp = (attribute* ) malloc(sizeof(attribute) * (db->db + 1)); for (i = 0; i < db->db; ++i) { attribute_copy(temp + i, db->attributes + i); } attribute_copy(temp + i, att); free(db->attributes); db->attributes = temp; db->db += 1; }
//AtkAttributeSet AtkAttributeSet* attribute_set_copy(AtkAttributeSet* attr) { GSList *tmp; AtkAttributeSet* result = g_slist_copy(attr); for(tmp = result; tmp != NULL; tmp = tmp->next) tmp->data = attribute_copy((AtkAttribute*)tmp->data); return result; }
void attribute_from_pk (attribute* att, public_key pk ) { public_key dm_pk; dm_pk.ID_tuple = pk.ID_tuple; dm_pk.level = pk.level - 1; domain_manager* dm = dm_from_publickey(dm_pk); if(dm == NULL) { att->name = NULL; att->DM.ID_tuple = NULL; att->DM.level = 0; } int i; for(i = 0; i < dm->number_of_attributes; ++i) { if(pkcomp(dm->attributes[i].DM, pk)) { attribute_copy(att, dm->attributes + i); } } }
// just in user_add_attribute useable void add_attribute( user_secret_key * out, public_key pk, public_key att) { //trick it s just a fake public_key public_key par_pk; par_pk.ID_tuple = att.ID_tuple; par_pk.level = att.level - 1; public_key_copy(&(out->pk), &par_pk); domain_manager* par = dm_from_publickey(par_pk); Q_tuple SK_u; generate_SK_u(&SK_u,par, pk); // free_Q_tuple(out->Q_tuple); element_t SK_a; generate_SK_ua(&SK_a, par, pk, att); out-> SK_a = (element_t* ) malloc( sizeof(element_t)); out->number_of_attributes = 1; element_init_G1(out->SK_a[0], pairing); element_set(out->SK_a[0], SK_a); element_clear(SK_a); out->Q_tuple = SK_u; attribute temp; attribute_from_pk(&temp, att); out->attribute = (attribute*) malloc(sizeof(attribute)); attribute_copy(out->attribute, &temp); free_attribute(temp); }