220 likes | 401 Views
Information Security. CS 483 – SD Section By Dr. Daniyal Alghazzawi (3). Cryptography. Symmetric vs. Asymmetric Algorithms. Key Management: different / same key for encryption Speed Hybrid cryptosystem. Symmetric-Key Algorithms (Private-Key).
E N D
Information Security CS 483 – SD Section By Dr. DaniyalAlghazzawi (3)
Symmetric vs. Asymmetric Algorithms • Key Management: different / same key for encryption • Speed • Hybrid cryptosystem
Symmetric-Key Algorithms (Private-Key) • Other terms for symmetric-key encryption are single-key, one-key and private-key encryption. Use of the latter term can sometimes conflict with the term private key in public key cryptography. • Symmetric-key algorithms can be divided into: • Stream ciphers: encrypt the bits of the message one at a time. • Block ciphers:take a number of bits and encrypt them as a single unit.
Symmetric-Key Algorithms - Stream Ciphers(Private-Key) • A stream cipher is a symmetric cipher where plaintext bits are combined with a pseudorandom cipher bit stream (keystream), typically by an exclusive-or (xor) operation. • Algorithms: • StreamCipher(K) = Swhere K is the key and, S is the keystream • C = P S; as one-time pad where C is the ciphertext, and P is the plaintext • The main idea is that the algorithm is used to generate the Stream Cipher. +
Symmetric-Key Algorithms - Stream CiphersTypes of Stream Ciphers • In a synchronous stream cipher, a stream of pseudo-random digits is generated independently of the plaintext and ciphertext messages, and then combined with the plaintext (to encrypt) or the ciphertext (to decrypt). Note: In the most common form, binary digits are used (bits), and the keystream is combined with the plaintext using the exclusive or operation (XOR). This is termed a binary additive stream cipher. (e.g., A5/1) • Asynchronous stream ciphers use several of the previous N ciphertext digits to compute the keystream. (e.g., Cipher-Feedback Mode)
Symmetric-Key Algorithms - Stream Ciphers Linear vs. Non-Linear Binary stream ciphers are often constructed using Linear Feedback Shift Registers (LFSRs) because they can be easily implemented in hardware. • Because LFSRs are inherently linear, one technique for removing the linearity is to feed the outputs of several parallel LFSRs into a non-linear Boolean function.
Symmetric-Key Algorithms - Stream CiphersExample(1): A5/1 • A5/1 initialization: • Register X hold 19 bits of the key (x0, x1, x2, …, x18) • Register Y hold 22 bits of the key (y0, y1, y2, …, y21) • Register Z hold 23 bits of the key (z0, z1, z2, …, z22) • A5/1 keystream bit: • m = maj (x8, y10, z10) • if (x8=m) then X steps • if (y10=m) then Y steps • if (z10=m) then Z steps • s = x18 y21 z22 • Go to step 1 + +
Symmetric-Key Algorithms - Stream CiphersExample(2): RC4 • RC4 initialization: fori= 0 to 255 S[i] = i K[i] = key [ i mod N ]nextij = 0fori = 0 to 255j = ( j + S[i] + K[i] ) mod 256swap ( S[i] , S[j] )nextii = j = 0 • RC4 keystream byte: i = ( i + 1 ) mod 256j = ( j + S[i] ) mod 256swap ( S[i] , S[j] )t = ( S[i] + S[j] ) mod 256keystreamByte = S[t] • Note: • The entire algorithm is byte based. • key[i] for i=0, 1, …, N-1, where key[i] is a byte
Symmetric-Key Algorithms - Block Ciphers • is a symmetric key cipher. • operates on fixed-length groups of bits, termed blocks. • a block cipher might take a (for example) 128-bit block of plaintext as input, and output a corresponding 128-bit block of ciphertext. • The exact transformation is controlled using a second input — the secret key.
Symmetric-Key Algorithms - Block CiphersDES (Data Encryption Standard) • Runs 16 rounds. • Each block consists of 64 bits. It uses a 56-bit key. • In each round of DES: • Plaintext divided to Li and Ri, and generate the subkey • Function F is composition of: • Expansion permutation (32bit → 48bit) • Addition of subkey (48bit 48bit) • S-boxes (map 6bits → 4bits) • P-box (change permutation) +
Symmetric-Key Algorithms - Block CiphersDES – Initial Step • A. Plaintext:Divide the plaintext into L and R parts; each of them 32 bits. • B. Key:Divide the key into 2 parts LK and RK; each of them 28 bits. • LK • 49 42 35 28 21 14 7 • 0 50 43 36 29 22 15 • 8 1 51 44 37 30 23 • 16 9 2 52 45 38 31 • RK • 55 48 41 34 27 20 13 • 6 54 47 40 33 26 19 • 12 5 53 46 39 32 25 • 18 11 4 24 17 10 3
Symmetric-Key Algorithms - Block CiphersDES –Key Schedule Algorithm • Defining the permutation LP as: (24 bits) • 13 16 10 23 0 4 2 27 14 5 20 9 • 22 18 11 3 25 7 15 6 26 19 12 1 • Defining the permutation RP as: (24 bits) • 12 23 2 8 18 26 1 11 22 16 4 19 • 15 20 10 27 5 24 17 13 21 7 0 3 • 1 if iЄ {1, 2, 9, 16} • ri = otherwise 2 • For each round i, the algorithm for generating the 48-bit subkeyKi is: • LK = cyclically left shift LK by ribitsRK = cyclically left shift RK by ribitsThe left half of subkeyKi consists of bits LP of LKThe right half of subkeyKi consists of bits RP of RK
Symmetric-Key Algorithms - Block CiphersDES – Step 1 1. Expansion Permutation For each round i, we have the plaintext Pi Change the permutation of Ri from (32 bits): 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 26 27 28 29 30 31 to (48 bits): 31 0 1 2 3 4 3 4 5 6 7 8 7 8 9 10 11 12 11 12 13 14 15 16 15 16 17 18 19 20 19 20 21 22 23 24 23 24 25 26 27 28 27 28 29 30 31 0 • In each round of DES: • Plaintext divided to Li and Ri; each 32 bits • The new left half is the same old right half • Function F is composition of:F(Ri-1, Ki) = P-box(S-boxes(Expand(Ri-1) Ki)) • Expansion permutation (32bit → 48bit) • Addition of subkey (48bit 48bit) • S-boxes (map 6bits → 4bits to offer protection) • P-box (change permutation) + +
Symmetric-Key Algorithms - Block CiphersDES – Step 2 • In each round of DES: • Plaintext divided to Li and Ri; each 32 bits • The new left half is the same old right half • Function F is composition of:F(Ri-1, Ki) = P-box(S-boxes(Expand(Ri-1) Ki)) • Expansion permutation (32bit → 48bit) • Addition of subkey (48bit 48bit) • S-boxes (map 6bits → 4bits to offer protection) • P-box (change permutation) • 2. Addition of Subkey • For each round i, we have the right part of the plaintext Ri after the expansion, and the subkey for this round Ki (both of them are 48 bits.) • Find:KiRi + + +
Symmetric-Key Algorithms - Block CiphersDES – Step 3 • In each round of DES: • Plaintext divided to Li and Ri; each 32 bits • The new left half is the same old right half • Function F is composition of:F(Ri-1, Ki) = P-box(S-boxes(Expand(Ri-1) Ki)) • Expansion permutation (32bit → 48bit) • Addition of subkey (48bit 48bit) • S-boxes (map 6bits → 4bits to offer protection) • P-box (change permutation) • 3. S-boxes • The main purpose of S-boxes is to offer protection against cryptanalytic. • There are 8 distinct S-boxes that are used in each round. (look at the appendix) • For each round i • Each of the S-Box takes only 6 bits from the • output and map them to 4 bits.In: 6 bits × 8 S-box = 48 bits • Out: 4 bits × 8 S-box = 32 bits + +
Symmetric-Key Algorithms - Block CiphersDES – Step 4 • In each round of DES: • Plaintext divided to Li and Ri; each 32 bits • The new left half is the same old right half • Function F is composition of:F(Ri-1, Ki) = P-box(S-boxes(Expand(Ri-1) Ki)) • Expansion permutation (32bit → 48bit) • Addition of subkey (48bit 48bit) • S-boxes (map 6bits → 4bits to offer protection) • P-box (change permutation) 4. P-boxes For each round i, there are 32 bits out from the S-Boxes: Change their permutationfrom: 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 26 27 28 29 30 31 to: 15 6 19 20 28 11 27 16 0 14 22 25 4 17 30 9 1 7 23 13 31 26 2 8 18 12 29 5 21 10 3 24
Symmetric-Key Algorithms - Block CiphersDES – Final Step • In each round of DES: • Plaintext divided to Li and Ri; each 32 bits • The new left half is the same old right half • Function F is composition of:F(Ri-1, Ki) = P-box(S-boxes(Expand(Ri-1) Ki)) • Expansion permutation (32bit → 48bit) • Addition of subkey (48bit 48bit) • S-boxes (map 6bits → 4bits to offer protection) • P-box (change permutation) 5. Constructing the ciphertext For each round i Li = Ri-1 Ri = Li-1 F(Ri-1, Ki) Repeat the five steps 16 rounds. At the end, the Ciphertext will be the combination of L16 and R16 + + +
Symmetric-Key Algorithms - Block CiphersTriple DES C = E(D(E(P,K1), K2), K1) P = D(E(D(C,K1),K2),K1) • In DES:C = E (P, K) ; encrypt the plaintext P with the key KP = D (C, K) ; for decryption • It takes 255key search to attack DES • Moving to encryption with two keys according to: C = E (E (P, K1), K2) wasn’t secure, WHY? • Triple DES has 112-bit key and is defined as:C = E (D (E (P,K1), K2), K1) • Triple DES is popular today. But with the coming of the AES, it should fade from use over time.
Symmetric-Key Algorithms - Block CiphersModes • ECB (Electronic Codebook) Mode • Suppose we have multiple plaintext blockP0, P1, P2, …, PN , and a fixed key KWe encrypt using the formula:Ci = E(Pi, K) for i = 0, 1, 2, …, NWe decrypt using the formula:Pi = D(Ci, K) for i = 0, 1, 2, …, N • Problem:in case Ci = Cj the attacker knows that Pi = PjSolution:add a random text to the plaintexts Pi = Pj, so Ci ≠ Cj
Symmetric-Key Algorithms - Block CiphersModes • CBC (Cipher Block Chaining) Mode • The ciphertext from a block is used to obscure the plaintext of the next block before it is encrypted. The formulas are:Ci = E(Pi Ci-1, K) for i = 0, 1, 2, …, NPi = D(Ci, K) Ci-1 for i = 0, 1, 2, …, N • What is about C0 ; we don’t have C-1 ? • An initialization vector, or IV, is used to take the place of C-1. • IV should be randomly selected, and it sends as the first block. • Problem: if a single-bit error causes two entire blocks to be garbled; it is a big problem in wireless environment.Solution:Use stream ciphers. + + 1 3 1 3
Symmetric-Key Algorithms - Block Ciphers Integrity • Block ciphers used for confidentiality and integrity. • A message authentication code, or MAC, uses a block cipher to ensure data integrity by encrypting the data un CBC mode, and use the final block only, called MAC. C0 = E(P0 IV, K), C1 = E(P1 C0, K), … CN-1 = E(PN-1 CN-2, K) = MAC • The recipient repeats the process on the plaintext and re-calculate the MAC. • A hashed MAC, or HMAC, is another standard approach to integrity. + + +