15
Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic methods. Plaintext P = the original message. Encryption E k : Encoding the contents of the message to hides its contents from outsiders. Ciphertext C: The encrypted message. Decryption D k : The process of retrieving the plaintext from the ciphertext. Key K: Encryption and decryption usually make use of a key, and the coding method is such that decryption can be performed only by knowing the proper key. Cryptosystem= finite set of plaintexts P + finite set of ciphertexts C + set of keys K+ set of encryption functions E k and corresponding decryption functions D k for each key k from K, such that D k [E k (x)] = x. Cryptanalysis: is the art of breaking ciphers without knowing the proper key. Cryptographers: People who do cryptography. Cryptanalysts: practitioners of cryptanalysis.

Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

  • View
    233

  • Download
    5

Embed Size (px)

Citation preview

Page 1: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Cryptography• Cryptography: art or science of keeping messages secret

• Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic methods.

• Plaintext P = the original message.

• Encryption Ek : Encoding the contents of the message to hides its contents from

outsiders.

• Ciphertext C: The encrypted message.

• Decryption Dk : The process of retrieving the plaintext from the ciphertext.

• Key K: Encryption and decryption usually make use of a key, and the coding method is such that decryption can be performed only by knowing the proper key.

• Cryptosystem= finite set of plaintexts P + finite set of ciphertexts C + set of keys K+ set of encryption functions Ek and corresponding decryption functions Dk for each key k from K, such that Dk[Ek(x)] = x.

• Cryptanalysis: is the art of breaking ciphers without knowing the proper key.

• Cryptographers: People who do cryptography.

• Cryptanalysts: practitioners of cryptanalysis.

Page 2: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

General ProcessE=Plaintext P= Numerical Representation

Encryption E Decryption D

C=E(P) P=D(C)

C= Ciphertext C= Numerical Represeantion

Page 3: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

8.1. Character CiphersNumerical Transformation:

Restriction to the alphabet and to English work modulo 26 (finite representation of large to infinite number of words/plaintexts)

Letter A B CD E F GH I J K L M N O P Q R S T U V W X Y Z

Numerical value

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

Frequency in %

7 1 3 413 3 2 3 8 <1

<1

4 3 8 7 3 <1

8 6 9 3 1 1 <1

2 <1

Page 4: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

8.1.1. Caesar Cipher (Shift)• Key: k between 1 and 25• Encryption: P C= E(P) = P + k• Decryption: C P= D(C) = C – k• Example with k=3:

P= HEY = 7 4 24

C= P+ 3 (mod 26) = 10 7 27= 10 7 1 = KHA

C=AHK = 1 7 10

P= C-3 (mod 26) = -2 5 7 = 24 5 7 = YEH

Page 5: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Cryptanalysis of Shift cipher • Given C, find k and P?

• Use the frequency of letter.

• Example:

C=YFXMPCESPZCJTDFDPQFWQZCPYNTASPCTYRXPDDLRPD

Most frequent letters are (decreasing): P, C, D,F,T,Y

Initial guess: E P, thus E+k=P 4+ k = 15 (mod 26)

k = 15-4=11 (mod 26)

P=C-11 (mod 26)

Thus

P = NUMEBRTHEORYISUSEFULFORENCIPHERINGMESAGES

= NUMEBR THEORY IS USEFUL FOR ENCIPHERING MESAGES

Page 6: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Cryptology Tools section(online PARI/GP)• Frequency Count: cut-and-paste a block of text to return the counts of letters from A to Z.

• Letter Block Count: to count the frequency of blocks of consecutive letters (bigrams, trigrams, etc.) in a text.

• Subtext Count: This tool gives the letter frequencies of a subtext of a given text, consisting of each n-th letter starting with the k-th one.

• Caesar Cipher: This tool encodes and decodes according to the simple shift cipher

• Affine Ciphers: This encodes and decodes texts by affine transformations .

• General Monoalphabetic Cipher: This encodes and decodes text using a monoalphabetic substitution.

• Babbage-Kasiski Method: This tool tabulates repeated blocks in any text and gives the distances (in numbers of letters) between the repetitions. The method of Babbage and Kasiski involves looking for common factors in these distances as a guess for the length of the keyword. The distances are factored to aid this guess. Friedman's Method: This tool calculates the index of coincidence of any text and uses that to guess the length of the keyword (or more generally the number of alphabets in a polyalphabetic cipher).

• Subtext Count: This is the same tool as mentioned above for counting subtext frequencies. Once you have a reasonable guess for the keyword length, use this tool to guess the individual keyword letters.

