CN100579006C - RSA ciphering method for realizing quick big prime generation - Google Patents

RSA ciphering method for realizing quick big prime generation Download PDF

Info

Publication number
CN100579006C
CN100579006C CN200610062877A CN200610062877A CN100579006C CN 100579006 C CN100579006 C CN 100579006C CN 200610062877 A CN200610062877 A CN 200610062877A CN 200610062877 A CN200610062877 A CN 200610062877A CN 100579006 C CN100579006 C CN 100579006C
Authority
CN
China
Prior art keywords
prime number
prime
algorithm
key
miller
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.)
Active
Application number
CN200610062877A
Other languages
Chinese (zh)
Other versions
CN1937493A (en
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.)
Shenzhen Sinosun Technology Co., Ltd.
Original Assignee
ZHAORI TECH Co Ltd SHENZHEN
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 ZHAORI TECH Co Ltd SHENZHEN filed Critical ZHAORI TECH Co Ltd SHENZHEN
Priority to CN200610062877A priority Critical patent/CN100579006C/en
Publication of CN1937493A publication Critical patent/CN1937493A/en
Application granted granted Critical
Publication of CN100579006C publication Critical patent/CN100579006C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Storage Device Security (AREA)

Abstract

The prime number (PN) generation flow is that: The system generates a random number during idle, checks it with the Fermats theorem algorithm. If it is a PN, rechecks it with the Miller-rabin algorithm. If it still is, stores it into buffer for later use; if it is not, continues to circulate with preset longer step length. Whenever the system needs PN for encrypting, it picks them up from buffers. This invention uses the check method combining the Fermats theorem algorithm and the Miller-rabin algorithm and utilizes system idle time. These raise the processing speed and reliability.

Description

