近代密码学---IT实验01--RSA实现.docx
《近代密码学---IT实验01--RSA实现.docx》由会员分享,可在线阅读,更多相关《近代密码学---IT实验01--RSA实现.docx(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、云南大学数学与统计学实验教学中心实验报告课程名称:近代密码学年级:2010级上机实践成绩:指导教师:陆正福姓名:段飞龙上机实践名称:RSA实现学号:20101910050上机实践日期:上机实践编号:No. 1组号:上机实践时间:一、实验目的配置gmp环境,并对其进行测试; 通过gmp实现RSA加密、解密。二、实验内容1、配置gmp环境,并对其进行测试;2、编程实现RSA非对称密码算法。三、实验环境Ubuntu VC四、实验结果1.对gmp的测试结果如下:1)对加法运算进行测试的结果:the n is 1the sum is 0the n is 101the sum is 338350the n
2、 is 1001the sum is 333833500the n is 10001the sum is 333383335000the n is 100001the sum is 333338333350000the n is 1000001the sum is 333333833333500000the n is 10000001the sum is 333333383333335000000the n is 100000001the sum is 333333338333333350000000the n is 1000000001the sum is 33333333383333333
3、35000000002)对乘法运算进行测试的结果:1234567823456789the result is 289589963907942.2.测试输入的字符串为最大长度(在此例中取最大长度为:10)的字符串时的结果:Input maxlength of message: I()Main menu:int flag,flagl;charch,flagchar;unsigned int L=OJ=O;mpz_t d,e,n,c,cin;mpz_init(d);mpz_init(e);mpz_init(ii);mpz_init(c);mpz_init(cin);printf(HInput max
4、length of message:H);scanf(n%uH,&L);getchar();/l=100;RSA_gmp(&d,&e,&n,L);while (1)(flagl=l;printf(HMain menu:nH);printf(ntl Encryption!nH);printf(Ht2 Deciphering!nH);printf(nt3 Out put the secret key of encryption !nH);printf(nt4 Out put the secret key of deciphering !nH);printf(Ht0 Exit!nn);printf(
5、HInput your option:);scanf(H%d,&flag);getchar();m=(char *)malloc(sizeof(char)*(L+l);switch (flag)(case 1: printf(HInput a message:nM);i=l;while(l)scanf(n%cn,&ch);if(ch != An!) mO=ch;break;else printf(nThe message can not empty!nlnput a message:nn);scanf(H%cH,&ch);while(ch != n)mi+=ch;scanf(n %cM,&ch
6、);)mi=,0,;l=strlen(m);encryption(m9d9n9&cj);gmp_printf(*1 The ciphertext is c:n%ZdnH,c);break;case 2: printf(nInput the ciphertext八n);gmp_scanf(n%Zdn,&cin);getchar();deciphering(m,e,n,c,81); / Need exchange 1break;case 3: printf(HThe secret key of encryption is (d,n):nH);gmp_printf(H% Zd,n % Zdn ” ,
7、d,n);break;case 4: printf(nThe secret key of decipering is (e,n):nH);gmp_printf(H% Zd,n % Zdn *e,n);break;case 0: flagl=0;break;default:printf(nError data!nn);break;if (flagl = 0) break;六、教师评语:1 Encryption!2 Deciphering!3 Out put the secret key of encryption !4 Out put the secret key of deciphering
8、!0 Exit!Input your option:3The secret key of encryption is (d,n):Main menu:1 Encryption!2 Deciphering!3 Out put the secret key of encryption !4 Out put the secret key of deciphering !0 Exit!Input your option:4The secret key of decipering is (e,n):Main menu:1 Encryption!2 Deciphering!3 Out put the se
9、cret key of encryption !4 Out put the secret key of deciphering !0 Exit!Input your option: 1Input a message:1234567890The ciphertext is c: Main menu:1 Encryption!2 Deciphering!3 Out put the secret key of encryption !4 Out put the secret key of deciphering !0 Exit!Input your option:?Input the ciphert
10、ext:message is 1234567890Main menu:1 Encryption!2| Deciphering!3 Out put the secret key of encryption !4 Out put the secret key of deciphering !0 Exit!Input your option:()3.测试输入的字符串小于最大长度(在此例中取最大长度为:50)的字符串时的结果:Input maxlength of message:5()Main menu:1 Encryption!2| Deciphering!3 Out put the secret
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 近代 密码学 IT 实验 01 RSA 实现
限制150内