San Diego State University logo

Encryption: What's in a Secret?

Preliminaries
  • This means the point being made is something to think about.
  •   When you see this symbol it means there's a bumpy ride ahead. Grab hold of your icons!
Definitions

Plain Text
The message being sent, before any transformations have been performed on it.
Cipher Text
The result of transforming a message so that it it can be read onlyby the intended recipient
Encryption Method
A particular scheme for transforming messages.
Encryption Key
A particular piece of information that must be available when encrypting the message according to the encryption scheme.
Decryption Key
A particular piece of information that must be available when decrypting the message according to the encryption scheme. Often the encryption key and the decryption key are the same.
A simple scheme

We need a way of transforming plain text into cipher text. Here's one:

    Plain Text a b c d e f g h i j k l m n o p q r s t u v w x y z
    Cipher Text d e f g h i j k l m n o p q r s t u v w x y z a b c

What's going on: Another view:

    Figure 1

One way to think about this is that we start with the inner and outer circle of letters aligned, which stands for realizing "a" as "a", "b" as "b", and so on.

    Figure 2
Then to get Figure 1, we shift the inner circle three clicks left, aligning outer "a" with inner "d".

Because we shift 3 letters, a => d, b => e, and so on, this is called a "shift 3" cipher.

We can of course shift amounts other than 3. This is the shift-8 cipher:

This is the shift-25 cipher:

There are 25 possible shift ciphers.

Shift-26 is the same as no shift at all,"a=>a, b=>b" and so on:

and therefore shift-27 is the same as shift-1.
Caesar's
Cipher

Julius Caesar is supposed to have used this cipher for military dispatches he wished to keep secret.

Other
Historical
Precedents

According to some, as you probably know, Shakespeare's plays weren't written by Shakespeare; he is supposed to to have displayed much too wide a knowledge of history, statecraft, scripture, and mythology for an uneducated nobody from Stratford. Among the many identities he has been claimed to have, one of the most popular is Francis Bacon. Here's one "argument" for that view:

    The complete name of the real author of the First Folio of Shakespeare's Plays is concealed in the first spoken word. It stands alone as the first word of dialogue on the first page of the first printing of the first play in the First Folio, the 1623 first edition of Shakespeare's collected Comedies Histories and Tragedies. It is a solitary word distinguished by its primal detachment...
    "The Tempest," as recorded in the First Folio, is the sole authority for the language and printing of that fanciful drama. The first word of dialogue in "The Tempest" is "BOte-swaine." The first letter, "B," is a great capital, the kind of large ornamental initial that heads the first page of almost all of the plays. The script, after some "scene setting" instructions which are printed in italics, gives the Master the first word to speak:
    To apply the Caesar decryption here we must remember that the letter "W" is not included in our key alphabet but it corresponds to "V" in the Folio and in the Sonnets. We shall install "BOTE-SVAINE" as the ciphertext and run our computer program:
    B O T E S V A I N E
    C P V F T Y B K O F 1  [Shift-1]
    D Q Y G V A C L P G 2  [Shift-2]
    E R A H Y B D M Q H 3  [Shift-3]
    F S B I A C E N R I 4  [Shift-4]
    
    The plaintext, then, is "F S B I A C E N R I". It appears on the "FORTH" (+4) line in which "A" = "e". Bacon's 21 letter alphabet, ending in "T V Y," remains the same. "FS" is Bacon's own signature abbreviation of his first name while "BIACEN" is yet another phonetic spelling of his surname.
    Here it is necessary to explain that cryptography is a very old technique. Even in antiquity the rule was, whenever the name of a place or person must be repeated in a message, it must always be misspelled. Therefore Bacon's name is never spelled correctly, and there are many alternate forms.

    Ciphertext: A B C D E F G H I K L M N O P Q R S T V Y
    Plaintext:  E F G H I K L M N O P Q R S T V Y A B C D
    
    Here I = J and V = V, U and W. There is no X or Z.
    Thus BOTESWAINE = FS BIACEN, while R and I are nulls.
    FS was often Bacon's signature abbreviation for Francis, and BIACEN is another homophone for his last name.
Encryption
Tool
Demo

You will find a downloadable version of the Encryption Tool here.

Read the installation directions carefully. Basically the download file is a self-extracting executable. Put the file somewhere on your home machine and then click on it. The program will ask you where you want to install it [give it a permanent home]. Pick anywhere --- just make sure you remember where you pick so you can find it later. A reasonable choice is your DeskTop.

Once you find the installed program, just click on it and the following window appears (will look slightly different in Windows):

Shift
Cipher
Keys

Repeating our definitions:

Encryption Key
A particular piece of information that must be available when encrypting the message according to the encryption scheme.
Decryption Key
A particular piece of information that must be available when decrypting the message according to the encryption scheme. Often the encryption key and the decryption key are the same.

By these definitions the encryption key for a shift cipher can just be one of the 25 possible shift values. So our first cipher was a shift-3 cipher, so 3 is the encryption key.

What is the decryption key?

Well once you know how much you shifted you know how much to unshift to decrypt it, so 3 could be the decryption key as well.

