Originally published 11 May 2001. Republished with permission from WatchGuard Technologies, Inc.


Foundations: Cryptography 101

by Fred Avolio, President, Avolio Consulting

Data and information residing on computers and flowing over telephone and network connections is vulnerable to theft, modification, and forgery. This article, aimed at the neophyte, looks at a technique used to secure transmissions over a network or to protect data files as they reside on a computer. The technique is called cryptography.

Basics and Terminology

Ciphers, codes, and secret writing have been around longer than history has been recorded. They have been around as long as people have needed to communicate secrets over long distances (battle plans sent by carrier pigeon, for example). They have been around as long as people have received important messages from afar (orders sealed with a monarch’s signet ring). People still use the modern equivalents.

The American Heritage® Dictionary of the English Language defines cryptography as “the process or skill of communicating in or deciphering secret writings or ciphers.” A cipher is a message written in a secret code.

We use cryptography when we hope to provide  three types of security for our data:

1.   Confidentiality. This simply means keeping our data secret, available only to authorized individuals. We lock up our information, and only someone with the proper key code (like the combination to a lock) can unlock it.

2.   Authentication with non-repudiation.  Authentication allows someone to be certain about who originated (created, wrote, or sent) the information. Non-repudiation is the other side of the “authentication” coin. If we  can prove who originated the data, he or she cannot deny it.

3.   Integrity.  This doesn’t  stop information from being modified or falsified, but if data has been protected for integrity, modification can be easily detected.  Cryptographic techniques do not tell us how the information has been modified, just that it has been changed from its original form.

Cryptography usually involves two processes: encryption and decryption. Encryption is like locking our data, and decryption is like unlocking it. We lock information (a file, an e-mail message, a disk image — any data) in a way that allows  the right person to unlock it again. In the digital world, this is accomplished using mathematical algorithms. The data is processed through the algorithm with a large number, called a key, converting (encrypting) it. Similar to the world of physical locks, the way we make sure that only authorized individuals can unlock information we have locked is by using different key codes. There are two types or classes of cryptography, secret key and public key.

Secret Key Cryptography

With secret key cryptography, when we lock up the data using a unique key code, we can unlock it only by using that same key code. For this reason, secret key cryptography is also called symmetric cryptography. So, if Pasha wants to encrypt (lock) a message so that only Tania and he can decrypt (unlock) it, he must make sure that Tania knows the key code he uses. Like a strongbox shipped by a parcel delivery service, the information within is safe assuming only these two people know the combination to open the box. The only stumbling block is, how do Pasha and Tania decide on a key code to use? Easy if they live in the same house. Hard if they are on different continents. One could e-mail the key code to the other … but then eavesdroppers or Internet thieves might intercept the key.

If someone stole the strong box, they could try to open it by attempting every possible key code. This is called a brute force attack. If the lock is a  three-tumbler luggage lock, with each tumbler showing 0 through 9, the would-be data thief has 1,000 combinations to guess. Anyone could open the strongbox in a matter of minutes. For Internet cryptography, we use very large key codes. A bad guy would have to guess at the combination to the lock from out of a space (a key space, we call it) of roughly 1 followed by 38 zeros. Even using a very, very, very fast computer to do the guessing, faster than any computer in existence today, it would take, on average,  two million-million- million (2 followed by 18 zeroes) years to guess. This is bad for our two friends if they forget the combination to the lock. But it is very good if they care to protect their message from eavesdroppers. And, yes, with a physical strong box someone could try to cut through the box. But for our analogy, consider the strongbox indestructible.

Most data securely transmitted over the Internet is protected by secret key cryptography.

Public Key Cryptography

Public key cryptography uses a pair of key codes — a key pair. These two key codes are related to each other in this way: if you lock-up data using one key code, you can only unlock it using the other key code. And vice versa. This is very different from what we are used to with physical locks, but it is a powerful mechanism.

Suppose Lena has a public/private key code pair, as I just described. Her public key should be public, so that anyone in the world can use it when they want to lock-up a strong box in such a way that Lena and only Lena can unlock it. Remember, if it is locked using her public key code, only her private key can unlock it. This is why she must keep her private key secret. No one else must be able to know or be able to use her private key code. If Lena alone has access to it, Lena is the only one who can unlock the message.

But wait, there’s more. Using public key cryptography, we can achieve authentication with non-repudiation, as well as integrity confirmation.  Suppose Lena wants to seal and certify a data file such that anyone in the world can read it and can tell that Lena did create it. She locks up the message using her private key code. Now who can unlock it? Anyone in the world with Lena’s public key code. Anyone can prove that it came from her, because if it unlocks with her public key code it must have been locked with her private key code. And only she can use her private key. Sealing a message or a file in  this manner is called digitally signing it.

If we also want to protect the message from unauthorized eyes, we can then encrypt the signed message before we send it. Using our example, Lena can digitally sign the message, as described, and then take the result and lock it using Oksana’s public key code and send it to her. Then Oksana (and only Oksana) can unlock it using her private key code, and then take the result and unseal it using Lena’s public key. The result is the unlocked message. Oksana knows that only Lena could have sent it.

In this way we get authentication and non-repudiation, but what about integrity? In the example as described, the message could not have been changed since Lena used her private key code to seal it. If we want to store the message in unsealed form, so that it is easily accessible, we can keep the digital signature around to check the plain version against the sealed version any time that we want.

Putting It Together

I’ve left out some steps to simplify matters. For example, the key codes or combinations we discussed are properly called keys, but they are in fact very large numbers, so thinking of them as key codes is accurate, even if the nomenclature is not. Next, when someone digitally signs a message, they really sign a summary of a message, a fairly unique but smaller representation of the data also called a message hash or message digest. And whole chapters have been written about how and why to combine secret key crypto, which calculates very rapidly, and public key crypto, which is slow. 

One article can’t make you an expert on encryption. But my hope is that now the topic doesn’t intimidate or confuse you. If this has whet your appetite for more crypto knowledge, be sure to check out the resources listed below. ##

For Further Reading

From beginner to advanced:

Gardner, Martin, Codes, Ciphers and Secret Writing, (October 1984), Dover Publications; ISBN: 0486247619.

Smith, Richard E., Internet Cryptography, 1st edition (January 15, 1997), Addison-Wesley Pub Co; ISBN: 0201924803.

Schneier, Bruce, Applied Cryptography: Protocols, Algorithms, and Source Code in C, 2nd edition, (October 18, 1995), John Wiley & Sons; ISBN: 0471117099.

Copyright © 1996 – 2001 WatchGuard Technologies, Inc. All rights reserved.
Legal Notice/Terms of Use