Is the public key and private key so complicated?

Source: Internet
Author: User

Is it really difficult to choose between public and private keys when using public key cryptography for encryption and signature?

This article is the second version, because the first version is unfortunately ...... Let's talk less and get down to the truth. It is often said that when using public key cryptography for encryption and signature, you must know whether to use the public key or private key. Otherwise, it is easy to joke. However, is it really that difficult for a person who has learned a little cryptography? Next we will discuss this issue. Key is used in cryptography. In Public Key cryptography, there are two keys, one is Public Key and the other is Secret Key, anyone can check the key, and the Private Key SK is kept confidential. In theory, you should only know it by yourself. This is different from the grouping password algorithm (DES, AES) (for the implementation of DES, see my previous blog), because the grouping password algorithm has only one KEY, it is shared by both parties and must be kept confidential. Next we will take the public key cryptography algorithm RSA as an example to illustrate how to implement the RSA decimals. We can also look at my article). Let's talk about the key selection problem in public key cryptography, encryption, and signature. First, let's talk about communication. communication naturally involves both parties. Of course, you can also communicate with yourself. If you still encrypt the signature at this time, you will be idle ......). The master of cryptography gave two nice names, A (lice) and B (ob), to both parties ). The following conventions describe PK (A). PK (B) represents the public key of Alice and Bob respectively. It is completely public and can be found by anyone. SK (A) is the private key of Alice, only Alice knows, SK (B) is Bob's private key, and Bob only knows. We will discuss it from Bob's perspective. Encryption: encryption. Why? Because both parties use a public channel, and the channel may have eavesdroppers, if messages are transmitted in plain text, they are not encrypted, then the eavesdroppers will be able to know the message content. If you transmit any ** message, you will be miserable. Therefore, to prevent messages from being known, encrypt the messages during transmission. In public key cryptography, a message M, under the control of key1, uses the cryptographic algorithm to obtain ciphertext C, which is encrypted. While ciphertext C is under the control of another Key2, after the cryptographic algorithm, we can obtain the corresponding plaintext M, which is decryption. One of them is the Public Key PK and the other is the private key SK, which is different from the group password. Next, Bob needs to transmit the message to Alice, which Key should be used. Use enumeration here. This method is very useful. A total of four keys are used. You don't want to use another person's key ...) 1) do I use PK (B) or my own Public Key )? This is used for analysis. For Messages encrypted using PK (B), only SK (B) can be decrypted. SK (B) is only known to you, Alice does not know, and eavesdroppers do not know. This Key has the best effect. No one else knows the content of the message, but Alice does not know the content of the message, this communication is meaningless. Therefore, deny it. 2) Do I use SK (B) or my own private key )? Let's take a look at it. For Messages encrypted using SK (B), use PK (B) for encryption. PK (B) is public. Alice knows. Well, Alice can decrypt the message. Can this be done! Is that true? It is precisely because PK (B) is public, Alice knows, the eavesdroppers know, so Alice can decrypt and the eavesdroppers can decrypt, so there is no confidentiality at all. It is not much different from plain text transmission. This is a tragic choice. Pass out. 3) is SK (A) the private key of the other Party used )? SK (A) is Alice's private key. Only Alice knows it. Bob does not know it. Assume that Alice secretly tells you the private key so that you can use it. Analysis in principle and outcome 2 is the same. Same ...... 4) do I use PK (A) or the other party's public key )? Division tells us that only this one can be selected, so choose it. You don't have to talk about the principle or anything. You're not interested in it either. No, the old man taught us to know why. We need to know the principle. Let's talk about it. For Messages encrypted by PK (A), SK (A) is used for decryption, while SK (A) is known to the other party, so the messages can be decrypted; and because SK (A) is only known by Alice, and others, including eavesdroppers, do not, the confidentiality of messages can be guaranteed. Meet the requirements. Well, I finally understood it. After talking so much about it, I'm thirsty. I'll talk about it again after drinking water ...... The signature is as follows. Signature: signature. In real life, we can use our own handwriting to sign the signature. What about the electronic world? Signature, which is provided by public key cryptography and cannot be compared with others. Signature. Why? For example, if you send a message to the bank and transfer 0.1 billion from your account, it is an example. It doesn't matter if you say that the amount is large ), the Bank executed this message and transferred the account. Afterwards, you told the bank that you have not transferred the account, and you want the bank to make compensation. If the Bank does not obtain the evidence, the bank is miserable and broke, and the bank can come up with evidence. The evidence is in that message, because you signed it, the signature is legal evidence. Okay. So, which key Should Bob use to sign the message? Enumeration Method debuted again ...... 1) do I use PK (A) or the other party's public key )? If you can, because PK (A) is public, everything can forge your signature, and your bank card will pop up... 2) Do I use SK (A) and the other party uses the private key )? You do not know this. The other party tells you that there is still a problem because it does not match your other key and the signature cannot be verified. This problem also occurs in 1. So, what's wrong... 3) do I use PK (B) or my own Public Key )? There are also problems. First, the principle is the same as 1. Because it is public, anyone can forge it, and the bank card is cracked again. Second, the principle is the same as 2. verification is required, you need to use another key, that is, your private key, which is only known to you, so the signature cannot be verified. This is another example of failure... 4) is the private key SK (B) Your Own Private Key )? Let's talk about the principle. The signature must be signed with something that can be confirmed unique, such as handwriting. Because SK (B) meets the requirements only you know. Second, the things signed by SK (B) can be verified by PK (B, because it is public. Therefore, the requirements are also met. Jackpot! After writing so much, I finally finished writing. Due to yesterday's mistake, I re-typed it today. I thought it was only a few hundred words. I didn't expect it to have more than 2 k words. However, the above is all nonsense. The following is a summary. The following sentence is the focus. In public key cryptography, encryption uses the other party's public key, and the signature uses its own private key. It's all nonsense. I wrote about it yesterday. I wrote about it today and I went drinking water!

This article is from the "info sec & pen test" blog, please be sure to keep this source http://andydhu.blog.51cto.com/3337368/859688

Related Article

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: info-contact@alibabacloud.com 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.