But there is another way of looking at it that will be mathematically more useful.

Recall that shifting 26 just gives us back the same letters.

So if we shift 3, followed by shifting 23, that should also give us back the same message.

[shift-3] + [shift-23] = [shift-26] = [shift-0]
Which leads to the following:
    Encryption Key 3
    Decryption Key 23

And then to the following:

    Theorem Shift Cipher Keys
    The sum of the encryption key and the decryption key for a shift cipher will always be 26.

Notice that this way of looking at it is nice if you write computer programs. I need one program called encrypt, which takes 2 pieces of input, a plain text and a shift value, and gives me back a cipher text.

>>> encrypt('the porcupine is under the sheets',3)
'wkh srufxslqh lv xqghu wkh vkhhwv'

But give the same program the cipher text and the decryption key and it gives you the plain text:

>>> encrypt('the porcupine is under the sheets',3)
'wkh srufxslqh lv xqghu wkh vkhhwv'

>>> encrypt('wkh srufxslqh lv xqghu wkh vkhhwv',23)
'the porcupine is under the sheets'
Breaking
Shift
Ciphers

This isnt the part of the course where we talk seriously about breaking ciphers.

But the shift ciphers are so easy to break it's worth mentioning that fact here.

Shift ciphers can be broken by what we call a brute force attack.

Here's the attack:

  1. Apply every possible decryption key from 1 through 25.
  2. Look at the results and see which one makes sense

Here's an example:

 Cipher text: haahjr ha khdu
---------------------------
   Shift: 0:  haahjr ha khdu
   Shift: 1:  ibbiks ib liev
   Shift: 2:  jccjlt jc mjfw
   Shift: 3:  kddkmu kd nkgx
   Shift: 4:  leelnv le olhy
   Shift: 5:  mffmow mf pmiz
   Shift: 6:  nggnpx ng qnja
   Shift: 7:  ohhoqy oh rokb
   Shift: 8:  piiprz pi splc
   Shift: 9:  qjjqsa qj tqmd
   Shift: 10: rkkrtb rk urne
   Shift: 11: sllsuc sl vsof
   Shift: 12: tmmtvd tm wtpg
   Shift: 13: unnuwe un xuqh
   Shift: 14: voovxf vo yvri
   Shift: 15: wppwyg wp zwsj
   Shift: 16: xqqxzh xq axtk
   Shift: 17: yrryai yr byul
   Shift: 18: zsszbj zs czvm
   Shift: 19: attack at dawn
   Shift: 20: buubdl bu ebxo
   Shift: 21: cvvcem cv fcyp
   Shift: 22: dwwdfn dw gdzq
   Shift: 23: exxego ex hear
   Shift: 24: fyyfhp fy ifbs
   Shift: 25: gzzgiq gz jgct
So the decryption key is 19, the encryption key is therefore 7.

This didn't take a lot of cleverness. But there's an important point here.

Most serious encryption methods can be cracked by a brute force attack. The serious question will always be not whether such an attack is possible, but whether it's practical. (for example, will it take longer than the age of the universe to compute?)

This brute force attack was eminently practical.

Encoding

Most serious encryption methods involve applying an encoding step to the plain text.

In the computer world an encoding of a text is just a cipher everyone knows about.

Usually the encoding turns the text into numbers; computers are good with numbers.

For talking about shift ciphers, the following encoding is pretty useful:

    Plain Text a b c d e f g h i j k l m n o p q r s t u v w x y z
    Encoding 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Encrypting
by Arithmetic

Basically once we use the above encoding, encryption can just be addition. For a shift-3 cipher, we add 3:

    Plain Text a b c d e f g h i j k l m n o p q r s t u v w x y z
    Encoding 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    Encryption 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 0 1 2
    Cipher Text d e f g h i j k l m n o p q r s t u v w x y z a b c

But wait, there's something funny going on off to the right. For the encoding of x, y and z.

23 + 3 = 0
"x"     "a"
24 + 3 = 1
"y"     "b"
25 + 3 = 2
"z"     "c"
But this isn't right, is it?

What we want here is clockface addition.

Modular Addition

    Here we are adding 8 to 5 on a "clockface" with 26 hours, 0 - 25 inclusive:

    As usual 8 + 5 = 13.

    But when the numbers and increments get high enough, addition "wraps around":

    23 + 3 = 0. Which is equivalent to saying map "x" to "a". ("x" encodes as 23; "a" as 0).

    24 + 3 = 1. Which is equivalent to saying map "y" to "b". ("y" encodes as 24; "b" as 1).

    25 + 3 = 2. Which is equivalent to saying map "z" to "c". ("z" encodes as 25; "c" as 2).

Basically, this rule will work for any of our 25 possible keys, as long as we follow the clockface rule of starting from 0 again once we get higher than 25:

19 + 11 = 4.

This kind of addition merits a mathematical name. It is called modular addition. We call the number of numbers on the clockface the "modulus". Normal clockface addition is addition "mod 12". Cipher shifting addition is addition "mod 26". We write the above addition as follows:

19 + 11 = 4 mod 26

A brief introduction to modular addition.