segmentation error while using mpz_powm in a loop
shrims . .... ..
shrims4u at gmail.com
Fri May 8 08:35:20 CEST 2009
I am getting segmentation fault in the program below.
I have initialised all the GMP variables properly...
But still i am getting segmentation fault at *mpz_powm( );
*The loop runs only once and second time it gives segmentation fault at
mpz_powm...
*
The code is as follows:
**mpz_t bigbody,encbody,decbody,n,d,e;
mpz_init(bigbody);
mpz_init(decbody);
while(i<noOfBlocks)
{
strncpy(substring, data_buffer + lower, upper);
*(substring+308)='\0';
lower=upper;
upper=upper+308;
i++;
mpz_set_str(bigbody,substring,10);
//size=len;
mpz_powm (decbody, bigbody, d, n);
}
The again i tried to use arrays but this time the loop runs for 2 times and
then gives segmentation fault...
The code is as follows..
mpz_t array[10];
//mpz_array_init (array, 10, 308);
mpz_t array1[10];
//mpz_array_init (array1, 10, 308);
while(i<noOfBlocks)
{
strncpy(substring, data_buffer + lower, upper);
lower=upper;
upper=upper+308;
mpz_init_set_str(array[i],substring,10);
mpz_get_str (STR, 10, array[i]);
strcat(STR,"\0");
syslog( LOG_INFO, "conn# %d - Encrypted-Biginteger = %s",
cd->connection_num, STR );
mpz_init(array1[i]);
mpz_powm (array1[i], array[i], d, n);
}
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gmplib.org/list-archives/gmp-bugs/attachments/20090508/d2903a9a/attachment-0001.html>
More information about the gmp-bugs
mailing list