Public key cryptography system and RSA public key algorithm

Source: Internet
Author: User


Public key cryptography system and RSA public key algorithm


This article briefly introduces the ideas and features of the public key cryptography system, and introduces the theoretical basis, working principle and implementation process of the RSA algorithm, A simple example shows how the algorithm is implemented. At the end of this article, the shortcomings and Solutions of the RSA algorithm are summarized.

Key words: public key cryptography, public key, private key, RSA

Graph classification: tp309.7

§ 1 Introduction

With the gradual implementation of computer networking, the prospect of Internet is getting better and better. The global economy is entering the information economy era, and the knowledge economy is emerging. The confidentiality of computer information becomes more and more important. Whether it is personal information communication or e-commerce development, there is an urgent need to ensure the security of information transmission over the Internet. Information security technology is a comprehensive discipline that involves information theory, computer science, cryptography, and other aspects of knowledge, its main task is to study the protection methods of information in computer systems and communication networks to ensure the security, confidentiality, authenticity and integrity of information in the system. Password technology is the core of information security. Cryptographic technology is a cross-discipline that combines mathematics, computer science, electronics and communication among other disciplines. It not only ensures the encryption of confidential information, but also implements functions such as digital signature, identity authentication, and system security. It is one of the important scientific aspects of modernization. This article will give a brief introduction to the public key cryptography system and the most popular RSA Algorithm in the system.

2. Public Key and password system

To describe the public key cryptography system, first let's take a look at different encryption algorithms: The current encryption algorithms can be divided into single-key cryptography and public key cryptography algorithms by key.

2.1. Single-key password

Symmetric cryptography is a traditional encryption method. It uses the same key for encryption and decryption, when transmitting and processing information, the sender and receiver of information must jointly hold the password (called Symmetric password ). Therefore, both parties must obtain the key and keep the key secret.

The security of a single-key password system depends on the following two factors: first, the encryption algorithm must be strong enough, and it is impossible to decrypt information only based on the ciphertext itself; second, the security of the encryption method depends on the confidentiality of the key, rather than the confidentiality of the algorithm. Therefore, we do not need to ensure the confidentiality of the algorithm (in fact, in reality, many algorithms for single-key cryptographic systems are public), but we must ensure the confidentiality of keys.

From the characteristics of a single key password, we can easily see that there are two main problems with it: first, the number of keys. In a single-key password system, each communication person needs a pair of keys. When users increase, the number of keys increases exponentially. Therefore, in network communication, the generation, storage, and distribution of a large number of keys will be difficult to solve. Second, key distribution issues. In a single-key password system, encryption security relies entirely on key protection. However, since both parties use the same key, people have to exchange keys with each other. To ensure security, people must use some other security channels to distribute keys, such as using dedicated couriers to transmit keys. This approach is costly and even unrealistic, especially in computer network environments, when people use the network to transmit encrypted files, they need another secure channel to distribute keys. Obviously, this is very unwise or even ridiculous.

2.2 Public Key Password

Because the single-key password system is so difficult to solve, it is more urgent and necessary to develop a new, more effective, and more advanced password system. In this case, a new public key cryptography system emerged, which breaks through the key distribution problem that plagued countless scientists. In fact, in this system, people do not even need to distribute keys that require strict confidentiality. This breakthrough is also considered to be the greatest achievement in password history after the invention of the single-code replacement password in two thousand years.

This new idea was proposed by Diffie and Hellman, two scholars from Stanford University in the 1970s S. The biggest difference between this system and single-key cryptography is:

In a public key cryptography system, encryption and decryption use different keys (which are called asymmetric keys relative to symmetric keys). The two keys are mutually dependent: that is, the Information encrypted with either of the keys can only be decrypted with the other key. This allows both parties to perform confidential communication without prior key exchange. The encryption key and algorithm are made public to the public. Everyone can use this key to encrypt the file and send it to the receiver. This encryption key is also called a public key. After receiving the encrypted file, the Receiver, it can use its decryption key for decryption. This key is owned by itself and does not need to be distributed. Therefore, it is also called a private key, which solves the issue of key distribution.

To illustrate this idea, we can consider the following analogy:

Two people who communicate on insecure channels, assume Alice (the receiver) and Bob (the sender). They want to communicate securely without being damaged by their rival Oscar. Alice came up with a way to use a lock (equivalent to a public key) that anyone can lock with a single click, but only Alice's key (equivalent to a private key). Alice then sends Numerous Locks To the outside. When anyone, such as Bob, wants to send a mail to her, they only need to find a box and then use Alice's lock to lock it and send it to Alice, at this time, no one (including Bob) can open the box except Alice, who owns the key. Even if Oscar can find Alice's lock, even if Oscar can intercept the box during communication, without Alice's key, he could not open the box, and Alice's key does not need to be distributed, so Oscar could not get this "private key ".

