RSA Public key Encryption--private key decryption

Source: Internet
Author: User

Liu Weihan-Learning pastry
Links: http://www.zhihu.com/question/25912483/answer/31653639
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

Let's review RSA's cryptographic algorithms. Based on the definition of public key cryptography and signature algorithms, we describe this algorithm in a more canonical language.

RSA public Key cryptography consists of the following 3 algorithms: KeyGen (Key generation algorithm), Encrypt (cryptographic algorithm), and decrypt (decryption algorithm).

    • 。 The key generation algorithm takes security constants as input, outputs a public key PK, and a private key SK. The security constants are used to determine how secure this cryptographic algorithm is, and are generally related to the size of the prime number p used by the cryptographic algorithm. The larger the prime number p is, the higher the security of the system is guaranteed. In RSA, the key generation algorithm is as follows: The algorithm first randomly produces two different large prime numbers p and q, calculating N=PQ. The algorithm then calculates the Euler function. Next, the algorithm randomly selects a less than an integer e, and calculates e about the modulo inverse element d. Finally, the public key is pk= (n, e), and the private key is sk= (n, D).
    • 。 The encryption algorithm outputs the ciphertext CT by using the public key PK and the message m to be encrypted as input . In RSA, the encryption algorithm is as follows: the algorithm directly outputs ciphertext as
    • 。 The decryption algorithm takes the private key SK and the ciphertext CT as input and outputs the message m. In RSA, the decryption algorithm is as follows: the algorithm directly outputs plaintext. Since E and D are under reciprocal inversion, we have:

So, as we can see from the algorithm description: The public key is used to encrypt the data, and the private key is used to decrypt the data . Of course, this can also be very intuitive to understand: the public key is a public key, it is public to use it to encrypt data. The private key is a private key, and whoever has this key is able to decrypt the text. Otherwise everyone can see the private key, can be decrypted, it is not a mess.

================= Split Line =================

Let's review the RSA signature scheme again. The signature scheme also contains 3 algorithms: KeyGen (Key generation algorithm), sign (signature algorithm), Verify (authentication algorithm).

    • 。 The key generation algorithm also takes the security constant as input, outputting a public key PK and a private key SK. In RSA signature, the key generation algorithm is exactly the same as the encryption algorithm.
    • 。 The signature algorithm outputs the signature with the private key SK and the message m to be signed as input . In RSA signatures, the signature algorithm directly outputs the signature as. Note that the signature algorithm and the decryption algorithm in the RSA encryption system are very similar .
    • 。 The validation algorithm outputs a bit value B with the public key PK, signature, and message m as input . B=1 means that the validation passes. B=0 means that the validation does not pass. In RSA signatures, the validation algorithm evaluates first, then compares M ' with m, and if equal, outputs b=1, otherwise the output is b=0. Note: The authentication algorithm is very similar to the encryption algorithm in the RSA encryption scheme .

Therefore, in the signature algorithm, the private key is used to sign the data, and the public key is used to authenticate the signature . This can also be intuitively understood: to sign a file, of course, to use the private key, because we hope that only ourselves to complete the signature. The verification process certainly wants everyone to be able to execute, and everyone can see that the signature is verified by the verification that I signed it myself.

Related implementation Source Address: http://download.csdn.net/detail/zyw_java/9549541

RSA Public key Encryption--private key decryption

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.