A kind of rsa encryption method that realizes that fast big prime number generates
Technical field
The invention belongs to the cryptographic calculations field, especially a kind of cryptographic calculations design field that is applied in the embedded system.
Background technology
In the password implementation procedure of prior art, particularly the implementation of public key cryptography when design, often need provide the function that generates big prime number, for example just to require must be prime number to key parameter p, the q in the rsa encryption process.
For generating big prime number, implementation common in the embedded system of prior art is: at first produce the enough random numbers of length, then by utilizing probability disposition detection algorithm to judge whether this random number is prime number, if this random number is not a prime number, then regenerate another group random number, or current random number carried out appropriate conversion, as this random number is added 2 computings, and then judge by probability disposition detection algorithm whether it is prime number, need repeat to generate random number and disposition judgement repeatedly like this, up to finding a prime number.
The defective of the big prime number implementation method of this generation of prior art is: for the limited embedded system of operational capability, because the probability disposition detection algorithm that is widely used at present such as the operation time of Miller-rabin algorithm itself are longer, and in most cases need to seek hundreds of in addition thousands of random numbers after just can find big prime number, promptly need execution disposition detection algorithm hundreds of even thousands of times, so can cause the time of the big prime number of generation in the computations process often very long, cause system running speed very slow, system effectiveness descends.
Therefore, prior art has defective, and awaits improving and development.
Summary of the invention
The object of the present invention is to provide a kind of password implementation method that is applied in the embedded system, generate the defective of big prime number implementation method, the time that generates big prime number is obviously shortened, thereby improve the efficient and the operation stability of system at prior art.
Technical scheme of the present invention comprises:
A kind of rsa encryption method that realizes that fast big prime number generates, it may further comprise the steps:
A, system are calculated at one's leisure automatically, generate plural prime number, and it is stored in the prime number buffer area;
B, when the generation cipher key function of calling system, system takes out two prime numbers that generate in steps A from the prime number buffer area, and after generating RSA key, this RSA key is exported to the user;
C, when the loading cipher key function of calling system, system is stored in the cipher key cache district with the key of user input;
D, when the encryption function of calling system, system takes out key from the cipher key cache district, the plaintext of user's input is carried out computations, obtains exporting to the user after the ciphertext;
The prime number product process of described steps A comprises step:
A1, generation one random number;
A2, whether be prime number with little this random number of theorem test of heuristics of Fermat; The prime number testing process of the little theorem algorithm of described Fermat comprises: if natural number n is judged, establishing a is the integer of any 1≤a of satisfying≤n-1, calculates a N-1(mod n), if the result is not equal to 1, then n is not a prime number; Otherwise judgement n is a prime number;
If A3 is judged as prime number, then use the inspection of Miller-rabin algorithm whether to be prime number, if check to be prime number, it is standby to buffer area then to export prime number;
If the inspection of A4 Miller-rabin algorithm still is not a prime number, then circulation A 2 and A3 step after the predetermined step-length of this random number growth are judged whether to be prime number.
Described method wherein, if when needs use prime number, do not deposit prime number in the described buffer area, is then called the prime number product process of described steps A, and till finding a prime number.
Described method, wherein, described step-length is the even number greater than zero.
Described method, wherein, described prime number product process carries out under the main control process flow idle condition, and after described steps A 3, no matter whether be prime number, withdraws from described prime number product process, returns main control process flow.
A kind of rsa encryption method that realizes that fast big prime number generates provided by the present invention, because the prime number detection mode that has adopted little theorem of Fermat (Fermat) and Miller-rabin algorithm to combine, and prime number to be measured is stored in buffering area, system's free time, the data in the buffering area are carried out disposition testing process control mode, make full use of the free time of system, improved the processing speed and the stability of system.
Description of drawings
Fig. 1 is the basic principle schematic of the handling process of the inventive method;
Fig. 2 is the idiographic flow schematic diagram of the prime number product process of the inventive method.
Embodiment
Below in conjunction with accompanying drawing, will be described in more detail each preferred embodiment of the present invention.
Cryptographic calculations implementation procedure of the present invention comprises: system is calculated at one's leisure automatically, generates plural prime number, and it is stored in the prime number buffer area; The generation cipher key function of user's calling system then, system takes out two prime number p and q from the prime number buffer area, and utilizes this two prime numbers to generate RSA keys, for example calculates RSA PKI n=p*q; Generate random number e, make that e and (p-1) (q-1) are relatively prime, e also is a PKI; Calculate RSA private key d=e -1Mod (p-1) (q-1) exports to the user with key then; The loading cipher key function of user's calling system, system is stored in the cipher key cache district with the key of user's input; The encryption function of user's calling system, system are taken out key from the cipher key cache district, the plaintext that the user is imported carries out computations, obtains exporting to the user after the ciphertext.
The technical scheme that the generation method of big prime number is adopted among the present invention program is: the first, and in order to reduce the time of each execution disposition detection algorithm, adopt the little theorem method of comparatively simple Fermat (Fermat) to detect disposition; And the correctness in order to guarantee that disposition detects, after the disposition detection of testing data by the little theorem method of Fermat, re-use comparatively general Miller-rabin algorithm and check disposition, so can reduce Miller-rabin algorithm comparatively consuming time and check the disposition number of times, and can guarantee the accuracy that disposition detects; Second, set up the prime number memory buffer, deposit testing data in this buffering area, system's free time, the data in the buffering area are carried out disposition and detect, thereby will need the disposition detection algorithm system that is distributed to of hundreds of even thousands of execution to finish in free time.
The content of " the little theorem of Fermat (Fermat) " of the inventive method is: if natural number n is a prime number, and a is the integer of any 1≤a of satisfying≤n-1, then a N-1≡ 1 (mod n).Algorithm according to this theorem test disposition is: at first generate random number a, and to make a be the integer of any 1≤a of satisfying≤n-1, calculate a then N-1(mod n) if the result is not equal to 1, illustrates that then n is not a prime number, otherwise explanation n might be prime number.
Montgomery Algorithm for once in the little theorem algorithm of Fermat (Fermat) as can be seen from formula, and in some embedded systems, Montgomery Algorithm is can be by special hardware logic arithmetic element, as special algorithm calculations speed-up chip, or the IP kernel that is applied to integrated circuit (IC) design calculates, and is relative simple and rapid so utilize the little theorem of Fermat (Fermat) to carry out primality test.But, this test result has bigger error rate, promptly may not be prime number but is judged as prime number.
Through after the above-mentioned processing, judge that by " Miller-rabin disposition detection algorithm " its steps performed comprises again:
1. remember n-1=2 sR, r are odd numbers, and n is a testing data;
2.For i=1 to t do (according to the needs of test accuracy, the t value is for several times to tens of times)
2.1 select a random number a, 2≤a≤n-2;
2.2 calculate y=a rMod n;
2.3ify≠1?and y≠n-1?then?do
j←1.
2.4While?j≤s-1?and?y≠n-1?do
y←y 2?modn.
If y=1 then Return (closing number)
j←j+1.
If y ≠ n-1 then Return (closing number)
(3.Return prime number)
Because the Miller-rabin algorithm is common by prior art, therefore, its computational process repeats no more.
By above-mentioned description to two kinds of disposition detection algorithms as can be seen, the Miller-rabin algorithm is to need loop computation repeatedly for the accuracy that increases detection, and all comprise the one-off pattern power operation at least in each circulation, promptly the Miller-rabin running time of algorithm is to utilize the little theorem of Fermat (Fermat) to carry out the several times of primality test.
Therefore the inventive method adopts the comparatively simple little theorem method of Fermat (Fermat) to detect disposition in advance, can significantly improve the speed that prime number detects, and after the disposition detection of testing data by the little theorem method of Fermat, re-use comparatively general Miller-rabin algorithm and check disposition, can guarantee the accuracy that disposition detects again.
The specific embodiment of the inventive method as depicted in figs. 1 and 2, is described below: at first, after the program running by other power functions of system master program scheduler; This primary control program is judged current state, when confirming there are not other functional requirements at present, when promptly system is in idle condition, calls the prime number product process.
Described prime number product process will generate a random number that length is enough, and guarantee that it is an odd number, and the generative process of this random number is that prior art is in common knowledge, does not repeat them here.
Described prime number product process judges by calculating whether this random number is prime number, this deterministic process comprises: at first use the little theorem method test of Fermat whether to be prime number, not prime number if the little theorem method of Fermat is thought, then directly return the result that current data is not a prime number; Whether if the little theorem method of Fermat thinks prime number, then re-using the inspection of Miller-rabin algorithm is prime number, and with its result as final result.Described Miller-rabin algorithm is known by prior art, therefore, repeats no more.
No matter whether described random number is prime number, all withdraw from the prime number product process, program is got back in the system master flow process, wherein current random number needs to preserve, so that the step of back can directly obtain current random number and carry out corresponding operating, and whether this random number of record is prime number in the global variable sign.
System master program of the present invention is judged current state, and when confirming not have other functional requirements at present, promptly system is in comparatively idle state, then calls the prime number product process once more.Described prime number product process is at first judged the global variable sign, whether retrieval is prime number from this global variable sign, if find it is prime number, then withdraw from the prime number product process, program is got back in the main control process flow, so, the front as calculated and the prime number computational process of judging just need not repeat, therefore, can save the resource consumption of double counting.
If find it is not prime number, then the random number that will preserve before can be done proper transformation, as add 2 and calculate, whether and to detect it once more be prime number, no matter whether be prime number afterwards, all withdraw from the prime number product process, program is got back in the system master flow process, wherein current random number is kept in the prime number buffering area, and whether this random number of record is prime number in the global variable sign.Certainly, also can continue to calculate and go down up to finding next prime number, but because system may accept new operation requests at any time, therefore, interrupting calculating is for making the corresponding more timely of system, only carries out searching of prime number when idle in system.
When primary control program find to use the demand of prime number, and when calling the prime number product process, the prime number product process is judged the global variable sign, if find it is prime number, then directly current prime number is exported from buffer area, and the modification global variable is masked as and is not prime number; Whether if find it is not prime number, then carrying out continuously the random number of preserving is before carried out conversion and calculated it once more is the operation of prime number, up to finding prime number, and no longer withdraws from the prime number product process from the searching process.
But therefore the inventive method has just reduced and has calculated the required time because employing is carried out searching and detecting of prime number in system during the free time, and therefore, the global variable sign is prime number substantially when primary control program need generate key.
It is noted that in the described big prime number generation method of the present invention, its applied main control process flow and cryptographic calculations as the RSA key generative process, are prior art contents well-known to those skilled in the art, do not repeat them here.
The inventive method both guarantees that by fully utilizing two kinds of disposition detection algorithms, having reached prime number detects quality, has obviously improved the effect of prime number formation speed again, thereby the formation speed of key is improved; Simultaneously, seek prime number when idle, thereby seek the effect of the time of prime number when reaching minimizing and carrying out the key generative process specially in system.
Should be understood that above-mentioned description at specific embodiment is comparatively detailed, can not therefore be interpreted as the restriction to scope of patent protection of the present invention, scope of patent protection of the present invention should be as the criterion with claims.

