8.1 chapter 8 encipherment using modern symmetric-key ciphers

46
8.1 Chapter 8 Encipherment Using Modern Symmetric- Key Ciphers

Upload: madalynn-wartell

Post on 14-Dec-2015

288 views

Category:

Documents


12 download

TRANSCRIPT

Page 1: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

81

Chapter 8

Encipherment UsingModern Symmetric-Key

Ciphers

82

8-1 USE OF MODERN BLOCK CIPHERS8-1 USE OF MODERN BLOCK CIPHERS

Symmetric-key encipherment can be done using Symmetric-key encipherment can be done using modern block ciphers Modes of operation have been modern block ciphers Modes of operation have been devised to encipher text of any size employing either devised to encipher text of any size employing either DES or AES DES or AES

83

8-1 Continued8-1 Continued

Figure 81 Modes of operation

84

The simplest mode of operation is called the electronic codebook (ECB) mode

811 Electronic Codebook (ECB) Mode

Figure 82 Electronic codebook (ECB) mode

85

811 Continued

It can be proved that each plaintext block at Alicersquos site is exactly recovered at Bobrsquos site Because encryption and decryption are inverses of each other

Example 81

This mode is called electronic codebook because one can precompile 2K codebooks (one for each key) in which each codebook has 2n entries in two columns Each entry can list the plaintext and the corresponding ciphertext blocks However if K and n are large the codebook would be far too large to precompile and maintain

Example 82

86

811 Continued

Assume that Eve works in a company a few hours per month (her monthly payment is very low) She knows that the company uses several blocks of information for each employee in which the seventh block is the amount of money to be deposited in the employeersquos account Eve can intercept the ciphertext sent to the bank at the end of the month replace the block with the information about her payment with a copy of the block with the information about the payment of a full-time colleague Each month Eve can receive more money than she deserves

Example 83

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 2: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

82

8-1 USE OF MODERN BLOCK CIPHERS8-1 USE OF MODERN BLOCK CIPHERS

Symmetric-key encipherment can be done using Symmetric-key encipherment can be done using modern block ciphers Modes of operation have been modern block ciphers Modes of operation have been devised to encipher text of any size employing either devised to encipher text of any size employing either DES or AES DES or AES

83

8-1 Continued8-1 Continued

Figure 81 Modes of operation

84

The simplest mode of operation is called the electronic codebook (ECB) mode

811 Electronic Codebook (ECB) Mode

Figure 82 Electronic codebook (ECB) mode

85

811 Continued

It can be proved that each plaintext block at Alicersquos site is exactly recovered at Bobrsquos site Because encryption and decryption are inverses of each other

Example 81

This mode is called electronic codebook because one can precompile 2K codebooks (one for each key) in which each codebook has 2n entries in two columns Each entry can list the plaintext and the corresponding ciphertext blocks However if K and n are large the codebook would be far too large to precompile and maintain

Example 82

86

811 Continued

Assume that Eve works in a company a few hours per month (her monthly payment is very low) She knows that the company uses several blocks of information for each employee in which the seventh block is the amount of money to be deposited in the employeersquos account Eve can intercept the ciphertext sent to the bank at the end of the month replace the block with the information about her payment with a copy of the block with the information about the payment of a full-time colleague Each month Eve can receive more money than she deserves

Example 83

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 3: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

83

8-1 Continued8-1 Continued

Figure 81 Modes of operation

84

The simplest mode of operation is called the electronic codebook (ECB) mode

811 Electronic Codebook (ECB) Mode

Figure 82 Electronic codebook (ECB) mode

85

811 Continued

It can be proved that each plaintext block at Alicersquos site is exactly recovered at Bobrsquos site Because encryption and decryption are inverses of each other

Example 81

This mode is called electronic codebook because one can precompile 2K codebooks (one for each key) in which each codebook has 2n entries in two columns Each entry can list the plaintext and the corresponding ciphertext blocks However if K and n are large the codebook would be far too large to precompile and maintain

Example 82

86

811 Continued

Assume that Eve works in a company a few hours per month (her monthly payment is very low) She knows that the company uses several blocks of information for each employee in which the seventh block is the amount of money to be deposited in the employeersquos account Eve can intercept the ciphertext sent to the bank at the end of the month replace the block with the information about her payment with a copy of the block with the information about the payment of a full-time colleague Each month Eve can receive more money than she deserves

Example 83

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 4: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

84

The simplest mode of operation is called the electronic codebook (ECB) mode

811 Electronic Codebook (ECB) Mode

Figure 82 Electronic codebook (ECB) mode

85

811 Continued

It can be proved that each plaintext block at Alicersquos site is exactly recovered at Bobrsquos site Because encryption and decryption are inverses of each other

Example 81

