Download presentation
1
Elementary Cryptography
Chapter 2 Elementary Cryptography Department of Computer Science, Umm Al-Qura University University year: 1435/1436 Computer Security Systems Lecturer :H.Ben Othmen
2
Computer Security Systems
Outline Concepts of encryption Cryptanalysis: how encryption systems are "broken" Symmetric (secret key) encryption and the DES and AES algorithms Asymmetric (public key) encryption and the RSA algorithm Key exchange protocols and certificates Digital signatures Cryptographic hash functions 1435/1436 Computer Security Systems
3
Computer Security Systems
Introduction Study of algorithms and protocols used to preserve confidentiality of information and ensuring its integrity. It forms the basis of most security measures: Secure Internet exchanges, confidentiality of banking, protection of trade secrets, protection of medical confidentiality, protection of computer systems against intrusion, Through the electronic signature: identification of correspondents, Guarantee of integrity of documents. 1435/1436 Computer Security Systems
4
Computer Security Systems
Terminology Encryption is the process of encoding a message Decryption is the reverse process, transforming an encrypted message back into its normal Encode the original message to hide its meaning Decode it to reveal the original message The original form of a message is known as plaintext The encrypted form is called ciphertext encode = encrypt= encipher decode=decrypt = decipher 1435/1436 Computer Security Systems
5
Computer Security Systems
Terminology P: plaintext message / P = <p1, p2, …, pn> (as a sequence of individual characters) C: ciphertext message / C = <c1, c2, …, cm> For example the plaintext message "I want cookies" can be denoted as the message string <I, ,w,a,n,t, , c,o,o,k,i,e,s>. It can be transformed into ciphertext <c1, c2, …, c14>, the encryption algorithm tells us how the transformation is done. Figure 2.1. Encryption 1435/1436 Computer Security Systems
6
Computer Security Systems
Terminology using the following formal notation to describe the transformations between plaintext and ciphertext. For example, we write C = E(P) and P = D(C), where: C represents the ciphertext, E is the encryption rule, P is the plaintext, D is the decryption rule. What we seek is a cryptosystem for which P = D(E(P)). In other words, we want to be able to convert the message to protect it from an intruder, but we also want to be able to get the original message 1435/1436 Computer Security Systems
7
Computer Security Systems
Encryption Algorithms The cryptosystem involves a set of rules for how to encrypt the plaintext and how to decrypt the ciphertext Algorithms: The encryption and decryption rules K (key) is a device used by the algorithm The resulting ciphertext depends on the original plaintext message, the algorithm, and the key value. dependence : C = E(K, P). E is a set of encryption algorithms key K selects one specific algorithm from the set 1435/1436 Computer Security Systems
8
Computer Security Systems
Encryption Algorithms Symmetric encryption The encryption and decryption keys are the same P = D(K, E(K,P)) D and E are mirror-image processes Asymmetric encryption The encryption and decryption keys come in pairs A decryption key, KD, inverts the encryption of key KE P = D(KD, E(KE,P)) An encryption scheme that does not require the use of a key is called a keyless cipher. 1435/1436 Computer Security Systems
9
Computer Security Systems
Encryption with Keys Fig2.2. Encryption with Keys 1435/1436 Computer Security Systems
10
Computer Security Systems
Cryptology A key gives us flexibility in using an encryption scheme We can create different encryptions of one plaintext message just by changing the key Cryptography: means hidden writing, and it refers to the practice of using encryption to conceal text Encryption has been used for centuries to protect diplomatic and military communications, sometimes without full success 1435/1436 Computer Security Systems
11
Computer Security Systems
Cryptology a cryptographer and a cryptanalyst attempt to translate coded material back to its original form. a cryptographer works on behalf of a legitimate sender or receiver a cryptanalyst works on behalf of an unauthorized interceptor (A cryptanalyst is an expert in cryptanalysis) cryptology is the research into and study of encryption and decryption; it includes both cryptography and cryptanalysis. Cryptology = cryptography+ cryptanalysis 1435/1436 Computer Security Systems
12
Computer Security Systems
Cryptanalysis break a single message recognize patterns in encrypted messages, to be able to break subsequent ones by applying a straightforward decryption algorithm infer some meaning without even breaking the encryption (communication was short or long) deduce the key, to break subsequent messages easily find weaknesses in the implementation or environment of use of encryption find general weaknesses in an encryption algorithm, without necessarily having intercepted any messages 1435/1436 Computer Security Systems
13
Computer Security Systems
Substitution : Shift (Caesar) Cipher The Caesar Cipher: Rules => Ci = E(pi)= pi + k mod 26 Pi = D(ci) = ci– k mod 26 Examples: 1) k=3 (Rot 3) P= TREATY IMPOSSIBLE C= w u h d w b l p s r v v l e o h 2) ROT13: Why did the chicken cross the road? Gb trg gb gur bgure fvqr! Letter: A B …… Y Z Code : 0 1 …… 24 25 Can we do arithmetic on letters? Example: A+2=C, N+1=O Y-1=X, etc. Rot 3: “rotate by 3 places” 1435/1436 Computer Security Systems
14
Outer: plaintext Inner: ciphertext
The Caesar cipher Outer: plaintext Inner: ciphertext 1435/1436 Computer Security Systems
15
Computer Security Systems
The Caesar cipher K=3 1435/1436 Computer Security Systems
16
Computer Security Systems
Substitutions :Keyword Mixed Alphabet Rule 1) pick a keyword 2) spell it without duplicates 3) then, fill in the rest of the alphabet in order Example: keyword VACATION P: 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 C: V A C T I O N B D E F G H J K L M P Q R S U W X Y Z Q: Encrypt “I should be sailing” as: DQBK SGTA IQVD GDJN 1435/1436 Computer Security Systems
17
Computer Security Systems
Substitutions : Vernam Cipher a type of one-time pad devised by Gilbert Vernam The basic encryption involves an arbitrarily long non repeating sequence of numbers that are combined with the plaintext. 1435/1436 Computer Security Systems
18
Computer Security Systems
Substitutions : Vernam Cipher The encryption is done by adding the key to the message modulo 2, bit by bit. This process is often called exclusive or (XOR). 1435/1436 Computer Security Systems
19
Example: Key : XMCKL Message: HELLO
Substitutions : Vernam Cipher Example: Key : XMCKL Message: HELLO H E L O message (plaintext) + 7(H) 4(E) 11(L) 14(O) message 23(X) 12(M) 2(C) 10(K) Key 30 16 13 21 25 Message+key 16(Q) 13(N) 21(V) 25(Z) Message+key (mod 26) Q N V Z Ciphertext 1435/1436 Computer Security Systems
20
Computer Security Systems
Substitution : Vigenere Cipher Vigenere cipher is a method of encrypting alphabetic text by using a series of different Caesar ciphers based on the letters of a keyword. The Vigenere square or Vigenere table 1435/1436 Computer Security Systems
21
Computer Security Systems
Substitution : Vigenere Cipher Example: The person sending the message chooses a keyword and repeats it until it matches the length of the plaintext. P= ATTACKATDAWN keyword :LEMON Method A:the first letter of the plaintext, L: the first letter of the key A is paired with L use row L and column A of the Vigenere square X? : the first letter of the Ciphertext X= row L ∩ column A Plaintext: ATTACKATDAWN Key: LEMONLEMONLE Ciphertext: LXFOPVEFRNHR 1435/1436 Computer Security Systems
22
Computer Security Systems
Transpositions (Permutations) A transposition is an encryption in which the letters of the message are rearranged With transposition, the cryptography aims for diffusion, widely spreading the information from the message or the key across the ciphertext A transposition is also known as a permutation. 1435/1436 Computer Security Systems
23
Computer Security Systems
Columnar Transpositions The following set of characters is a five-column transposition The plaintext characters are written in rows of five and arranged one row after another c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 etc Figure 2.4. Columnar Transposition 1435/1436 Computer Security Systems
24
Computer Security Systems
Columnar Transpositions- Example Plaintext : THIS IS A MESSAGE TO SHOW HOW A COLUMNAR TRANSPOSITION WORKS T H I S A M E G O W C L U N R P K Ciphertext: tssoh oaniw haaso lrsto imghw utpir seeoa mrook istwc nasns Note : if the message length is not a multiple of the length of a row, the last columns will be one or more letters short. When this happens, we sometimes use an infrequent letter, such as X, to fill in any short 1435/1436 Computer Security Systems
25
Computer Security Systems
Symmetric and Asymmetric Encryption Systems Two basic kinds of encryptions are: Symmetric Secret key Symmetric algorithms use one key, which works for both encryption and decryption Authenticity is ensured n users who want to communicate in pairs need n * (n - 1)/2 keys. key distribution Asymmetric Two keys: -public key -private key 1435/1436 Computer Security Systems
26
Computer Security Systems
DES DES: Data Encryption Standard a system developed for the U.S. government DES algorithm: key is 64 bits Uses basic techniques of encryption confusion (substitutions) diffusion (permutations) Same process 16 times/block Uses standard arithmetic and logical operators 1435/1436 Computer Security Systems
27
Computer Security Systems
DES algorithm The DES algorithm Fractioning of the text into 64-bit (8 octet) blocks Initial permutation of blocks Breakdown of the blocks into two parts: left and right, named L and R Permutation and substitution steps repeated 16 times (called rounds) Re-joining of the left and right parts then inverse initial permutation. The function expects a 64-bit key as input. However, only 56 of these bits are ever used; the other 8 bits can be used as parity bits or simply set arbitrarily. 1435/1436 Computer Security Systems
28
Computer Security Systems
Fig 2..General Depiction of DES Encryption Algorithm 1435/1436 Computer Security Systems
29
Computer Security Systems
DES Left-hand side: The processing of the plaintext proceeds in three phases First, the plaintext (64-bit) passes through an initial permutation (IP) that rearranges the bits to produce the permuted input This is followed by a phase consisting of 16 rounds of the same function (permutation and substitution functions) The output of the last (sixteenth) round consists of 64 bits that are a function of the input plaintext and the key. 1435/1436 Computer Security Systems
30
Computer Security Systems
DES The left and right halves of the output are swapped to produce the preoutput Finally, the preoutput is passed through a permutation (IP-1) that is the inverse of the initial permutation function, to produce the 64-bit ciphertext The right-hand: The key is passed through a permutation function for each of the 16 rounds, a subkey (Ki) is produced by the combination of a left circular shift and a permutation 1435/1436 Computer Security Systems
31
Computer Security Systems
DES The key is ciphered on 64 bits and made of 16 blocks of 4 bits, generally denoted k1 to k16 . Given that "only" 56 bits are actually used for encrypting, there can be 2^56 (or 7.2*10^16 ) different keys The permutation function is the same for each round, but a different subkey is produced 1435/1436 Computer Security Systems
32
The First phase: Initial Permutation
DES: Initial Permutation The First phase: Initial Permutation After round 16: Inverse Initial Permutation (IP-1) Description : put bit 58 into the 1st position, put 50 into the 2nd position, …………. At the end of the iterations, the two blocks L16 and R16 are re-joined, then subject to inverse initial permutation 1435/1436 Computer Security Systems
33
Computer Security Systems
Figure 2.. Single Round of DES Algorithm 1435/1436 Computer Security Systems
34
Computer Security Systems
DES-Expansion Permutation (E) 1435/1436 Computer Security Systems
35
Computer Security Systems
DES-Calculation of F(R, K) 1435/1436 Computer Security Systems
36
Computer Security Systems
DES: S Boxes Each box defines a substitution – 6-bit input – 4-bit output 1435/1436 Computer Security Systems
37
Computer Security Systems
DES: S Boxes Example: S box 1 bit 1 and 6 define the row. bit 2-5 define col. Example: bit 1,6 = 01 → row 1 bit 2,3,4,5 = 1001 → col 9 output = 6, i.e. 0110 1435/1436 Computer Security Systems
38
Computer Security Systems
Permutation function (P) 16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25 1435/1436 Computer Security Systems
39
Computer Security Systems
DES: Keys PC1: just a simple permutation (output = 56 bit) selected by Pc1 key split in half each half 28 bits Both halves are shifted lift either 1 or 2 bits (depending on round) result of shift fed to PC2 bits are permuted and 48 of the 56 bits chosen for Subkey 1 28 28 1435/1436 Computer Security Systems
40
Computer Security Systems
The Triple Data Encryption Standard (Triple DES) Triple DES Operation For each block: encrypt with key 1 decrypt with key 2 i.e. C= E(K3, D(K2, E(K1, P))) C: ciphertext P: plaintext E[K, X] encryption of X using key K D[K, Y] decryption of Y using key K 1435/1436 Computer Security Systems
41
Computer Security Systems
The Triple Data Encryption Standard (Triple DES) Key Length (3DES) = 3*56 = 168 1435/1436 Computer Security Systems
42
Computer Security Systems
1435/1436 Computer Security Systems
43
Computer Security Systems
Bibliography Security in Computing, Fourth Edition By Charles P. Pfleeger - Pfleeger Consulting Group, Shari Law rence Pfleeger cryptography-and-network-security-principles-and-practices-4th-ed-william-stallings 1435/1436 Computer Security Systems
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.