Claims (4)

1, a kind of rsa encryption method that realizes that fast big prime number generates, it may further comprise the steps:
A, system are calculated at one's leisure automatically, generate plural prime number, and it is stored in the prime number buffer area;
B, when the generation cipher key function of calling system, system takes out two prime numbers that generate in steps A from the prime number buffer area, and after generating RSA key, this RSA key is exported to the user;
C, when the loading cipher key function of calling system, system is stored in the cipher key cache district with the key of user input;
D, when the encryption function of calling system, system takes out key from the cipher key cache district, the plaintext of user's input is carried out computations, obtains exporting to the user after the ciphertext;
The prime number product process of described steps A comprises step:
A1, generation one random number;
A2, whether be prime number with little this random number of theorem test of heuristics of Fermat; The prime number testing process of the little theorem algorithm of described Fermat comprises: if natural number n is judged, establishing a is the integer of any 1≤a of satisfying≤n-1, calculates a N-1(mod n), if the result is not equal to 1, then n is not a prime number; Otherwise judgement n is a prime number;
If A3 is judged as prime number, then use the inspection of Miller-rabin algorithm whether to be prime number, if check to be prime number, it is standby to buffer area then to export prime number;
If the inspection of A4 Miller-rabin algorithm still is not a prime number, then circulation A 2 and A3 step after the predetermined step-length of this random number growth are judged whether to be prime number.
2, method according to claim 1 is characterized in that, if when needs use prime number, do not deposit prime number in the described buffer area, then calls the prime number product process of described steps A, and till finding a prime number.
3, method according to claim 1 and 2 is characterized in that, described step-length is the even number greater than zero.
4, method according to claim 1 is characterized in that, described prime number product process carries out under the main control process flow idle condition, and after described steps A 3, no matter whether be prime number, withdraws from described prime number product process, returns main control process flow.
CN200610062877A 2006-09-27 2006-09-27 RSA ciphering method for realizing quick big prime generation Active CN100579006C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200610062877A CN100579006C (en) 2006-09-27 2006-09-27 RSA ciphering method for realizing quick big prime generation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200610062877A CN100579006C (en) 2006-09-27 2006-09-27 RSA ciphering method for realizing quick big prime generation