This mode is called electronic codebook because one can precompile 2K codebooks (one for each key) in which each codebook has 2n entries in two columns Each entry can list the plaintext and the corresponding ciphertext blocks However if K and n are large the codebook would be far too large to precompile and maintain

Example 82

86

811 Continued

Assume that Eve works in a company a few hours per month (her monthly payment is very low) She knows that the company uses several blocks of information for each employee in which the seventh block is the amount of money to be deposited in the employeersquos account Eve can intercept the ciphertext sent to the bank at the end of the month replace the block with the information about her payment with a copy of the block with the information about the payment of a full-time colleague Each month Eve can receive more money than she deserves

Example 83

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 5: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

85

811 Continued

It can be proved that each plaintext block at Alicersquos site is exactly recovered at Bobrsquos site Because encryption and decryption are inverses of each other

Example 81

This mode is called electronic codebook because one can precompile 2K codebooks (one for each key) in which each codebook has 2n entries in two columns Each entry can list the plaintext and the corresponding ciphertext blocks However if K and n are large the codebook would be far too large to precompile and maintain

Example 82

86

811 Continued

Assume that Eve works in a company a few hours per month (her monthly payment is very low) She knows that the company uses several blocks of information for each employee in which the seventh block is the amount of money to be deposited in the employeersquos account Eve can intercept the ciphertext sent to the bank at the end of the month replace the block with the information about her payment with a copy of the block with the information about the payment of a full-time colleague Each month Eve can receive more money than she deserves

Example 83

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 6: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

86

811 Continued

Assume that Eve works in a company a few hours per month (her monthly payment is very low) She knows that the company uses several blocks of information for each employee in which the seventh block is the amount of money to be deposited in the employeersquos account Eve can intercept the ciphertext sent to the bank at the end of the month replace the block with the information about her payment with a copy of the block with the information about the payment of a full-time colleague Each month Eve can receive more money than she deserves

Example 83

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 7: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

87

Security Issues1- Patterns at the block level are preserved2- The block independency creates opportunities for Eve to exchange some ciphertext blocks without knowing the key

Error PropagationA single bit error in transmission can create errors in several in the corresponding block However the error does not have any effect on the other blocks

811 Continued

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 8: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

88

Ciphertext StealingA technique called ciphertext stealing (CTS) can make it possible to use ECB mode without padding In this technique the last two plaintext blocks PNminus1 and PN are encrypted differently and out of order as shown below assuming that PNminus1 has n bits and PN has m bits where m le n

811 Continued

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 9: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

89

ApplicationsbullThe ECB mode is not recommended for encryption of messages more than one blockbullOne area where the independency of the ciphertext block is useful is where records need to be encrypted before they are stored in a database or decrypted before they are retrievedhellipAccess to the database can be randombullAnother advantage of this mode is that we can use parallel processing if we need to create a very huge encrypted database

811 Continued

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 10: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

810

In CBC mode each plaintext block is exclusive-ored with the previous ciphertext block before being encrypted

812 Cipher Block Chaining (CBC) Mode

Figure 83 Cipher block chaining (CBC) mode

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 11: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

811

812 ContinuedFigure 83 Cipher block chaining (CBC) mode

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 12: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

812

812 Continued

It can be proved that each plaintext block at Alicersquos site is recovered exactly at Bobrsquos site Because encryption and decryption are inverses of each other

Example 84

Initialization Vector (IV)The initialization vector (IV) should be known by the sender and the receiver

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 13: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

813

Security IssuesbullPatterns at the block level are not preserved However if the first M blocks in two different messages are equal they are enciphered into equal blocks unless different Ivs are used Hence recommend the use of timestamp as an IVbullEve can add some ciphertext blocks to the end of the ciphertext stream

Error PropagationIn CBC mode a single bit error in ciphertext block Cj during transmission may create error in most bits in plaintext block Pj during decryption

812 Continued

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 14: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

814

ApplicationsbullParallel processing is not possiblebullCBC mode is not used to encrypt and decrypt random-access files records because of the need to access the previous recordsbullCBC mode is used for authentication

812 Continued

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 15: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

815

Ciphertext StealingThe ciphertext stealing technique described for ECB mode can also be applied to CBC mode as shown below

812 Continued

The head function is the same as described in ECB mode the pad function inserts 0rsquos

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 16: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

816

In some situations we need to use DES or AES as secure ciphers but the plaintext or ciphertext block sizes are to be smaller

813 Cipher Feedback (CFB) Mode

Figure 84 Encryption in cipher feedback (CFB) mode

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 17: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

817

The relation between plaintext and ciphertext blocks is shown below

813 Continued

In CFB mode encipherment and decipherment use the encryption function of the underlying block

cipher

Note

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 18: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

818

813 Continued

