DES Algorithm  Stream Cipher Modes and JCE SUN Implementation
Part:
1
2
3
4
This tutorial helps you understand:
 DES in Stream Cipher Modes
 CFB (Cipher FeedBack) Operation Mode as a Stream Cipher
 OFB (Output FeedBack) Operation Mode as a Stream Cipher
 Sun Java Implementation of DES Operation Modes
 JceSunDesStreamCipherTest.java  JCE DES Stream Cipher Mode Testing Program
 Test Cases of DES Stream Cipher Modes
DES in Stream Cipher Modes
As we from previous tutorials, DES algorithm is a block cipher algorithm. But it can be operated
in different ways to become stream ciphers.
(FIPS 81) Federal Information Processing Standards Publication 81 published in 1980 defined the following
4 operation modes:
 ECB  Electronic Code Book operation mode.
 CBC  Cipher Block Chaining operation mode.
 CFB  Cipher Feedback operation mode
 OFB  Output Feedback operation mode
See http://www.itl.nist.gov/fipspubs/fip81.htm for details.
In FIPS 81, the last two operation modes, CFB and OFB, are defined in ways so that they can be used as
stream ciphers.
In order to describe these operation modes, we need to define the following notations:
P = P[1], P[2], P[3], ..., P[i], ...  Representing the original plaintext message, P, being arranged into multiple 64bit
plaintext blocks. P[i] represents plaintext block number i.
E(P[i])  Representing the DES encryption algorithm applied on a single 64bit plaintext block, P[i], with a predefined key, k.
C = C[1], C[2], C[3], ..., C[i], ...  Representing the final ciphertext message, C, being regrouped from multiple 64bit
ciphertext blocks. C[i] represents ciphertext block number i.
IV  Called "Initial Vector", representing a predefined 64bit initial value.
CFB (Cipher FeedBack) Operation Mode as a Stream Cipher
CFB (Cipher FeedBack) operation mode as a block cipher can be described with notations defined earlier
as the following formula and diagram:
C[i] = P[i] XOR E(C[i1])
C[1] = P[1] XOR E(IV)
IV
  
E() / E() / E()
 /  / 
 /  / 
P[1]XOR / P[2]XOR / P[3]XOR
 /  / 
 /  / 
C[1] C[2] C[3]
As you can see from the formula and the diagram, in CBC mode, each block of plaintext is XORed with the encrypted version of
the previous ciphertext to generate the current ciphertext block.
In this way, each ciphertext block is depending on all plaintext blocks up to that
point. Note that for the first block, the Initial Vector (IV) is used as the previous ciphertext block.
In order to run the CFB operation mode as a stream cipher, FIPS 81 defines CFB variations where plaintext blocks
can have any size less than 64 bits. To describe CFB variations, we need the following additional notations:
k  Representing the size plaintext blocks. k can have a value between 1 and 64.
Fk()  Representing a filter function that take the first k bits of a 64bit block.
I = I[1], I[2], I[3], ..., I[i], ...  Representing the input block, I, used as input to the DES encryption process.
Sk()  Representing a shifting function that shifts k bits out of the input block from the left side.
The missing k bits are taken from the ciphertext block.
(Continued on next part...)
Part:
1
2
3
4
