CN105515770A - Improved method for quickly generating big prime number - Google Patents

Improved method for quickly generating big prime number Download PDF

Info

Publication number
CN105515770A
CN105515770A CN201510814575.1A CN201510814575A CN105515770A CN 105515770 A CN105515770 A CN 105515770A CN 201510814575 A CN201510814575 A CN 201510814575A CN 105515770 A CN105515770 A CN 105515770A
Authority
CN
China
Prior art keywords
prime
big
integer
algorithm
prime number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510814575.1A
Other languages
Chinese (zh)
Inventor
叶宁
梁成良
林巧民
王汝传
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Post and Telecommunication University
Nanjing University of Posts and Telecommunications
Original Assignee
Nanjing Post and Telecommunication University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Post and Telecommunication University filed Critical Nanjing Post and Telecommunication University
Priority to CN201510814575.1A priority Critical patent/CN105515770A/en
Publication of CN105515770A publication Critical patent/CN105515770A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/30Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy
    • H04L9/3006Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy underlying computational problems or public-key parameters
    • H04L9/302Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy underlying computational problems or public-key parameters involving the integer factorization problem, e.g. RSA or quadratic sieve [QS] schemes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Complex Calculations (AREA)

Abstract

The invention discloses an improved method for quickly generating a big prime number, and the method can quickly generate the big prime number, is based on a Miller-Rabin prime number detection algorithm, has an additional preprocessing process, and employs a Montgomery modular multiplication algorithm to optimize the original detection of the prime number through the Miller-Rabin prime number detection algorithm. The Montgomery modular multiplication algorithm employs a method of modular addition right shift, effectively avoids the time-consuming division operation in a modular solving operation, reduces the number of times of modular exponentiation operation in an original algorithm, and greatly improves the detection speed of the prime number.

Description

