Asymmetric Encryption
Asymmetric encryption is characterized by the fact that each user has a pair of keys: a public key and a private key. To send a message while ensuring secrecy, the sender encrypts the message with the recipient's public key, which the recipient decrypts using their private key. Examples of algorithms that implement asymmetric encryption are RSA and El Gamal.
Asymmetric encryption is particularly useful for privacy on the Internet because it does not require the physical exchange of the shared key. However, asymmetric encryption is slower than symmetric encryption, which is a better alternative. discussed in this post.
General principles of asymmetric cryptography
Asymmetric cryptography (also called public-key cryptography) is based on the general principle that each user has a pair of keys: a public key K+ and a private key Kโ. For the mechanism to work, the user who owns the key pair must scrupulously follow these two rules:
-
The public key can be distributed to anyone;
-
The private key must be jealously guarded and must not be disclosed to anyone.
It may be disconcerting and counterintuitive that a different key is used to encrypt a message than the one used to decrypt it, yet the mechanism works perfectly. For demonstration purposes, we will briefly discuss the basic functioning of the RSA algorithm, emblematic of asymmetric cryptography. The RSA algorithm was invented in 1977 by three MIT engineers, Ronald Rivest, Adi Shamir, and Leonard Adleman โ the acronym RSA comes from the authors' initials. RSA is based on the following principle: given a number n, it is possible to decrypt it. It is very difficult to find the two prime numbers p and q that are factors of n. Based on this principle, the number n can be made public without fear that, starting from n, p and q, on which the private key depends, can be factored.
Secrecy
Asymmetric cryptography allows the requirement of secrecy to be satisfied. Let's see, for example, how a user A can send a message to B while guaranteeing secrecy (even if the message is intercepted, it is unintelligible).
To guarantee the secrecy of communications, user A encrypts the message m with B's public key and sends it. User B receives the encrypted message, decrypts it by applying his private key and thus obtains the original message. By indicating with KB+ the public key of B and with KBโ the private key of B, the operations carried out can be summarized as follows:
A:ย KB+(m)
B:ย KBโ(KB+(m))=m
It should be noted that the message sent by A is unintelligible to everyone except the owner of the private key KBโ. In fact, only the application of this key allows the message to be decrypted.
Authentication
Asymmetric cryptography allows the authentication requirement to be satisfied; that is, for the purposes under consideration, it allows the sender's identity to be verified. Let's see, for example, how user A can Send B a message, and B can verify that only A could have sent the message.
To ensure authentication, user A encrypts message m with his private key and sends it. User B receives the message, applies A's public key, and if he successfully decrypts it, verifies that only A could have sent the message. By indicating with KA+ the public key of A and with KAโ the private key of A, the operations carried out can be summarized as follows:
A:ย KAโ(m)
B:ย KA+(KAโ(m))=m
Please note that the above steps do not guarantee also secrecy, in fact anyone who intercepts A's message is able to read its contents, since A's public key is known to everyone. If one wanted to guarantee both authentication and secrecy, one would have to combine the authentication operations with those related to secrecy. The procedure is left as an exercise to the reader, highlighting how the starting point for A consists in applying his private key not to the cleartext message but to the message encrypted with B's public key (KB+ย ), as follows:
A:ย KAโ(KB+(m))