From the above introduction, we can see that the idea of the public key cryptography system is not complicated, but the key to implementing it is how to determine the public key and private key and the encryption/decryption algorithm, that is to say, how to find the question of "Alice's lock and key. In this system, we assume that the primary key is public information and used as an encryption key. The SK must be kept confidential by the user and used as the decryption key. Both the encryption algorithm e and the decryption algorithm D are public. Although SK and PK appear in pairs, SK cannot be calculated based on PK. They must meet the following conditions:

① Encryption key PK encrypts plaintext X and then decrypts it with the decryption key SK to restore the plaintext, or write it as DSK (EPK (x) = x
② The encryption key cannot be used for decryption, that is, dpk (EPK (x) =x
③ On the computer, it is easy for the real estate to generate a pair of PK and SK.
④ SK cannot be exported from a known PK.
⑤ The encryption and decryption operations can be reversed, that is, EPK (DSK (x) = x

From the above conditions, we can see that in the public key cryptography system, the encryption key is not equal to the decryption key. The encryption key can be disclosed to the public, so that any user can encrypt the information sent to this user, and the only private key that the user saves is confidential, only the ciphertext can be restored and decrypted. Although the decryption key can be calculated theoretically by the encryption key, this algorithm design is actually impossible, or although it can be computed, it takes a long time to become unfeasible. Therefore, disclosing an encrypted key does not compromise the security of the key.

This kind of institutional thinking is simple, but how to find a suitable algorithm to implement this system is a challenge that really bothers cryptology practitioners, since PK and SK are a pair of interconnected keys, it is very likely to export the other key from one of them. If the competitor Oscar can export SK from PK, then the system is no longer secure. Therefore, how to find a suitable algorithm to generate a suitable PK and SK, and make it impossible to export SK from the PK is a challenge that the cryptographic experts urgently need to solve. This problem even caused the development of the public key and password system to stagnate for a long time.

To solve this problem, the cryptology considers the One-Way Function in mathematics. Below, we can give an informal definition of it:

Alice's public encryption function should be easy to calculate, and calculation of its inverse function (that is, the decryption function) should be difficult (for persons other than Alice ). Many functions in the form of Y = f (x) can easily calculate the value of Function Y for the given independent variable X value, in many cases, it is very difficult to calculate the X value based on the Function Relation f (x. This is a function that is easy to calculate but difficult to calculate inverse. It is usually called a one-way function. In the encryption process, we want the encryption function e to be a single-shot function for decryption. Although no function can prove to be unidirectional, many single-shot functions are considered unidirectional.

For example, assume that N is the product of two prime numbers p and q, and B is a positive integer, then define F:
F (x) = x B mod n
(If gcd (B, Phi (N) = 1, this is actually the RSA encryption function we will talk about below)

If we want to construct a public key cryptography system, it is not enough to provide only one-way single-shot function. From Alice's point of view, e is not one-way, because it needs to decrypt the received information in a valid way. Therefore, Alice should have a trap, which contains the secret information of your function that is easy to find e. That is to say, Alice can decrypt data effectively, because it has additional secret knowledge, that is, SK, which can provide you with the decryption function D. Therefore, a function is called a one-way function. If it is a one-way function and has a specific knowledge, it is easy to find its inverse.

Consider the above function f (x) = XB mod n. We can know that its inverse function f-1 has a similar form f (x) = XA mod N, for a suitable value. The trap is to use the factor decomposition of N to effectively calculate the correct index A (for a given B ).

For convenience, we count the specific class of traps as one-way functions ?. So a random function f belongs ?, As a public encryption function; its inverse function f-1 is a secret decryption function. Then the public key and password system can be implemented.

According to the above thoughts on traps of one-way functions, scholars have proposed many public key encryption methods. Their security is based on complicated mathematical difficulties. Based on the mathematical difficulties, at least three types of systems are currently considered safe and effective: Big integer factorization systems (typically RSA) elliptic curve discrete logarithm System (ECC) and discrete logarithm System (Representative DSA ).

§ 3 RSA Algorithm

3.1 Introduction

Currently, the most famous and widely used public key system, RSA, was developed by the Massachusetts Institute of Technology (MIT) in 1978) rivest, Shamir, and Adleman proposed in the paper entitled "How to obtain a digital signature and public key/password system. It is an asymmetric (Public Key) cryptography system based on number theory and a group cryptography system. The name comes from the first letter of the three inventors. Its security is based on the difficulty of big integer factorization, while the big integer factorization is a famous mathematical problem. So far, there is no effective solution, therefore, the security of the RSA algorithm can be ensured. RSA is the most typical method of public key system. Most products and standards that use public key encryption for encryption and digital signature use the RSA algorithm.

The RSA algorithm is the first algorithm that can be used for both data encryption and digital signature. Therefore, it provides a basic method for Information Encryption and identification on public networks. It is usually a pair of RSA keys, one of which is a private key, which is saved by the user; the other is a public key that can be made public, or even registered on a network server, people use public keys to encrypt files and send them to individuals. individuals can use private keys for decryption. To increase the confidentiality, the RSA key must be at least 500 bits long. Generally, 1024 bits are recommended.

Based on the following two facts, this algorithm ensures the security and effectiveness of the RSA algorithm:
1) A quick algorithm has been developed to determine whether a number is a prime number;
2) No quick algorithm has been found to determine a certain quantity of quality factors.

3.2 Working Principle

1) select two different mass numbers p and q, and calculate the product R = p * q;
(2) arbitrary selection of a large integer E, E and (p-1) * (q-1) mutual quality, integer e is used as the encryption key. Note: E can be easily selected. For example, all quality numbers greater than p and q are available.
3) determine the decryption key D: D * E = 1 modulo (p-1) * (Q-1) D can be easily calculated based on E, P, and Q.
4) Public integers R and E, but not D;
5) encrypt plaintext P (assuming P is an integer smaller than R) to ciphertext C. The calculation method is as follows:
C = PE modulo R
6) decrypt ciphertext C into plain text P. The calculation method is as follows:
P = CD modulo R
However, it is impossible to calculate d only based on R and E (not p and q. Therefore, anyone can encrypt the plaintext, but only authorized users (know d) can decrypt the ciphertext.

3.3 simple instance

To illustrate the working process of this algorithm, we will give a simple example below. Obviously, we can only take a small number here, but as mentioned above, to ensure security, in practical applications, we use a lot of numbers.

For example, if p = 3, q = 5 is selected, r = 15, (p-1) * (q-1) = 8. Select E = 11 (greater than the prime numbers of p and q) and calculate d = 3 through D * 11 = 1 modulo 8.
Assume that the plaintext is an integer of 13. The ciphertext C is
C = PE modulo R
= 1311 modulo 15
= 1,792,160,394,037 modulo 15
= 7
Recovery plaintext P:
P = CD modulo R
= 73 modulo 15
= 343 modulo 15
= 13
Because E and D are mutually inverse, the public key encryption method also allows the "signature" method to encrypt the information so that the recipient can determine that the signature is not forged.

Assume that a and B want to transmit data through the public key encryption method. A and B respectively disclose the encryption algorithm and the corresponding key, but do not disclose the decryption algorithm and the corresponding key. The encryption algorithms of A and B are ECA and ECB, And the decryption algorithms are DCA and DCB, ECA and DCA, and ECB and DCB. If a wants to send plain text P to B, instead of simply sending ECB (P), it first applies the decryption algorithm DCA to P and then encrypts the result with the encryption algorithm ECB.

Ciphertext C:
C = ECB (DCA (p ))
After receiving C, B successively applies the decryption algorithm DCB and the encryption algorithm ECA to obtain the plaintext P:
ECA (DCB (c ))
= ECA (DCB (ECB (DCA (p ))))
= ECA (DCA (p)/* DCB and ECB offset each other */
= P/* DCB and ECB offset each other */

In this way, B determines that the message is indeed sent from a, because only when the encryption process uses the DCA algorithm, ECA can get p. Only a knows the DCA algorithm, no one knows, even B cannot forge a's signature.

3.4 advantages and disadvantages

3.4.1 advantages

The RSA algorithm is the first algorithm that can be used for both encryption and digital signature, and is easy to understand and operate. RSA is the most widely studied public key algorithm. It has been nearly two decades since it was proposed. It has been tested by various attacks and is gradually accepted by people, it is generally regarded as one of the best public key solutions. The encryption key of this algorithm is separated from the encryption algorithm to facilitate key distribution. It is particularly compatible with the computer network environment. For a large number of online users, the encryption key can be printed in the phone book. If a user wants to communicate with another user in a confidential manner, the user only needs to find the encryption key of the other user from the public key book and use it to encrypt and send the transmitted information. After receiving the information, the recipient uses the decryption key only known to him to decrypt the information and understand the content of the message. It can be seen that the RSA algorithm solves the difficulty of managing a large number of network user keys, which is the most prominent advantage of the public key cryptography system over the symmetric cryptography system.

3.4.2 disadvantages

1) It is difficult to Generate Keys. Due to technical restrictions on the generation of prime numbers, it is difficult to achieve one-time password.

2) Security: RSA Security depends on factor decomposition of large numbers, but it is not theoretically proved that the difficulty of deciphering RSA is equivalent to the difficulty of decomposing large numbers, in addition, most people in the cryptographic field tend to use factor decomposition rather than the NPC issue. At present, people have been able to break down more than 140 large prime numbers in decimal places, which requires a longer key, and the speed is slower. In addition, people are actively looking for methods to attack RSA, for example, if you select a ciphertext attack, an attacker may disguise a certain information and sign the entity with the private key. Then, the desired information is obtained after calculation. In fact, the attack uses the same weakness, that is, the fact that the multiplication structure of the input is retained by the power:

