Classical Cryptography

Introduction to Cryptography

secret (crypto-) writing (-graphy)

W Diffie, M E Hellman, "Privacy and Authentication: An Introduction to Cryptography", in Proc. IEEE, Vol 67(3) Mar 1979, pp 397-427

Basic Concepts

cryptography
the art or science encompassing the principles and methods of transforming an intelligible message into one that is unintelligible, and then retransforming that message back to its original form
plaintext
the original intelligible message
ciphertext
the transformed message
cipher
an algorithm for transforming an intelligible message into one that is unintelligible by transposition and/or substitution methods
key
some critical information used by the cipher, known only to the sender & receiver
encipher (encode)
the process of converting plaintext to ciphertext using a cipher and a key
decipher (decode)
the process of converting ciphertext back into plaintext using a cipher and a key
cryptanalysis
the study of principles and methods of transforming an unintelligible message back into an intelligible message without knowledge of the key. Also called codebreaking
cryptology
both cryptography and cryptanalysis
code
an algorithm for transforming an intelligible message into an unintelligible one using a code-book

Concepts

Encryption C = E_(K)(P)

Decryption P = E_(K)^(-1)(C)

E_(K) is chosen from a family of transformations known as a cryptographic system.

The parameter that selects the individual transformation is called the key K, selected from a keyspace K

More formally a cryptographic system is a single parameter family of invertible transformations

E_(K) ; K in K : P -> C

with the inverse algorithm E_(K)^(-1) ; K in K : C -> P

such that the inverse is unique

Usually assume the cryptographic system is public, and only the key is secret information

Private-Key Encryption Algorithms

Cryptanalytic Attacks

ciphertext only

known plaintext

chosen plaintext

chosen plaintext-ciphertext

Unconditional and Computational Security

A Brief History of Cryptography

Ancient Ciphers

Machine Ciphers

Classical Cryptographic Techniques

Caesar Cipher - a monoalphabetic cipher

eg.
	L FDPH L VDZ L FRQTXHUHG
	I CAME I SAW I CONQUERED
ie mapping is
	ABCDEFGHIJKLMNOPQRSTUVWXYZ
	DEFGHIJKLMNOPQRSTUVWXYZABC
Encryption E_(k) : i -> i + k mod 26

Decryption D_(k) : i -> i - k mod 26

Cryptanalysis of the Caesar Cipher

				GDUCUGQFRMPCNJYACJCRRCPQ
				HEVDVHRGSNQDOKZBDKDSSDQR
	Plain	-	IFWEWISHTOREPLACELETTERS
				JGXFXJTIUPSFQMBDFMFUUFST
				KHYGYKUJVQTGRNCEGNGVVGTU
	Cipher -	LIZHZLVKWRUHSODFHOHWWHUV
				MJAIAMWLXSVITPEGIPIXXIVW	
Single Letter              Double Letter             Triple Letter              
E                          TH                        THE                        
T                          HE                        AND                        
R                          IN                        TIO                        
N                          ER                        ATI                        
I                          RE                        FOR                        
O                          ON                        THA                        
A                          AN                        TER                        
S                          EN                        RES                        

Character Frequencies