• Keyword Guesser: This tool is a shortcut that guesses the keyword based on the keylength and on identifying the most common cipher letter as the translation of `E'. This is not always a good choice!

• Frequency Chart Alignment: Use this tool to additively shift a ciphertext to fit the pattern of English letter frequencies.

Page 7: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

8.1.2. Affine Cipher• P C = a P + b• C P = ā (C – b)• Key: a & b between 0 & 25 with (a,26)=1• Phi(26)= only12 possible values for a.

• Reminder: Euler’s theorem: (a,26)=1 → aΦ(26) Ξ 1 (mod 26) Corollary: (a,26)=1 → ā Ξ aΦ(26)-1 (mod 26) Solving ax Ξ c (mod 26) x Ξ ā c (mod 26)

a 1 3 5 7 9 11 15 17 19 21 23 25

ā 1 9 21 15 3 19 7 23 11 5 17 25

Page 8: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Cryptanalysis• From C find x=a & y=b then P: C=xP+y?• Use the most two frequent letters to create two linear

equations with two unknown. • C=JAPXMSJGYPGDZWJPGJEGHDSSLBGWPGJYHVPOODCJZDMYJW

ZWFMGPCPSFBDBVHWNB

• Most frequent letters: G 7, J 7, P 7

• Compare to most frequent letters in English: E 13, T 9, A 8, etc.

• Try J E and G T to get the equations:

x E + y = J and x T + y = G

• Or again

x 4 + y = 9 and x 19 + y = 6 (mod 26)

Page 9: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

System of Linear Congruences

a x + b y Ξ e (mod m)

c x + d y Ξ f (mod m)• Use material from section 4.2 if possible, or

• Use Theorems 4.17 -4.19 (page 179-181):Put

If (∆, m)= 1, then the solution of the system is

with the inverse of A mod 26:

ac

bdAadjwhereAadjA )(

bcadAanddc

baAPut

det

f

eA

y

x

Page 10: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Application to the example• x 4 + y = 9 and x 19 + y = 6 (mod 26)

• (∆, m)= 1, inverse of ∆ (mod 26) is ∆¯ =19 to get:

• On Derive: MOD(∆¯ MOD(DET(A)·A-1 , 26), 26)• On Maple: Mod(∆¯ · Mod(Det(A)·A-1 , 26), 26)

• Solution

• P=EXAMPLETHATICREATEDTOILLUSTRATEHOWAFFINECIPHERCRYPTANALYSISWORKS

• EXAMPLE THAT I CREATED TO ILLUSTRATE HOW AFFINE CIPHER CRYPTANALYSIS WORKS

)26(mod1115det119

14

AandAPut

)26(mod243

719

A

)26(mod15

5

6

9

A

y

x

Page 11: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

8.2 Block and Stream Ciphers

• Less vulnerable to cryptanalysis than Character Ciphers.

• Substitute for each block of plaintext letters of a specific length a block of ciphertext letters of the same length.

• Called Block or Polygraphic ciphers.• They are symmetric algorithms (or secret-key), i.e.,

use the same key for encryption and decryption (or the decryption key is easily derived from the encryption key).

Page 12: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

8.2.1 Vigenere Ciphers (see web & pages 287-292)

• Consists of a Keyword of length n: l1 l2… ln

• It numerical equivalence is then: k1 k2… kn

• Split plaintext into blocks of length n: p1 p2… pn

• Transform it into ciphertext blocks: c1 c2… cn

Such that: ci = pi + ki (mod 26) for i =1,2,…,n

or C=P+L

C =(c1, c2, … , cn) P=(c1, c2, … , cn) L =(c1, c2, … , cn)

To decrypt:pi = ci - ki (mod 26) for i =1,2,…,n

• A dummy letter can be used for a terminal block of less than n letters

Page 13: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Hill Ciphers (1929, see pages 292-296)

• Consists of a Key matrix A=(kij) of size n x n

• Split plaintext into blocks P of length n. • Transform it into ciphertext blocks C of length n.

C = A P (mod 26) or to decrypt P = C (mod 26)

• Where

• A dummy letter can be used for a terminal block of less than n letters

nn c

c

c

p

p

p

.

.C

.

.P2

1

2

1

A

Page 14: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Case of n=2; diagraphic ciphers

212

211

212

211

cdccp

cbcap

pdpcc

pbpacPAC

2

121

2

121 CPA

c

ccc

p

ppp

dc

ba

)26(mod)det( adj(A) 26modA Awithac

bd) (ofinverseA

Page 15: Cryptography Cryptography: art or science of keeping messages secret Cryptology: branch of mathematics that studies the mathematical foundations of cryptographic

Cryptanalysis of polygraphic Ciphers

• Not vulnerable to letter frequency • Vulnerable to frequency of blocks of size n.• For n=2 262 = 676 diagraphs (blocks of length 2)

• In English, the most common diagraphs with decreasing frequency: TH then HE

• So if TH c1c2 & HE c3c4 then solve for matrix A:

42

31

_____________

42

31

cc

cc

EH

HTA

cc

cc

EH

HTA