Publications (2)

Publication Number Publication Date
CN1937493A CN1937493A (en) 2007-03-28
CN100579006C true CN100579006C (en) 2010-01-06

Family

ID=37954785

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200610062877A Active CN100579006C (en) 2006-09-27 2006-09-27 RSA ciphering method for realizing quick big prime generation

Country Status (1)

Country Link
CN (1) CN100579006C (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102023962A (en) * 2009-09-10 2011-04-20 上海华虹集成电路有限责任公司 Prime number generating method applied to cryptology application
CN102279840B (en) * 2011-08-31 2014-06-18 刘诗章 Method for quickly generating prime number group applicable to information encryption technology
CN102325024A (en) * 2011-09-26 2012-01-18 飞天诚信科技股份有限公司 Method and device for generating big prime
EP2791784A1 (en) * 2011-12-15 2014-10-22 Inside Secure Method for generating prime numbers proven suitable for chip cards
CN105071928A (en) * 2015-07-08 2015-11-18 路博超 FPGA-based quick generation method of big prime number and big prime number family
CN106487512A (en) * 2015-08-31 2017-03-08 北京同方微电子有限公司 A kind of RSA key is to quick-speed generation system and method
CN105373366B (en) * 2015-10-12 2018-11-09 武汉瑞纳捷电子技术有限公司 A kind of method and device generating Big prime
CN106209349A (en) * 2016-08-31 2016-12-07 福建联迪商用设备有限公司 Data ciphering method based on 3DES algorithm and device
CN111130785B (en) * 2018-10-31 2022-11-29 中国移动通信集团浙江有限公司 Method and device for generating RSA encryption algorithm key based on real-time passenger flow model
CN112367342B (en) * 2020-12-04 2023-07-14 国网江苏省电力有限公司南京供电分公司 Encryption transmission method and system for distributed photovoltaic operation and maintenance data

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
Miller-Rabin算法研究与优化实现. 秦晓东,辛运帏,卢桂章.计算机工程,第28卷第10期. 2002
Miller-Rabin算法研究与优化实现. 秦晓东,辛运帏,卢桂章.计算机工程,第28卷第10期. 2002 *
一种快速的素数生成和检验算法. 夏静波,陈建华.武汉大学学报(理学版),第51卷第S2期. 2005
一种快速的素数生成和检验算法. 夏静波,陈建华.武汉大学学报(理学版),第51卷第S2期. 2005 *
大素数的快速生成研究与实现. 耿海飞,苏锦海.电脑与信息技术,第13卷第2期. 2005
大素数的快速生成研究与实现. 耿海飞,苏锦海.电脑与信息技术,第13卷第2期. 2005 *

Also Published As

Publication number Publication date
CN1937493A (en) 2007-03-28

Similar Documents

Publication Publication Date Title
CN100579006C (en) RSA ciphering method for realizing quick big prime generation
Nara et al. Scan-based attack against elliptic curve cryptosystems
US20200265167A1 (en) Configurable lattice cryptography processor for the quantum-secure internet of things and related techniques
CN101540672B (en) Data processing system and data processing method
Nara et al. Scan-based side-channel attack against RSA cryptosystems using scan signatures
US20100306295A1 (en) Protection of a prime number generation for an rsa algorithm
CN105426159A (en) True random number generator based on digital circuit
CN101350716A (en) Systems and methods for efficient generation of hash values of varying bit widths
Kocabaş et al. Implementation of binary Edwards curves for very-constrained devices
US8639944B2 (en) Zero divisors protecting exponentiation
CN102279725A (en) Elliptic curve cipher (ECC) co-processor
CN105790939A (en) Prime number field elliptic curve cryptography system of VLSI realization accelerator
KR100436814B1 (en) apparatus for RSA Crypto Processing of IC card
CN111835518A (en) Error injection method and system in security evaluation of elliptic curve public key cryptographic algorithm
JP2004304800A (en) Protection of side channel for prevention of attack in data processing device
Wu et al. Implementation of efficient method of RSA key-pair generation algorithm
CN101371285A (en) Encryption processing device, encryption processing method, and computer program
Wang et al. An efficient quantum meet-in-the-middle attack against NTRU-2005
CN101021777A (en) Efficient mod operation based on divisor (2n-1)
Fournaris et al. Design and leakage assessment of side channel attack resistant binary edwards Elliptic Curve digital signature algorithm architectures
Barenghi et al. A novel fault attack against ECDSA
US10454680B2 (en) RSA decryption processor and method for controlling RSA decryption processor
Zhu et al. Mckeycutter: A High-throughput Key Generator of Classic McEliece on Hardware
CN114238205B (en) High-performance ECC coprocessor system for resisting power attack
US20050152539A1 (en) Method of protecting cryptographic operations from side channel attacks

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
EE01 Entry into force of recordation of patent licensing contract

Assignee: Zhaori Science & Technology (Shenzhen) Co., Ltd.

Assignor: Zhaori Tech Co., Ltd., Shenzhen

Contract fulfillment period: 2009.2.28 to 2027.9.11 contract change

Contract record no.: 2009990000224

Denomination of invention: RSA ciphering method for realizing quick big prime generation

License type: Exclusive license

Record date: 2009.3.26

LIC Patent licence contract for exploitation submitted for record

Free format text: EXCLUSIVE LICENSE; TIME LIMIT OF IMPLEMENTING CONTACT: 2009.2.28 TO 2027.9.11; CHANGE OF CONTRACT

Name of requester: ZHAORI SCIENCE + TECHNOLOGY (SHENZHEN) CO., LTD.

Effective date: 20090326

C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: SINOSUN TECHNOLOGY (SHENZHEN) CO., LTD.

Free format text: FORMER OWNER: SHENZHEN SINOSUN TECH CO., LTD.

Effective date: 20100622

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 518040 BLOCK C-3, 6/F, BUILDING 213, TAIRAN 9TH ROAD, DISTRICT, SHENZHEN CITY, GUANGDONG PROVINCE TO: 518040 TOWER C, 6/F, BUILDING 213, TAIRAN INDUSTRY DISTRICT, CHEGONGMIAO, FUTIAN DISTRICT, SHENZHEN CITY

TR01 Transfer of patent right

Effective date of registration: 20100622

Address after: 518040 Shenzhen city Futian District Che Kung Temple Tairan industrial district 213 building 6 floor C block

Patentee after: Sinosun Technology (Shenzhen) Co., Ltd.

Address before: Nine road 518040 Guangdong city of Shenzhen province Futian District Tairan 213 building 6 floor C-3 block

Patentee before: Zhaori Tech Co., Ltd., Shenzhen

C56 Change in the name or address of the patentee

Owner name: SHENZHEN ZHAORI TECHNOLOGY CO., LTD.

Free format text: FORMER NAME: ZHAORI SCIENCE + TECHNOLOGY (SHENZHEN) CO., LTD.

CP01 Change in the name or title of a patent holder

Address after: 518040 Shenzhen city Futian District Che Kung Temple Tairan industrial district 213 building 6 floor C block

Patentee after: Shenzhen Sinosun Technology Co., Ltd.

Address before: 518040 Shenzhen city Futian District Che Kung Temple Tairan industrial district 213 building 6 floor C block

Patentee before: Sinosun Technology (Shenzhen) Co., Ltd.