(XM) d = XD * md mod n

As mentioned above, this inherent problem comes from the most useful feature of the public key cryptography system-everyone can use the public key. However, the algorithm cannot solve this problem. There are two main measures: one is to use a good public key protocol to ensure that the entity does not decrypt any information generated by other entities during the work process, you do not need to sign any information that you do not know about. The other is never to sign a random document sent by strangers. When signing a document, use one-way hash function to hash the document, or use different signature algorithms at the same time. In addition to using the public modulus, people also try to use decryption indexes or PHI (n) attacks.

3) The speed is too slow. Because the RSA group length is too large, N must be at least 600 bitx to ensure security, which results in high computing costs, especially when the speed is low, symmetric cryptographic algorithms are several orders of magnitude slower. With the development of big data decomposition technology, this length is still increasing, which is not conducive to the standardization of data formats. Currently, the Set (Secure Electronic Transaction) protocol requires CA to use a 2048-bit long key, while other entities use a 1024-bit key. In order to solve the speed problem, the single-key and public-key encryption methods are widely used. Their advantages and disadvantages are complementary: the single-key encryption is fast, and people use it to encrypt long files, then, RSA is used to encrypt the file key, which solves the key distribution problem of a single key and password.

§ 4 Conclusion

At present, the increasing demand for e-commerce and other Internet applications has popularized public key systems. These demands mainly include access control for server resources and protection for e-commerce transactions, and rights protection, personal privacy, wireless transactions and content integrity (such as ensuring the authenticity of news reports or stock quotations. Since the development of public key technology, the obvious development trend in the market is the integration of PKI and the operating system. PKI is short for "Public Key Infrastructure", meaning "Public Key Infrastructure ". Public key systems are widely used in CA authentication, digital signatures, and key exchange.

RSA is the most widely used public key encryption algorithm. The initial idea and goal of RSA algorithm development is to ensure the security and reliability of the Internet. It aims to solve the challenge of using public channels for transmission and distribution of DES algorithm secret keys. The actual results not only solve this problem well, but also can use RSA to sign the digital message to prevent denial and denial of the message; at the same time, attackers can also use digital signatures to easily detect illegal tampering of messages to protect the integrity of data information. So far, many encryption technologies have adopted the RSA algorithm, which has been widely used in many aspects of the Internet, including the security Interface Layer (SSL) standard (this standard is required when a web browser establishes a secure Internet connection. In addition, the RSA encryption system can be applied to smart IC cards and network security products.

However, at present, the patent term of the RSA algorithm is about to end, and it is replaced by an elliptic curve-Based Cryptography (ECC ). Compared with the RSA algorithm, ECC has its own advantages, which makes ECC more suitable for today's development trends that require rapid response in e-commerce. In addition, a new quantum cryptography is also under development.

What encryption algorithm should be used in actual applications should be combined with the specific application environment and system, and cannot be simply determined based on its encryption strength. In addition to the encryption algorithm itself, reasonable key distribution, encryption efficiency, combination with existing systems, and input-output analysis should all be taken into account in the actual environment. With the development and update of the network, encryption technology will generate more secure and easy-to-implement algorithms, providing more powerful protection for information security. We will wait and see where the encryption technology will go in the future.

[1] Douglas R. Stinson. Principles and Practices of cryptography. Beijing: Electronics Industry Press, 131-132
[2] Simon Singh. Password story. Haikou: Hainan press, 271, 272-
The RSA Algorithm of encryption algorithm-,2003
[4] encryption and digital signature-
[5] hacker intermediate tutorial series of 10.

Public Key Cipher System and RSA public key algorithm

The paper introduce the idea and character of the public key cryptography in a simple way, especially expound the theoretical foundation, the working principle and the concrete realizing procedure of the RSA algorithm. besides that, it accounts for how the algorithm realize through a simple example. in the end of this article, some weakness which exist up to now are given out with their solution.

Key word public key cryptography, public key, private key, RSA


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.