anon_server_credentials::anon_server_credentials ():credentials
    (GNUTLS_CRD_ANON)
{
    RETWRAP (gnutls_anon_allocate_server_credentials (&cred));
    set_ptr (cred);
}
示例#2
0
//dereference write to a pointer to int
void PrivPtr::dereference_ptr_write_var(priv_ptr ptr, mpz_t value, int dereferences, mpz_t priv_cond, int threadID)
{
        if(ptr->type != 0)
	{
		printf("WRONG TYPE on the left operator...\n"); 
		exit(1); 
	}
        priv_ptr tmp_ptr;
        priv_ptr copy_ptr = create_ptr(0, 0);
        priv_ptr ptr1 = create_ptr(0, 0);
        set_ptr(ptr1, ptr, threadID);

        if(dereferences > 1)
        {
                reduce_dereferences(ptr1, dereferences, copy_ptr, threadID);
                tmp_ptr = copy_ptr;
        }
        else
                tmp_ptr = ptr;

        int index = 0;
        int size = tmp_ptr->size;
        listnode tmp = tmp_ptr->list->head->next;

        mpz_t* op1 = (mpz_t*)malloc(sizeof(mpz_t) * size);
        mpz_t* op2 = (mpz_t*)malloc(sizeof(mpz_t) * size);
        mpz_t* op3 = (mpz_t*)malloc(sizeof(mpz_t) * size);
        mpz_t* op4 = (mpz_t*)malloc(sizeof(mpz_t) * size);

        for(int i = 0; i < size; i++)
        {
                mpz_init(op1[i]);
                mpz_init(op2[i]);
                mpz_init(op3[i]);
                mpz_init(op4[i]);
        }

        while(tmp != tmp_ptr->list->tail)
        {
                mpz_set(op1[index], *(tmp->u.int_var_location));
                mpz_set(op2[index], tmp->priv_tag);
                if(priv_cond != NULL)
                        mpz_set(op3[index], priv_cond);
                mpz_set(op4[index], value);
                index++;
                tmp = tmp->next;
        }
        /* compute (*location) + tag * priv_cond * (value-(*location)) */
        ss->modSub(op4, op4, op1, size);
        if(priv_cond != NULL)
                Mul->doOperation(op4, op4, op3, size, threadID);
	if(size != 1)
        	Mul->doOperation(op4, op4, op2, size, threadID);
        ss->modAdd(op4, op1, op4, size);
        /* update the values of nodes in the list (not update the tags) */
        tmp = tmp_ptr->list->head->next;
        index = 0;
        while(tmp != tmp_ptr->list->tail)
        {
                mpz_set(*(tmp->u.int_var_location), op4[index++]);
                tmp = tmp->next;
        }
	for(int i = 0; i < size; i++)
        {
                mpz_clear(op1[i]);
                mpz_clear(op2[i]);
                mpz_clear(op3[i]);
                mpz_clear(op4[i]);
        }

        free(op1);
        free(op2);
        free(op3);
        free(op4);

        destroy_ptr(&ptr1);
        destroy_ptr(&copy_ptr);
        return;
}
certificate_credentials::certificate_credentials ():credentials
    (GNUTLS_CRD_CERTIFICATE)
{
    RETWRAP (gnutls_certificate_allocate_credentials (&cred));
    set_ptr (cred);
}
示例#4
0
//dereference read of pointer to float
void PrivPtr::dereference_ptr_read_var(priv_ptr ptr, mpz_t* result, int dereferences, int threadID)
{
        if(ptr->type != 1)
	{
		printf("WRONG TYPE on the left operator...\n"); 
		exit(1); 
	}

        priv_ptr copy_ptr = create_ptr(0, 1);
        priv_ptr ptr1 = create_ptr(0, 1);
        priv_ptr tmp_ptr;
        set_ptr(copy_ptr, ptr, threadID);
        if(dereferences > 1)
        {
                reduce_dereferences(copy_ptr, dereferences, ptr1, threadID);
                tmp_ptr = ptr1;
        }
        else
                tmp_ptr = ptr;

        int size = tmp_ptr->size;
        int index = 0;
        listnode tmp = tmp_ptr->list->head->next;

	if(size == 1)
	{ 
		for(int i = 0; i < 4; i++)
			mpz_set(result[i], (*(tmp->u.float_var_location))[i]); 
		return; 
	}

        mpz_t* op1 = (mpz_t*)malloc(sizeof(mpz_t) * 4 * size);
        mpz_t* op2 = (mpz_t*)malloc(sizeof(mpz_t) * 4 * size);
        mpz_t* product = (mpz_t*)malloc(sizeof(mpz_t) * 4 * size);
        for(int i = 0; i < 4 * size; i++)
        {
                mpz_init(op1[i]);
                mpz_init(op2[i]);
                mpz_init(product[i]);
        }
        while(tmp != tmp_ptr->list->tail)
        {
                for(int i = 0; i < 4; i++)
                {
                        mpz_set(op1[4*index+i], (*(tmp->u.float_var_location))[i]);
                        mpz_set(op2[4*index+i], tmp->priv_tag);
                        mpz_set_ui(product[4*index+i], 0);
                }
                index++;
                tmp = tmp->next;
        }
        Mul->doOperation(product, op1, op2, 4 * size, threadID);
        for(int i = 0; i < 4; i++)
            mpz_set_ui(result[i], 0);

        for(int i = 0; i < size; i++)
            for(int j = 0; j <  4; j++)
                ss->modAdd(result[j], result[j], product[4*i+j]);
        for(int i = 0; i < 4 * size; i++)
        {
                mpz_clear(op1[i]);
                mpz_clear(op2[i]);
                mpz_clear(product[i]);
        }
        free(op1);
        free(op2);
        free(product);
        destroy_ptr(&copy_ptr);
        destroy_ptr(&ptr1);
}