A kind of method of quick generating big prime of improvement
Technical field
The present invention relates to a kind of method of quick generating big prime of improvement, belong to the technical field of information security.
Background technology
Asymmetric cryptosystem is also referred to as public encryption system, and this system is suggested for the defect of DSE arithmetic.In public key encryp, encryption and decryption are relatively independent, and encryption and decryption use two different keys.One of them key is referred to as public-key cryptography (abbreviation PKI) disclosed in being, for encryption; Another key for user special, because of but maintain secrecy, be referred to as privacy key (being called for short secret key), for deciphering.Therefore public-key cryptosystem is also referred to as conbined public or double key cryptographic system, and it revolutionizes original encryption principle, and really making the communicating pair of not knowing each other mutually securely communicate on a unsafe channel finally becomes possibility.
PKI RSA cryptographic algorithms is the international standard in asymmetry sampling, and it is only being widely accepted and the general rivest, shamir, adelman realized.The secret principle of this cryptographic algorithm is the difficulty based on big integer Factorization, that is in mathematics, it is very easy that two Big prime are multiplied, but it is but very difficult to carry out factorization to the result of its product again, therefore RSA cryptographic algorithms is open by the product of these two Big prime, as the encryption key of algorithm.The core of RSA Algorithm is the Montgomery Algorithm of big integer.
Cloud storage is a kind of ideal style that Future Information stores, it is provided convenience easy-to-use memory space, but problem of data safety is cloud stores the biggest obstacle in popularizing, because the data in cloud stores inevitably relate to private (as individual mail, phone etc.) and company's secret (as customer list, business memorandum etc.).Therefore cloud storage security is the emphasis that cloud stores research always.In storing for cloud, the problem of lightweight data security, can adopt DEA to be encrypted and then to store thus ensure the confidentiality of data.
Because PKI RSA cryptographic algorithms both may be used for data encryption, may be used in digital signature again, so it has a wide range of applications.But along with the continuous research for large number decomposition technique, the number making people to decompose is increasing, and in order to improve the fail safe of RSA Algorithm, the length of its key also increases thereupon.And method provided by the invention can generating big prime fast, increase the length of RSA key, improve the fail safe of RSA Algorithm, and then can ensure that encrypted data is stored in the confidentiality in cloud storage system.
Summary of the invention
The object of the invention be to provide a kind of can the method for generating big prime fast, this method solve the length increasing RSA key, to improve the problem of the fail safe of RSA cryptographic algorithms, ensure that and be stored in Information Security in cloud storage system and the efficiency of generating big prime and the efficiency of RSA encryption and decryption.
The present invention solves the technical scheme that its technical problem takes: a kind of method of quick generating big prime of improvement, the method can generating big prime fast, based on Miller-Rabin prime number examination algorithm, by adding preprocessing process, and Montgomery modular multiplication algorithm is adopted to be optimized former Miller-Rabin algorithm detection prime number.What Montgomery modular multiplication algorithm adopted is that mould adds the method moved to right, and efficiently avoid and asks division arithmetic more consuming time in modular arithmetic, decrease the number of times of Montgomery Algorithm in former algorithm, thus substantially increase the detection speed for prime number.
Method flow:
Step 1: first stochastic generation specifies the big integer of figure place:
Step 1-1: define an array, the scope of each element wherein in array is 0 ~ 0xFFFFFFFF;
Step 1-2: take time as random seed;
Step 1-3: the number on each element in the generation array circulating random;
Step 1-4: after circulation terminates, make the element of highest order and 0x80000000 carry out step-by-step or computing, the highest order making the big integer produced is 1, namely ensures the figure place of large number.
Step 2: preliminary treatment is carried out to the stochastic larger integer produced:
Step 2-1: this big integer and integer 1 are carried out step-by-step or computing, ensures that it is an odd number;
Step 2-2: judge that can this odd number be divided exactly by integer 5;
Step 2-3: if can, then on the basis of this odd number, add the number in predefined table of primes PrimeTableB [N] (as shown in table 1), forward step 2-1 to;
Step 2-4: if can not, then forward step 2-5 to;
Step 2-5: judge that can this big integer divide exactly the prime number in predefine table of primes PrimeTableA [M] (as shown in table 1);
Step 2-6: if aliquot, then illustrate that the big integer of generation is not prime number, the basis of this big integer number adds the number in predefined table of primes PrimeTableB [N], forwards step 2-1 to;
Step 2-7: if prime numbers all in this big integer aliquant predefine table of primes PrimeTableA [M], then illustrate that it may be prime number, forward step 3 to;
Step 3: to the Miller-Rabin algorithm detection carrying out 5 times in step 2 through pretreated big integer; Step 4: if all pass through for 5 times to detect, then this big integer is exactly prime number, forwards step 6 to;
Step 5: if not by detecting, then add the number in predefined table of primes PrimeTableB [N] on the basis of this big integer number, forward step 2 to;
Step 6: preserve and export this Big prime.
What the present invention adopted is that prime number element in predefine table of primes PrimeTableB is searched for as the increment of random increase.
The present invention is applied to the key length increasing RSA Algorithm, and the method can improve RSA fail safe, ensure that the confidentiality of encrypted data.
Beneficial effect:
1, the present invention can generating big prime fast, increases the length of RSA key, improves the fail safe of RSA Algorithm, and then ensure that encrypted data is stored in the confidentiality in cloud storage system.
2, the present invention is on Miller-Rabin prime number examination algorithm basis, by introducing preprocessing process, and adopt Montgomery modular multiplication algorithm to detect prime number to former Miller-Rabin algorithm to be optimized, the number of times of Montgomery Algorithm in former algorithm can be decreased.
3, the present invention can improve the detection speed of prime number, and this clear thinking, simple, is easy to realize.
Accompanying drawing explanation
Fig. 1 is method flow diagram of the present invention.
Fig. 2 is the flow chart producing stochastic larger integer.
Fig. 3 is the pretreated flow chart of the present invention.
Fig. 4 is the schematic flow sheet of Miller-Rabin prime number examination algorithm.
Embodiment
Below in conjunction with Figure of description, the invention is described in further detail.
As shown in Figure 1, generate corresponding big integer by according to the figure place of specifying (for 1024) when the present invention starts, PrimeTableB [N] and PrimeTableA [M] are similar, are all one-dimension array, just dimension N is larger than M, as shown in table 1.
Table 1
PrimeTableA[M]=
3 7 11 13 17 19 23 29 31 37 41 43 47
53 59 61 67 71 73 79 83 89 97 101 103 107
109 113 127 131 137 139 149 151 157 163 167 173 179
181 191 193 197 199 211 223 227 229 233 239 241 251
Idiographic flow of the present invention as shown in Figure 2, comprising:
(1) first, need the array Array (that is: the present invention is for the operating system of 32) first defining a unsignedlong type, the length length of array is traditionally arranged to be the figure place of generation divided by 32, preferably be greater than this length, it is 32 that the present invention here arranges length;
(2) take time as random seed srand ((int) time (0)), ensure that each random number produced is different;
(3) circulation produces random number, the elements A rray [0 of composition array Array ... 31];
(4) after circulation terminates, make last elements A rray of array [31] and carry out step-by-step or computing with 0x80000000, the highest order making the big integer produced is 1;
Like this, the present invention just creates the big integer of 1024.Next, need to carry out preliminary treatment to the random big integer produced, as shown in scheme 3:
(1) first, this big integer and integer 1 are carried out step-by-step or computing, ensure that the big integer produced is odd number;
(2) judge that whether the odd number after (1) computing is the multiple of 5;
(3) if this odd number is the multiple of 5, (wherein PrimeTableB [N] is the one dimension prime number array pre-defined to the number then adding in predefined table of primes Prime-TableB [N] on the basis of this odd number, here it is 800 that the present invention gets N, lower same), forward to (1);
(4) if can not be divided exactly by 5, then continue to judge that (PrimeTableA [M] is predefined little prime number one-dimension array for prime number that can this big integer divide exactly in predefine table of primes PrimeTableA [M], 52 little prime numbers from 3, do not comprise 5, getting M is 52, lower same);
(5) if aliquot, then illustrate that the big integer of generation is not prime number, the basis of this big integer number adds the number in predefined table of primes PrimeTableB [N], forwards to (1);
(6) if prime numbers all in this big integer aliquant predefine table of primes PrimeTableA [M], then illustrate that it may be prime number.
Likely the Big prime of 1024 like this through pretreated number.Next, need to judge that it is that the possibility of prime number judges, the present invention adopts Miller-Rabin test for primality algorithm to detect.When carrying out Montgomery Algorithm, Montgomery modular multiplication algorithm is utilized to be optimized original algorithm, Montgomery Algorithm is changed into mould and add the method moved to right, effectively avoid and ask division arithmetic more consuming time in modular arithmetic, decrease the number of times of Montgomery Algorithm in former algorithm, improve the judgement efficiency of disposition.Idiographic flow, as shown in flow chart 4, comprising:
(1) for random number m to be measured, first need to calculate n, e, make m-1=2^e*n, wherein n is positive odd number, and e is nonnegative integer, and initialization i=0;
(2) random selecting integer t, makes 0<t<m;
(3) x=t^nmodm (in algorithm realization, Montgomery Algorithm being converted into Montgomery modular multiplication) is calculated;
(4) if x and 1 or m-1 congruence, then random number m to be measured is by prime test, and m may be prime number; Terminate.
(5) if i>0 and x and 1 congruence, then illustrate that m is not prime number;
(6) make i=i+1, if i<e or x and m-1 is incogruent, make x=x^2modm (in algorithm realization, Montgomery Algorithm being converted into Montgomery modular multiplication); Forward to (5).If x and m-1 congruence, then m is by test, may be prime number; Terminate.
(7) if i=e or x not with m-1 congruence, then m certainly not prime number.
Carry out 5 times in above process to detect, if the Miller-Rabin algorithm that have passed 5 times detects, then illustrate that the stochastic larger integer of generation is prime number, preserve and show the Big prime produced; Anyly once not pass through if had in 5 test for primality, then illustrate that this big integer is not prime number, on the basis of this big integer number, then add the number in predefined table of primes PrimeTableB [N], need to carry out preliminary treatment to new number, forward flow chart 3 to;
Here provide one and detect through 5 times 1024 the binary Big prime (forms of 16 systems) all passed through, that is:
c4f86cfc2de501fa3255763c30f404cb5a7043865939395448b57a0909b67e82195129a93c6663566573784e039712d138c3316e1a8c121f6c2225d701525d0601a207c15fe12c8f5dc62f122c7673f579fd71f2512e5fcd6c5b7d914ce5637660995b360b4f20c15e4e0d8a705635e3786d722552b53d9a42005359621336eb。

