/* * Program to decode message using RSA private key. * * **** For Demonstration use only ****** * */ #include #include "miracl.h" #include #include #define NP 2 /* two primes - could be used with more */ miracl *mip; void strip(char *name) { /* strip extension off filename */ int i; for (i=0;name[i]!='\0';i++) { if (name[i]!='.') continue; name[i]='\0'; break; } } int main() { /* decode using private key */ int i; big e,ep[NP],m,ke,kd,p[NP],kp[NP],mn,mx; FILE *ifile; FILE *ofile; char ifname[13],ofname[13]; BOOL flo; big_chinese ch; mip=mirsys(100,0); for (i=0;iIOBASE=16; if ((ifile=fopen("private.key","rt"))==NULL) { printf("Unable to open file private.key\n"); return 0; } for (i=0;iIOBASE=16; cinnum(m,ifile); if (size(m)==0) break; for (i=0;i=0) divide(e,mn,mn); mip->IOBASE=128; if (flo) cotnum(e,ofile); cotnum(e,stdout); } crt_end(&ch); fclose(ifile); if (flo) fclose(ofile); printf("message ends\n"); return 0; }