[1]
  • do need a moderate amount of ciphertext (100+ letters)

    Modular Arithmetic monoalphabetic cipher

    E_(a b) : i ->a.i + b mod 26

    nb a must not divide 26 (ie gcd(a,26) = 1)

    otherwise cipher is not reversible eg a=2

    and a=0, b=1, c=2 ... , y=24, z=25

    Cryptanalysis:

    Example - Sinkov pp 34-35

    Mixed Alphabets

    Plain:   ABCDEFGHIJKLMNOPQRSTUVWXYZ
    Cipher:  DKVQFIBJWPESCXHTMYAUOLRGZN
    Plaintext:  IFWEWISHTOREPLACELETTERS
    Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
    
    !!!WRONG!!! 1) there is lots of statistical information in message

    2) can solve the problem piece by piece

    (ie can get key nearly right, and nearly get message)

    (near enough MUST NOT be good enough!)

    Cryptanalysis

    General Monoalphabetic

    Example Seberry p66

    	STARW
    	BCDEF
    	GHIJK
    	LMNOP
    	QUVXY
    	Z
    
    Plain:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
    Cipher: SBGLQZTCHMUADINVREJOXWFKPY
    
    Plaintext:  I KNOW ONLY THAT I KNOW NOTHING
    Ciphertext: H UINF NIAP OCSO H UINF INOCHIT
    

    Polyalphabetic Substitution

    Vigenère Cipher

    Plaintext	THISPROCESSCANALSOBEEXPRESSED
    Keyword		CIPHERCIPHERCIPHERCIPHERCIPHE
    Plaintext	VPXZTIQKTZWTCVPSWFDMTETIGAHLH
    

    
       ABCDEFGHIJKLMNOPQRSTUVWXYZ
    
    A  ABCDEFGHIJKLMNOPQRSTUVWXYZ
    B  BCDEFGHIJKLMNOPQRSTUVWXYZA
    C  CDEFGHIJKLMNOPQRSTUVWXYZAB
    D  DEFGHIJKLMNOPQRSTUVWXYZABC
    E  EFGHIJKLMNOPQRSTUVWXYZABCD
    F  FGHIJKLMNOPQRSTUVWXYZABCDE
    G  GHIJKLMNOPQRSTUVWXYZABCDEF
    H  HIJKLMNOPQRSTUVWXYZABCDEFG
    I  IJKLMNOPQRSTUVWXYZABCDEFGH
    J  JKLMNOPQRSTUVWXYZABCDEFGHI
    K  KLMNOPQRSTUVWXYZABCDEFGHIJ
    L  LMNOPQRSTUVWXYZABCDEFGHIJK
    M  MNOPQRSTUVWXYZABCDEFGHIJKL
    N  NOPQRSTUVWXYZABCDEFGHIJKLM
    O  OPQRSTUVWXYZABCDEFGHIJKLMN
    P  PQRSTUVWXYZABCDEFGHIJKLMNO
    Q  QRSTUVWXYZABCDEFGHIJKLMNOP
    R  RSTUVWXYZABCDEFGHIJKLMNOPQ
    S  STUVWXYZABCDEFGHIJKLMNOPQR
    T  TUVWXYZABCDEFGHIJKLMNOPQRS
    U  UVWXYZABCDEFGHIJKLMNOPQRST
    V  VWXYZABCDEFGHIJKLMNOPQRSTU
    W  WXYZABCDEFGHIJKLMNOPQRSTUV
    X  XYZABCDEFGHIJKLMNOPQRSTUVW
    Y  YZABCDEFGHIJKLMNOPQRSTUVWX
    Z  ZABCDEFGHIJKLMNOPQRSTUVWXY
    
    given K = k_(1) k_(2) ... k_(d)

    then f_(i) (a) = a + k_(i) (mod n)

    Beauford Cipher

    given K = k_(1) k_(2) ... k_(d)

    then f_(i) (a) = (k_(i) - a) (mod n)

    and its inverse is

    f_(i) ^(-1)(a) = (k_(i) - c) (mod n)

    Example - Seberry p71

    Key = d
    Plain:   ABCDEFGHIJKLMNOPQRSTUVWXYZ
    Cipher:  DCBAZYXWVUTSRQPONMLKJIHGFE
    
    

    Variant-Beauford Cipher

    given K = k_(1) k_(2) ... k_(d)

    then f_(i) (a) = a - k_(i) (mod n)

    Language Redundancy & Unicity Distance

    D = F(H(M),k) N = F(H(K),D)

    where H(K) is entropy (amount of info) of the key,

    and is D the rate of the language used (eg 3.2)

    N = F(H(K),D) = F(log_(2)26,3.2) = 1.5

    hence only need 2 letters to break

    N = F(H(K),D) = F(log_(2)n!,D) = F(log_(2)26!,3.2) = F(26 log_(2)F(26,e),3.2) = 27.6

    hence only need 27 or 28 letters to break

    N = F(H(K),D) = F(log_(2)s^(d),D) = F(d log_(2)26,3.2) = 1.5d

    hence need 1.5 times the number of separate substitutions used letters to break the cipher


    Kasiski Method

    Example - Seberry p71

    Plaintext:   TOBEORNOTTOBE
    Key:         NOWNOWNOWNOWN
    Ciphertext:  GCXRCNACPGCXR
    

    Since repeats are 9 chars apart, guess period is 3 or 9.

    Index of Coincidence

    see Seberry Table 3.2 p72 and Table 3.3 p74

    d           IC              
    1           0.0660          
    2           0.0520          
    3           0.0473          
    4           0.0450          
    5           0.0436          
    6           0.0427          
    7           0.0420          
    8           0.0415          
    9           0.0411          
    10          0.0408          
    11          0.0405          
    12          0.0403          
    13          0.0402          
    14          0.0400          
    15          0.0399          
    ...         ...             
    Inf         0.0380          
    
    
    	Table 3.3 - Period and IC for English
    
    		MR = Isu(i=o,n-1,(p_(i) - F(1,n))^(2))
    
    where p_(i) is probability an arbitrary character in ciphertext is the ith character a_(i) in the alphabet
    			 Isu(i=o,n-1,p_(i)) = 1
    
    		MR = Isu(i=o,n-1,p_(i)^(2)) - 0.038
    
    or
    		MR + 0.038 = Isu(i=o,n-1,p_(i)^(2)) 
    
    is prob two arbitrary letters in ciphertext are the same eg MR for English is 0.028 (0.066 - 0.038)
    		Bbc[(S(N,2)) = F(1,2) N (N-1)
    
    		F(F_(i)(F_(i)-1),2)		and	Isu(i=o,n-1,F_(i)) = 1
    
    	IC = 	Isu(i=o,n-1,F(F_(i)(F_(i)-1),N(N-1)))
    
    and use the IC estimate in
    		MR + 0.038 = IC 
    
    		0.038 < IC < 0.066
    
    		Exp(IC) = F(1,d) F(N-d,N-1)(0.066) + Bbc[(S(d-1,d))F(N,N-1)(0.038)
    
    and we can use these values to estimate d from the ciphertext

    Example program to compute IC - Seberry Fig3.4 p74

    Solving Polyalphabetic Ciphers

    Example - Seberry pp73-77

    Krypto program

    krypto [file]
           Command                                    Meaning                            
    ?                       this message.                                                
    !                       execute a shell command.                                     
    f [<seqlen> [n]]        print [the n most] frequent strings of length seqlen.        
    g [<d> <p>]             print the frequency distribution graph of letters.           
    i [<p>]                 calculate the index of coincidence of the text.              
    l [<b> <B>]             list only the modified string.  [b=blklength, B=blks/line]   
    p                       print current code.                                          
    q                       exit.                                                        
    s <ch1> <ch2>           substitute ch2 for ch1.                                      
    S [-] -[gvbB] {keys}    Perform the substitution specified by the key.               
    T [-] <perm>|key        Transpose text by perm or keyword. e.g. T 4,5,2,3,1          
    t <n> [/regexp]         look for transpositions of period n;  [print only /regexp].  
    B [-] <perm>|key        apply the specifed rectangular encryption to the text.       
    b <n> [/regexp]         look for block decryptions of size n;  [print only           
                            /regexp].                                                    
    u                       undo previous modification.                                  
    z                       reset the code to its initial state.                         
    r <file>                enter code from file.                                        
    w <file>                write code to file.                                          
    e                       edit code.                                                   
    
    

    Transposition Ciphers

    Scytale cipher

    For information on lots of simple substitution and permutation ciphers see:

    Reverse cipher

    Plain:	I CAME I SAW I CONQUERED
    Cipher:	DEREU QNOCI WASIE MACI
    
    

    Rail Fence cipher

    Plain:	I A E S W C N U R D
             C M I A I O Q E E 
    Cipher:	IAESW CNURD CMIAI OQEE
    
    

    Geometric Figure

    Row Transposition ciphers

    
    Plain:	THESIMPLESTPOSSIBLETRANSPOSITIONSXX
    Key (R):      2 5 4 1 3	
    Key (W):                           4 1 5 3 2 	
    
                  T H E S I		S T I E H 	
                  M P L E S		E M S L P 	
                  T P O S S		S T S O P 	
                  I B L E T		E I T L B 	
                  R A N S P		S R P N A 	
                  O S I T I		T O I I S 	
                  O N S X X		X O X S N 
    Cipher:	STIEH EMSLP STSOP EITLB SRPNA TOIIS XOXSN
    

    Example - Davies p26 Fig 2.14

    
    Plain:	ACONVENIENTWAYTOEXPRESSTHEPERMUTATION
    Key (W):      C O M P U T E R
    Key (W):      1 4 3 5 8 7 2 6
     	
                  A N O V I N C E
                  E W T A O T N Y
                  H E P R T U E M
                  A O I N Z Z T Z
    
    Cipher:       ANOVI NCEEW TAOTN YHEPR TUEMA OINZZ TZ
    

    Example - Davies p26 Fig 2.15

    Key(R):	sorcery => 6 3 4 1 2 5 7
    laser beams can be modulated to carry more intelligence than radio waves
    
    gives
    erasb lecam snabd umole atoed ctamo ryrre elntl iicee ntgha dnria oesav w
    

    Cryptanalysis of Row Transposition ciphers

    Example - Seberry p67-8 [3]

    N = F(H(K),D) = F(log_(2)d!,D) = F(d log_(2)(d/e),3.2)

    Seberry Table 3.1 p69


    Block (Columnar) Transposition ciphers

    
    Key(R):       s o r c e r y        s o r c e r y
    Key(R):       6 3 4 1 2 5 7        6 3 4 1 2 5 7
    
                  l a s e r b e        l a s e r b e
                  a m s c a n b        a m s c a n b
                  e m o d u l a        e m o d u l a
                  t e d t o c a        t e d t o c a
                  r r y m o r e        r r y m o r e 
                  i n t e l l i        i n t e l l i
                  g e n c e t h        g e n c e t h
                  a n r a d i o        a n r a d i o
                  w a v e s            w a v e s q r
    
    
    ecdtm ecaer auool edsam merne nasso dytnr vbnlc rltiq laetr igawe baaei hor

    Example - Sinkov p148

    Sinkov p148

    Cryptanalysis of Block Transposition ciphers

    Example - Sinkov p 149-151

    Nihilist ciphers

    Plaintext:    NOWISTHETIMEFORALLGOODMEN
    
    Key (W):             L E M O N
                         2 1 3 5 4
                  L 2    O N W S I
                  E 1    H T E I T
                  M 3    E M F R O
                  0 5    L A L O G
                  N 4    D O M N E
    
    Nihilist Cipher:     HTEIT ONWSI EMFRO DOMNE LALOG
    
    Diagonal Cipher:     ONHET WSEML DAFII TRLOM OOGNE
    
    
    Example - Davis Fig2.16 p27

    Product ciphers

    ADFGVX Product Cipher

    	
    Substitution Table
    
    
    \\    A     D     F     G     V     X     
    A     K     Z     W     R     1     F     
    D     9     B     6     C     L     5     
    F     Q     7     J     P     G     X     
    G     E     V     Y     3     A     N     
    V     8     O     D     H     0     2     
    X     U     4     I     S     T     M     
    
    
    
    	Plaintext:	PRODUCTCIPHERS
    	
    	Intermediate Text:
    				FG AG VD VF XA DG XV
    				DG XF FG VG GA AG XG
    
    Keyed Block Columnlar Transposition Matrix
    
    
    D     E     U     T     S     C     H        Key                     
    2     3     7     6     5     1     4        Sorted Order            
    F     G     A     G     V     D     V                                
    F     X     A     D     G     X     V                                
    D     G     X     F     F     G     V                                
    G     G     A     A     G     X     G                                
    
    
    
    	Ciphertext:	DXGX FFDG GXGG VVVG VGFG CDFA AAXA
    

    [1] follow w Seberry App A-1 p1; Sinkov Ex 9 & 10 p 20
    [2] see Seberry Section 2.4 for detailed derivations
    [3]follow with example Seberry p68
    [CSC Info]
    Lawrie.Brown@adfa.oz.au / 22-Feb-96