Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Introduction to Encryption and Cryptography. Join the course to learn more.

Skip to 0 minutes and 3 secondsModern encryption techniques fall into two categories-- symmetric and asymmetric. Symmetric encryption uses the same key to encrypt and decrypt the data. It's like putting a secret into a locked box. The same key can lock and unlock the box. Symmetric encryption is useful when the same person does both the encryption and decryption. For example, if you encrypt your hard drive, the only person who needs to know the encryption key is you, because only you should be able to decrypt it. But if you use symmetric encryption to send secret information to someone, they also need a copy of the key you used to encrypt the information. And communicating the key risks the key being read by eavesdroppers.

Skip to 0 minutes and 42 secondsAsymmetric encryption, also known as public key cryptography, overcomes this key sharing problem. It uses two different keys-- a public key to encrypt the message and a private key to decrypt it. The public key can be given to anyone, because it's only useful for encrypting the data. Knowing the public key doesn't make it any easier to decrypt the data. Only the private key can be used to do that. For example, imagine Cerys wants to send a message to Sanjay. First, Sanjay creates a pair of private and public keys and sends the public key to Cerys. Cerys writes a message for Sanjay, encrypts her message using the public key, and sends the cipher text to Sanjay.

Skip to 1 minute and 21 secondsOnce Sanjay receives the cipher text, they can decrypt using the private key. Even if a hacker intercepts the cipher text, only Sanjay has the private key, so only they can decrypt. Asymmetric encryption systems are better suited to sending secure information than symmetric systems are. However, symmetric encryption requires fewer resources and can be faster than asymmetric systems. So with this in mind, is the Vigenère cipher a symmetric or asymmetric encryption scheme? And would you use symmetric or asymmetric encryption to send your credit card details to a website?

Symmetric and asymmetric encryption

Modern encryption techniques can broadly be sorted into two categories: symmetric encryption and asymmetric encryption. In this step, you will learn about these two types of encryption and how they are used.

Symmetric encryption

In a symmetric encryption scheme, the same key is used to encrypt and decrypt the data. Symmetric encryption can be thought of like putting a secret into a locked box. The same key will open and lock the box.

A message is put into a box, which is then locked with a key

This kind of encryption is most useful when the same person intends to do the encryption and decryption. For example, if you encrypt your hard drive, the only person who needs to know the encryption key is you, as only you should be able to decrypt it.

However, if you want to send a secret message to someone else and use a symmetric encryption scheme, they have to have a copy of the key you used to encrypt the message. Communicating the encryption key can be difficult, as it risks the key falling into the wrong hands, which would make your message vulnerable to being read by others. To protect the key, you might try encrypting it as well, but you would still have the problem of telling your recipient what that encryption key is.

Asymmetric encryption

Asymmetric encryption (also known as public-key cryptography) uses a different key to encrypt and decrypt a message. This solves the problem of key sharing in symmetric encryption schemes.

The key generation algorithm of an asymmetric encryption scheme generates two keys: one is called the public key and the other is called the private key. The public key is used for encrypting data and the private key is used for decrypting.

The keys are generated in such a way that the public key can be given to anyone (that is, made public) because it can only be used to encrypt data. Knowing the public key does not make it easier to decrypt information; only knowing the private key allows you to do that.

Animation - Sanjoy creates a pair of keys, and sends one to his friend, Cerys. Cerys types a message to Sanjoy, and uses her key to lock it. Sanjoy uses his key to unlock and read the message. An eavesdropper only sees nonsense.

Suppose you want to send a secret message to someone. Instead of putting the message in a locked box and working out how to also send them a key, you could ask them to send you a padlock for which they already have the key. You can write your message, put it in a box and lock it with the padlock, then send the whole thing back to the recipient, who can open it easily because they have the key. In this system, the key doesn’t have to be sent anywhere.

Asymmetric encryption systems are better suited to sending messages than symmetric encryption systems. However, they are more complex and it takes more resources for computers to complete the key generation, encryption, and decryption algorithms. They are therefore less suited to tasks that can be performed using symmetric encryption.

Next steps

In the next step you will learn more about symmetric encryption.

Questions

  • Is the Vigenère cipher a symmetric or asymmetric encryption scheme?
  • Would you use a symmetric or asymmetric encryption scheme to send your credit card details to a website?
  • Would an online cloud storage system be better served by a symmetric or asymmetric encryption scheme?

Share your answers in the comments section.

Share this video:

This video is from the free online course:

Introduction to Encryption and Cryptography

Raspberry Pi Foundation