AdvantagesbullThis mode does not need padding because the size of the block r is normally chosen to fit the data unit to be encrypted ( a character for example)bullThe system does not have to wait until It has received a large block of data (64 or 128 bits) before starting the encryptionDisadvantages CFB is less efficient than CBC and ECB because it needs to apply the encryption function for each small block of size r

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 19: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

819

CFB as a Stream Cipher

813 Continued

Figure 85 Cipher feedback (CFB) mode as a stream cipher

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 20: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

820

813 Continued

Security IssuesbullThe patterns are not preservedbullThe IV should be changed for each messagebullEve can add some ciphertext block to the end of the ciphertext streamError Propagation A single bit error in ciphertext block Ci during transmission creates a single bit eror in plaintext block Pi However most of the bits in the following plaintext blocks are in errorApplication This mode can be used to encipher blocks of small size such as characters or bit at a time

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 21: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

821

In this mode each bit in the ciphertext is independent of the previous bit or bits This avoids error propagation

1814 Output Feedback (OFB) Mode

Figure 86 Encryption in output feedback (OFB) mode

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 22: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

822

OFB as a Stream Cipher

814 Continued

Figure 87 Output feedback (OFB) mode as a stream cipher

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 23: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

823

814 Continued

Security Issues The patterns are not preserved

Error Propagation A single bit error in the ciphertext affects only the corresponding bit in the plaintext

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 24: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

824

In the counter (CTR) mode there is no feedback The pseudorandomness in the key stream is achieved using a counter

815 Counter (CTR) Mode

Figure 88 Encryption in counter (CTR) mode

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 25: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

825

815 Continued

Figure 89 Counter (CTR) mode as a stream cipher

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 26: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

826

815 Continued

NotesbullCTR creates n-bit blocks that are independent from each other they depend only on the value of the counterbullCTR like ECB mode cannot be used for real- time processingbullCTR like ECB mode can be used to encrypt and decrypt random access files as long as the value of the counter can be related to the record number in the file

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 27: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

827

Comparison of Different Modes

815 Continued

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 28: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

828

8-2 USE OF STREAM CIPHERS8-2 USE OF STREAM CIPHERS

Although the five modes of operations enable the use Although the five modes of operations enable the use of block ciphers for encipherment of messages or files of block ciphers for encipherment of messages or files in large units and small units sometimes pure stream in large units and small units sometimes pure stream are needed for enciphering small units of data such as are needed for enciphering small units of data such as characters or bits characters or bits

821 RC4822 A51

Topics discussed in this sectionTopics discussed in this section

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 29: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

829

821 RC4

Developed by RSA Labs RC4 is a symmetric byte-oriented stream cipher with a variable length key size in which a byte (8 bits) of a plaintext is exclusive-ored with a byte of key to produce a byte of a ciphertext KEY

RC4 HAS two main partsKSA (Key Scheduling Algorithm)PRGA (Pseudo Random Generation Algorithm)

StateRC4 is based on the concept of a state

ksa

PRGA

P C +

K

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 30: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

830

821 Continued

Figure 810 The idea of RC4 stream cipher

KSA

PRGA

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 31: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

831

RC4 Key Schedule KSA

Starts with an array S of numbers 02551048698 Use key to truly shuffle S1048698 S forms internal state of the cipher1048698 Given a key k of length L bytes

Scrambling Pseudocode for i = 0 to 255 doS[i] = ij = 0for i = 0 to 255 doj = (j + S[i] + k[i ]) (mod 256)swap (S[i] S[j])

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 32: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

832

RC4 PRGA and Encryption

Encryption involves XORing data bytes with output of thePRGA

1048698 The PRGA initializes i and j to 0 and then loops over 4 basicoperations increase j increase j using s[i] swap and outputs[i]+s[j]

1048698PRGA Pseudocode isi = j = 0for each message byte Mii = (i + 1) (mod 256)j = (j + S[i]) (mod 256)swap(S[i] S[j])t = (S[i] + S[j]) (mod 256) Ki = S[t]Encryption Ci = Mi XOR S[t]

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 33: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

833

RC4 Encryption Example

Lets consider the stream cipher RC4 but instead of the full 256 bytes we will use 8 x 3-bits That is the state vector S is 8 x 3-bits We will operate on 3-bits of plaintext at a time since S can take the values 0 to 7 which can be represented as 3 bits Assume we use a 4 x 3-bit key of K = [1 2 3 6] And a plaintext P = [1 2 2 2]

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 34: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

834

RC4 PRGA and EncryptionThe first step is to generate the stream Initialise the state vector S and temporary vector T S is initialised so the S[i] = i and T is initialised so it is the key K (repeated as necessary) S = [0 1 2 3 4 5 6 7]