Claims (5)

1. a method for the quick generating big prime improved, it is characterized in that, described method comprises the steps:
Step 1: first stochastic generation specifies the big integer of figure place;
Step 1-1: define an array, the scope of each element wherein in array is 0 ~ 0xFFFFFFFF;
Step 1-2: take time as random seed;
Step 1-3: the number on each element in the generation array circulating random;
Step 1-4: after circulation terminates, make the element of highest order and 0x80000000 carry out step-by-step or computing, the highest order making the big integer produced is 1, namely ensures the figure place of large number;
Step 2: preliminary treatment is carried out to the stochastic larger integer produced:
Step 3: to the Miller-Rabin algorithm detection carrying out 5 times in step 2 through pretreated big integer; Step 4:
If all pass through for 5 times to detect, then this big integer is exactly prime number, forwards step 6 to;
Step 5: if not by detecting, then add the number in predefined table of primes PrimeTableB [N] on the basis of this big integer number, forward step 2 to;
Step 6: preserve and export this Big prime.
2. the method for the quick generating big prime of a kind of improvement according to claim 1, is characterized in that, described step 2 comprises the steps:
Step 2-1: big integer and integer 1 are carried out step-by-step or computing, is an odd number;
Step 2-2: judge that can its odd number be divided exactly by integer 5;
Step 2-3: if can, then on the basis of its odd number, add the number in predefined table of primes PrimeTableB [N], forward step 2-1 to;
Step 2-4: if can not, then forward step 2-5 to;
Step 2-5: judge that can big integer divide exactly the prime number in predefine table of primes PrimeTableA [M];
Step 2-6: if aliquot, then illustrate that the big integer of generation is not prime number, the basis of this big integer number adds the number in predefined table of primes PrimeTableB [N], forwards step 2-1 to;
Step 2-7: if prime numbers all in this big integer aliquant predefine table of primes PrimeTableA [M], then illustrate that it may be prime number, forward step 3 to.
3. the method for the quick generating big prime of a kind of improvement according to claim 1, it is characterized in that, described method is based on Miller-Rabin prime number examination algorithm, by adding preprocessing process, and Montgomery modular multiplication algorithm is adopted to be optimized former Miller-Rabin algorithm detection prime number.
4. the method for the quick generating big prime of a kind of improvement according to claim 1, is characterized in that, described method is applied to the key length increasing RSA Algorithm.
5. the method for the quick generating big prime of a kind of improvement according to claim 1, is characterized in that, the prime number element that what described method adopted is in predefine table of primes PrimeTableB is searched for as the increment of random increase.
CN201510814575.1A 2015-11-23 2015-11-23 Improved method for quickly generating big prime number Pending CN105515770A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510814575.1A CN105515770A (en) 2015-11-23 2015-11-23 Improved method for quickly generating big prime number

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510814575.1A CN105515770A (en) 2015-11-23 2015-11-23 Improved method for quickly generating big prime number

