大整数乘法的实现与分析(毕业文代码)
大整数乘法的实现与分析
摘 要
随着计算机信息安全要求的不断提高,密码学被大量应用到生活中。RSA、ElGamal、DSA、ECC Abstract
Nowadays, as computer information security requirements improve continuously, the cryptology has been widely applied to life. Public key cryptographic algorithms and digital signature algorithms such as RSA, ElGamal, DSA, ECC are all base on multiple precision arithmetic. Multiple precision multiplication, Division, modular multiplication ,exponen- tiation, modular exponentiation which need more working time is used by public key cryptographic algorithms widely, their speed is very important to the implementations of those algorithms. How to fast implement those arithmetic above is the hot topic in the public key cryptographic field.
This paper is based on the 32 bit system. First of all, we found the modular foundation of multiple precision arithmetic library; After some auxiliary function is formed, we discuss and implement the multiple precision integer basic addition, Subtraction,multiplication, , kinds of square algorithms,division,reduction, and some relational function. All the algorithm discuss in this paper is implement entirely in portable ISO C/C++and the optimization of those algorithms implementations is built on the C/C++ language level. the algorithm has high enough to ensure the efficiency of the code at the same time strive to clearly understand, simple interface function with portability and stability.
Key words: Multiple Precision Integer,Comba,Montgomery,Binary search,
Written calculation
目录
1 绪论1
1.1题目的背景1
1.2国内外研究状况1
1.3本文研究内容2
2大整数的结构3
2.1大整数的存取结构3
2.1.1大整数结构分析3
2.1.2大整数结构4
2.2预定义的变量5
2.3大整数基本函数定义5
2.3.1大整数初始化操作5
2.3.2大整数的销毁操作6
2.3.3大整数的扩展6
2.3.4大整数的输入和输出函数6
2.4大整数的移位函数7
2.4.1字移位运算7
2.4.2比特移位运算9
3大整数加法和减法实现13
3.1符号相同的加法运算13
3.2符号不相同的加法运算16
4大整数乘法实现19
4.1 笔算乘法19
4.2使用Comba方法的快速乘法22
4.3平方算法24
4.3.1笔算平方算法25
4.3.2 Comba思想的平方算法27
5大整数模缩减实现30
5.1模2的幂30
5.2 Barrett缩减31
5.3 Montgomery缩减33
6大整数除法实现37
6.1使用减法替换除法运算37
6.2模拟笔算除法38
7大整数幂