T = [1 2 3 6 1 2 3 6] Now perform the initial permutation on S j = 0 for i = 0 to 7 do j = (j + S[i] + T[i]) mod 8 Swap(S[i]S[j]) end For i = 0 j = (0 + 0 + 1) mod 8 = 1 Swap(S[0]S[1]) S = [1 0 2 3 4 5 6 7]

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 35: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

835

RC4 PRGA and Encryption

For i = 1 j = 3 Swap(S[1]S[3]) S = [1 3 2 0 4 5 6 7]

For i = 2 j = 0 Swap(S[2]S[0]) S = [2 3 1 0 4 5 6 7]

For i = 3 j = 6 Swap(S[3]S[6]) S = [2 3 1 6 4 5 0 7]

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 36: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

836

RC4 PRGA and EncryptionFor i = 4 j = 3 Swap(S[4]S[3]) S = [2 3 1 4 6 5 0 7] For i = 5 j = 2 Swap(S[5]S[2]) S = [2 3 5 4 6 1 0 7] For i = 6 j = 5 Swap(S[6]S[4]) S = [2 3 5 4 0 1 6 7] For i = 7 j = 2 Swap(S[7]S[2]) S = [2 3 7 4 0 1 6 5] Hence our initial permutation of S = [2 3 7 4 0 1 6 5]

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 37: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

837

RC4 PRGA and EncryptionNow we generate 3-bits at a time k that we XOR with each 3-bits of plaintext to produce the ciphertext The 3-bits k is generated by i j = 0 while (true) i = (i + 1) mod 8 j = (j + S[i]) mod 8 Swap (S[i] S[j]) t = (S[i] + S[j]) mod 8 k = S[t] The first iteration S = [2 3 7 4 0 1 6 5] i = (0 + 1) mod 8 = 1 j = (0 + S[1]) mod 8 = 3 Swap(S[1]S[3]) S = [2 4 7 3 0 1 6 5] t = (S[1] + S[3]) mod 8 = 7 k = S[7] = 5 Remember P = [1 2 2 2]

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 38: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

838

RC4 PRGA and Encryption

Remember P = [1 2 2 2] So our first 3-bits of ciphertext is obtained by k XOR P 5 XOR 1 = 101 XOR 001 = 100 = 4

The second iteration S = [2 4 7 3 0 1 6 5] i = (1 + 1 ) mod 8 = 2 j = (2 + S[2]) mod 8 = 1 Swap(S[2]S[1]) S = [2 7 4 3 0 1 6 5] t = (S[2] + S[1]) mod 8 = 3 k = S[3] = 3 Second 3-bits of ciphertext are 3 XOR 2 = 011 XOR 010 = 001 = 1

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 39: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

839

RC4 PRGA and Encryption

After 4 iterations To encrypt the plaintext stream P = [1 2 2 2] with key K = [1 2 3 6] using our simplified RC4 stream cipher we get C = [4 1 2 0] (or in binary P = 001010010010 K = 001010011110 and C = 100001010000) Simplified

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 40: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

840

A51 (a member of the A5 family of ciphers) is used in the Global System for Mobile Communication (GSM) a network for mobile telephone communication

822 A51

Figure 811 General outline of A51

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 41: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

841

Key GeneratorA51 uses three LFSRs with 19 22 and 23 bits

822 Continued

Figure 812 Three LFSRrsquos in A51

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 42: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

842

822 Continued

At a point of time the clocking bits are 1 0 and 1 Which LFSR is clocked (shifted)

Example 87

SolutionThe result of Majority (1 0 1) = 1 LFSR1 and LAFS3 are shiftedbut LFSR2 is not

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 43: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

843

EncryptionDecryptionThe bit streams created from the key generator are buffered to form a 228-bit key that is exclusive-ored with the plaintext frame to create the ciphertext frame Encryptiondecryption is done one frame at a time

822 Continued

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 44: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

844

8-3 OTHER ISSUES8-3 OTHER ISSUES

Encipherment using symmetric-key block or stream Encipherment using symmetric-key block or stream ciphers requires discussion of other issuesciphers requires discussion of other issues

831 Key Management832 Key Generation

Topics discussed in this sectionTopics discussed in this section

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 45: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

845

Alice and Bob need to share a secret key between themselves to securely communicate using a symmetric-key cipher If there are n entities in the community n(n minus 1)2 keys are needed

831 Key Management

Key management is discussed in Chapter 15

Note

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
Page 46: 8.1 Chapter 8 Encipherment Using Modern Symmetric-Key Ciphers

846

Different symmetric-key ciphers need keys of different sizes The selection of the key must be based on a systematic approach to avoid a security leak The keys need to be chosen randomly This implies that there is a need for random (or pseudorandom) number generator

832 Key Generation

Random number generators are discussed in Appendix K

Note

  • PowerPoint Presentation
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46