← All writing

Symmetric vs Asymmetric Cryptography

3 ‘Key’ Understandings

Let us lean toward an intermediate understanding today! Before you can denote any form of specificity or perhaps discern “tusk to type”, as some might say, you had better understand the underlying system, machine, or perhaps derive the species. But this is not being written to explain the difference between a boar and an elephant; that would be… boring.

Before proceeding, it will serve you justly to know : Keys are a lot like passwords. Keys are sequences of information which can be manipulated and obfuscated by a mathematical algorithm.

Symmetric Cryptography

Right to it then! Now that we’ve left the animal kingdom lets disembark upon a perilous path. Because what isn’t perilous about sharing your locker key with hundreds of people? In symmetric cryptography this is exactly what is going on: A critical piece of information must be kept under lock and key, but multiple people may need access to it.

To accomplish this, a secret key is generated and ironically shared if need be. This key may encrypt and decrypt our data. Symmetric cryptography really is that simple. Symmetric cryptography is also a fast approach and still capable of securing entire directories. This is due to the simplicity of the math involved; symmetric algorithms get by on cheap operations like substitutions, shuffles and XORs, whereas their asymmetric cousins must wrestle with enormous numbers. Symmetric algorithms come in two flavors, block ciphers and stream ciphers (more to be understood from a future post). Symmetrical cryptography requires only one relationship between key and data — between enciphering and deciphering.

Symmetric cryptography: a single shared key both encrypts and decrypts the data, and every participant holds a copy

The secret keys are shared among the users who will require access to the data. So, great! Only someone with one of the many necessary copies of the secret key can access the information that has been classified as confidential. Sounds like the first paragraph of a risk acceptance doc. Not Great.

Problems with Symmetry

With virtually limitless keys, there is a great risk to be named when someone happens upon or is even naively granted (or literally handed [hardware]) one of the secret keys. Furthermore, the situation grows in complexity as you require secure communications between each of your peers involved. This is a simple concept, but still worth conceptualizing with a little math. K = 100 * (100-1)/2 — This means that if 100 people wanted to communicate securely between each other, you would need K=4950 keys to be generated. Therefore symmetric cryptography is born a bad solution while standing alone. It still serves a very clever purpose as you will discover after another briefing.


Asymmetric Cryptography

Some might intuitively consider the design of asymmetry to correlate well with matters concerning obfuscation. Well, you’re right!

In asymmetric cryptography the user commands 2 keys. What one key encrypts, the other deciphers. This is typically imagined as the client’s public and private keys, respectively. In fact asymmetric cryptography is ubiquitously referred to as public key cryptography. Am I confusing you yet? I hope to in some way. Thats security through obscurity! Kidding — real cryptography assumes the algorithm is public knowledge and only the key is kept secret. (It may or may not be worth noting that the terms enciphering and encrypting, as well as deciphering and decrypting are interchangeable to one another.)

Asymmetric cryptography: public keys are exchanged, data is encrypted with the acquired public key, and each user's private key decrypts it

One user must have the other user’s public key in order to encipher a message asymmetrically, for that user; meaning that the message that Alice will send to Jim will be enciphered with Jim’s public key , which could have been downloaded, or emailed or even copied from Jim’s cloud source. Your public key’s are for anyone to acquire so that someone else can send you encrypted data. (Just be sure the key you acquired really is Jim’s and not an impostor’s; that is what certificates are for.) As you can see in the diagram, Alice has encrypted a message for Jim, through the use of Jim’s public key and Jim has done the same for Alice with her public key. Remember that a user’s public and private keys are mathematically related (seen as Jim’s yellow and his red keys; and Alice’s blue and red keys). How? Private keys recognizes the mathematical encoding scheme (algorithm) of their public key counterparts. Check out the theoretical reasoning to this relationship in trapdoor functions. (and please don’t forget to donate to the wikipedia foundation once in a while)

As you have seen several things are happening in a very concise but vague order. To be more realistic :

  1. Alice finds Jim’s key through the company’s authoritative directory, she thinks she found evidence that an admin is bribing their coffee distributor and hoarding all the good brew!
  2. Meanwhile Jim acquires Alice’s key from the same repository because he needs to know which dentist Alice prefers which she keeps on her company profile.
  3. The messages are encoded with each of their own acquired public key.
  4. Finally after the digital transit (be it email or some proprietary convention) the messages are decoded by the recipient by using their private keys.
  5. The coffee distributor gets laid off.

So what have we fortified with this approach?

  • Key Distribution. If Jim wanted to know everyone elses dental provider, he would only need to acquire their public key and send them the enciphered message. This opposes symmetric cryptography in that the public keys are unique to each entity, not each session.
  • Less Exposure. With only one key pair per person, and a private key that never leaves its owner, the chances of a hacker or that of a social engineer acquiring a secret key is severely reduced.
  • Confidentiality. The message may only be decrypted by the individual or entity which it is intended for.

To be more or less succinct, symmetric cryptography also provides confidentiality; with less and less surety as the pile of shared keys grows. Note that neither approach, by itself, proves that a message wasn’t tampered with or who really sent it. Integrity and authenticity are the business of MACs and digital signatures.

Cons, of Course?

Asymmetric methods involve more computing power and can therefore take hundreds, even thousands of times longer to produce cryptographic results when compared to symmetric cryptography.


Hybrid Cryptography

The last and by far the most practical method of cryptography is Hybrid Cryptography; it is what TLS, SSH and PGP actually use. Lets gently glide through the most complicated form, which is no stronger than its parts but gets the best out of both.

Simply put, hybrid cryptography uses a symmetric key to encode your files and messages, and an asymmetric exchange to encode this key! It really is as utterly brilliant as it sounds. This concept really takes full advantage of the temporal diversity of computer science, on an interactive level.

Likewise to the secret key of symmetric cryptography, the session key may be used to both encipher and decipher a document. The difference lies in its life-cycle. Ninety nine out of one hundred times the session (secret) key is once used, the session key explodes in a fiery inferno, or if you’re lucky it ends up as a bunch of zeros/nots in your disk. A persistent session key could be considered bad if not fatal practice given the organization.

Hybrid cryptography: a session key encrypts the message, the recipient's public key encrypts the session key, and the session key is destroyed after use

Step by Step :

  • Alice generates a random session key, right there on her own machine.
  • Alice uses the session key to encrypt a message for Yoshi.
  • Alice then acquires Yoshi’s public key and encrypts the session key.
  • The encrypted session key & Alice’s encrypted message are both sent to Yosh.
  • Yoshi deciphers the session key with his private key, rendering it readable by those < 1337 (sidenote — private keys decipher and sign. When private keys “encrypt” something, they don’t actually encrypt it, they sign it).
  • Yoshi deciphers the message.
  • The key is canned.
  • Jim still hasn’t found a dentist he can trust.

Because the session key is destroyed, it may be referred to as being an ephemeral key. This concept brushes up against another concept called forward secrecy (or perfect forward secrecy), but beware: the exchange above does not achieve it. If an eavesdropper records the transmission and later compromises a long term key, such as Yoshi’s private key, they can decipher the session key and then the message, no matter how fiery the inferno was. True forward secrecy demands that the session key never travels at all. Instead both parties derive it through an ephemeral key exchange such as Diffie-Hellman, and the long term keys are only used to sign that exchange. This is why TLS 1.3 retired the approach shown here in favor of ephemeral Diffie-Hellman.


That was a lot of information presented as clearly as I know how to describe an intentionally obfuscated system. I hope you’ve learned a bit and have a slightly better understanding of the overarching mechanisms employed in many crypto-systems. Thank you for reading.

← All writing