Click here to Skip to main content
15,559,567 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MFC - Drawning Bitmaps Transparent Pin
Stuart Dootson8-May-09 5:18
professionalStuart Dootson8-May-09 5:18 
GeneralRe: MFC - Drawning Bitmaps Transparent Pin
Praystation28-May-09 5:27
Praystation28-May-09 5:27 
GeneralRe: MFC - Drawning Bitmaps Transparent Pin
Stuart Dootson8-May-09 5:54
professionalStuart Dootson8-May-09 5:54 
GeneralRe: MFC - Drawning Bitmaps Transparent Pin
Praystation28-May-09 6:11
Praystation28-May-09 6:11 
AnswerRe: MFC - Drawning Bitmaps Transparent Pin
Madhu Nair8-May-09 6:21
Madhu Nair8-May-09 6:21 
GeneralRe: MFC - Drawning Bitmaps Transparent Pin
Praystation28-May-09 6:35
Praystation28-May-09 6:35 
GeneralRe: MFC - Drawning Bitmaps Transparent Pin
Stuart Dootson8-May-09 6:34
professionalStuart Dootson8-May-09 6:34 
Questionsegmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 4:40
shrims4u8-May-09 4:40 
i am writing a milter which decrypts the email message.
For decryption i am using GMP library...

The code which gives the error is as follows:


mpz_t bigbody,encbody,decbody,n,d,e;



mpz_init_set_str (e, "5", 10);

mpz_init_set_str (n, "81072118814004638617775947138239917744589505176471539666269773100315781097546894455560658571445286325125766632676152452856383447352821337178984474781813475276075048299705214136395672502245955793627681061360075723595075874516950614187016991430293887968216015097675955399134514678660046996064181098182893072761", 10);

mpz_init_set_str (d, "32428847525601855447110378855295967097835802070588615866507909240126312439018757782224263428578114530050306653070460981142553378941128534871593789912725382636961637010791821646038659077539848411532121133465246631106852802485583932352673149866783600963924490576147444236696494852521901563664557493382382127469", 10);



char *STR;
STR=(char*)malloc(1000);




mpz_t array[10];
//mpz_array_init (array, 10, 308);
mpz_t array1[10];
//mpz_array_init (array1, 10, 100000);

char substring[400];
int i=0,lower=0,upper=308;

while(i<noofblocks)
{

="" strncpy(substring,="" data_buffer="" +="" lower,="" upper);
="" *(substring+308)="\0" ;
="" syslog(="" log_info,="" "conn#="" %d="" -="" substring="%s"," cd-="">connection_num, substring );

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);

mpz_get_str (STR, 10, array1[i]);
syslog( LOG_INFO, "conn# %d - Decrypted-Biginteger = %s", cd->connection_num, STR );

size_t length;
void *ret;
char *decrypted;
decrypted=(char*)malloc(1000);

ret=mpz_export (decrypted, &length, 1,sizeof(data_buffer[0]), 0, 0, array1[i]);
//ret=mpz_export (decrypted, &length, 1,sizeof(data_buffer[0]), 0, 0, array1[i]);

strncpy(decrypted,ret,length);
*(decrypted+length)='\0';


syslog( LOG_INFO, "conn# %d - size decrypted = %d Decrypted = %s", cd->connection_num,length, (char *)ret );
fflush(stdout);


free(decrypted);
fflush(stdin);
mpz_clear(array[i]);
mpz_clear(array1[i]);
i++;

}

This code executes for 2 iterations and then give segmentation fault at mpz_powm( )
QuestionRe: segmentation error while using mpz_powm in a loop Pin
David Crow8-May-09 4:44
David Crow8-May-09 4:44 
AnswerRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 4:48
shrims4u8-May-09 4:48 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
David Crow8-May-09 4:52
David Crow8-May-09 4:52 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 4:59
shrims4u8-May-09 4:59 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
molesworth8-May-09 6:35
molesworth8-May-09 6:35 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 7:00
shrims4u8-May-09 7:00 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 7:12
shrims4u8-May-09 7:12 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
molesworth8-May-09 9:53
molesworth8-May-09 9:53 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 5:02
shrims4u8-May-09 5:02 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
jeron18-May-09 6:05
jeron18-May-09 6:05 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 6:57
shrims4u8-May-09 6:57 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
jeron18-May-09 7:02
jeron18-May-09 7:02 
GeneralRe: segmentation error while using mpz_powm in a loop Pin
shrims4u8-May-09 7:10
shrims4u8-May-09 7:10 
Questionhow to code its`?so hard if we use OOP Pin
trongduy8-May-09 4:30
trongduy8-May-09 4:30 
AnswerRe: how to code its`?so hard if we use OOP Pin
Stuart Dootson8-May-09 4:41
professionalStuart Dootson8-May-09 4:41 
AnswerRe: how to code its`?so hard if we use OOP Pin
David Crow8-May-09 4:41
David Crow8-May-09 4:41 
AnswerRe: how to code its`?so hard if we use OOP Pin
Michael Schubert8-May-09 9:05
Michael Schubert8-May-09 9:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.