Publications (1)

Publication Number Publication Date
CN105515770A true CN105515770A (en) 2016-04-20

Family

ID=55723445

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510814575.1A Pending CN105515770A (en) 2015-11-23 2015-11-23 Improved method for quickly generating big prime number

Country Status (1)

Country Link
CN (1) CN105515770A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108270564A (en) * 2016-12-30 2018-07-10 广东精点数据科技股份有限公司 A kind of generation of large prime method and device in RSA cryptographic algorithms
CN108650086A (en) * 2018-05-14 2018-10-12 无锡知更鸟网络科技有限公司 A kind of cloud data ciphering method
CN116610290A (en) * 2023-07-20 2023-08-18 南京邮电大学 Hardware implementation method for implementing four-rule operation in finite field by Montgomery algorithm

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108270564A (en) * 2016-12-30 2018-07-10 广东精点数据科技股份有限公司 A kind of generation of large prime method and device in RSA cryptographic algorithms
CN108650086A (en) * 2018-05-14 2018-10-12 无锡知更鸟网络科技有限公司 A kind of cloud data ciphering method
CN116610290A (en) * 2023-07-20 2023-08-18 南京邮电大学 Hardware implementation method for implementing four-rule operation in finite field by Montgomery algorithm
CN116610290B (en) * 2023-07-20 2023-09-22 南京邮电大学 Hardware implementation method for implementing four-rule operation in finite field by Montgomery algorithm

Similar Documents

Publication Publication Date Title
Harn et al. Multilevel threshold secret sharing based on the Chinese Remainder Theorem
Mahmood et al. New fully homomorphic encryption scheme based on multistage partial homomorphic encryption applied in cloud computing
Muthukumar et al. Synchronization and an application of a novel fractional order King Cobra chaotic system
Segar et al. Pell's RSA key generation and its security analysis
US11658799B2 (en) Exponent splitting for cryptographic operations
Saxena et al. State of the art parallel approaches for RSA public key based cryptosystem
Rososhek Modified matrix modular cryptosystems
CN105515770A (en) Improved method for quickly generating big prime number
CN102279840A (en) Method for quickly generating prime number group applicable to information encryption technology
Rui et al. A k-RSA algorithm
Vollala et al. Efficient modular multiplication algorithms for public key cryptography
Reddy RM-RSA algorithm
Wang et al. Key generation research of RSA public cryptosystem and Matlab implement
Wahid et al. Implementation of certificateless signcryption based on elliptic curve using Javascript
Reyes et al. A performance comparison of elliptic curve scalar multiplication algorithms on smartphones
Li et al. A novel algorithm for scalar multiplication in ecdsa
Nykolaychuk et al. Residue Number System Asymmetric Cryptoalgorithms
CN104468100A (en) Improved sliding window modular exponentiation computing method
Wu et al. Batch public key cryptosystem with batch multi-exponentiation
Rai et al. Modified RSA cryptographic system with two public keys and chinese remainder theorem
Goswami et al. A new public key encryption scheme based on two cryptographic assumptions
Jaju et al. Analytical study of modified rsa algorithms for digital signature
Musa et al. Hybrid Cloud Storage Techniques Using Rsa And Ecc
Rai et al. “Encryption and Decryption through RSA Cryptosystem using Two Public Keys and Chinese Remainder Theorem
El Fadil A public-key cryptosystem based on Lucas sequences

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20160420

RJ01 Rejection of invention patent application after publication