CNS UNIT- 2
CNS UNIT- 2
A stream cipher is one that encrypts a digital data stream one bit or one byte
at a time.
Examples of classical stream ciphers are the autokeyed Vigenère cipher and the
Vernam cipher.
In the ideal case, a one-time pad version of the Vernam cipher would be used, in
which the keystream (Ki) is as long as the plaintext bit stream (Pi). If the
cryptographic keystream is random, then this cipher is unbreakable by any
means other than acquiring the keystream.
A block cipher is one in which a block of plaintext is treated as a whole and used
to produce a ciphertext block of equal length. Typically, a block size of 64 or
128 bits is used. As with a stream cipher, the two users share a symmetric
encryption key.
The logic of a general substitution cipher for A 4-bit input produces one of 16
possible input states, which is mapped by the substitution cipher into a unique
one of 16 possible output states, each of which is represented by 4 ciphertext
bits.
A block cipher is designed by considering its three critical aspects which are
listed as below:
1. Number of Rounds
2. Design of Function F
3. Key Schedule Algorithm
1. Number of Rounds
The number of rounds judges the strength of the block cipher algorithm. It is
considered that more is the number of rounds, difficult is for cryptanalysis to
break the algorithm.
2. Design of Function F
The function F of the block cipher must be designed such that it must be
impossible for any cryptanalysis to unscramble the substitution. The criterion
that strengthens the function F is it non-linearity.
More the function F is nonlinear, more it would be difficult to crack it. Well,
while designing the function F it should be confirmed that it has a good
avalanche property which states that a change in one-bit of input must reflect
the change in many bits of output.
It is suggested that the key schedule should confirm the strict avalanche
effect and bit independence criterion.
Since DES is based on the Feistel Cipher, all that is required to specify DES is −
Round function
Key schedule
Any additional processing − Initial and final permutation
Initial and Final Permutation
The initial and final permutations are straight Permutation boxes (P-boxes) that
are inverses of each other. They have no cryptography significance in DES. The
initial and final permutations are shown as follows −
The heart of this cipher is the DES function, f. The DES function applies a 48-
bit key to the rightmost 32 bits to produce a 32-bit output.
Expansion Permutation Box − Since right input is 32-bit and round key is a 48-
bit, we first need to expand right input to 48 bits. Permutation logic is
graphically depicted in the following illustration
Key Generation
The round-key generator creates sixteen 48-bit keys out of a 56-bit cipher key.
The process of key generation is depicted in the following illustration
AES does not use a Feistel structure. Instead, each full round consists of four
separate functions: byte substitution, permutation, arithmetic operations over a
finite field, and XOR with a key.
Figure shows the overall structure of the AES encryption process. The cipher
takes a plaintext block size of 128 bits, or 16 bytes. The key length can be 16,
24, or 32 bytes (128, 192, or 256 bits). The algorithm is referred to as AES-
128, AES-192, or AES-256, depending on the key length.
Advanced Encryption Standard is found at least six time faster than triple DES.
A replacement for DES was needed as its key size was too small. With
increasing computing power, it was considered vulnerable against exhaustive key
search attack. Triple DES was designed to overcome this drawback but it was
found slow.
Operation of AES
Interestingly, AES performs all its computations on bytes rather than bits.
Hence, AES treats the 128 bits of a plaintext block as 16 bytes. These 16 bytes
are arranged in four columns and four rows for processing as a matrix −
Unlike DES, the number of rounds in AES is variable and depends on the length
of the key. AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit keys and
14 rounds for 256-bit keys. Each of these rounds uses a different 128-bit
round key, which is calculated from the original AES key.
Encryption Process
The 16 input bytes are substituted by looking up a fixed table (S-box) given in
design. The result is in a matrix of four rows and four columns.
Shiftrows
Each of the four rows of the matrix is shifted to the left. Any entries that „fall
off‟ are re-inserted on the right side of row. Shift is carried out as follows −
[ b0 | b1 | b2 | b3 ] [ b0 | b1 | b2 | b3 ]
| b4 | b5 | b6 | b7 | -> | b5 | b6 | b7 | b4 |
| b8 | b9 | b10 | b11 | | b10 | b11 | b8 | b9 |
[ b12 | b13 | b14 | b15 ] [ b15 | b12 | b13 | b14 ]
MixColumns
[ c0 ] [ 2 3 1 1 ] [ b0 ]
| c1 | = | 1 2 3 1 || b1 |
| c2 | | 1 1 2 3 || b2 |
[ c3 ] [ 3 1 1 2 ][ b3 ]
The 16 bytes of the matrix are now considered as 128 bits and are XORed to
the 128 bits of the round key. If this is the last round then the output is the
ciphertext. Otherwise, the resulting 128 bits are interpreted as 16 bytes and
we begin another similar round.
Decryption Process
Since sub-processes in each round are in reverse manner, unlike for a Feistel
Cipher, the encryption and decryption algorithms needs to be separately
implemented, although they are very closely related.
AES Analysis
However, just as for DES, the AES security is assured only if it is correctly
implemented and good key management is employed.
BLOWFISH ALGORITHM
Now each of the subkey is changed with respect to the input key as:
The resultant P-array holds 18 subkeys that is used during the entire
encryption process
Step3: Encryption:
Linear Cryptanalysis
A block cipher processes the data blocks of fixed size. Usually, the size of a
message is larger than the block size. Hence, the long message is divided into a
series of sequential message blocks, and the cipher operates on these blocks
one at a time.
This mode is a most straightforward way of processing a series of sequentially listed message
blocks.
Operation
The user takes the first block of plaintext and encrypts it with the key
to produce the first block of ciphertext.
He then takes the second block of plaintext and follows the same process
with same key and so on so forth.
The ECB mode is deterministic, that is, if plaintext block P1, P2,…, Pm are
encrypted twice under the same key, the output ciphertext blocks will be the
same.
In reality, any application data usually have partial information which can be
guessed. For example, the range of salary can be guessed. A ciphertext from
ECB can allow an attacker to guess the plaintext by trial-and-error if the
plaintext message is within predictable.
For example, if a ciphertext from the ECB mode is known to encrypt a salary
figure, then a small number of trials will allow an attacker to recover the figure.
In general, we do not wish to use a deterministic cipher, and hence the ECB
mode should not be used in most applications.
Operation
The operation of CBC mode is depicted in the following illustration. The steps
are as follows −
In CBC mode, the current plaintext block is added to the previous ciphertext
block, and then the result is encrypted with the key. Decryption is thus the
reverse process, which involves decrypting the current ciphertext and then
adding the previous ciphertext block to the result.
It is worth mentioning that CBC mode forms the basis for a well-known data
origin authentication mechanism. Thus, it has an advantage for those
applications that require both symmetric encryption and data origin
authentication.
In this mode, each ciphertext block gets „fed back‟ into the encryption process
in order to encrypt the next plaintext block.
Operation
The operation of CFB mode is depicted in the following illustration. For example,
in the present system, a message block has a size „s‟ bits where 1 < s < n. The
CFB mode requires an initialization vector (IV) as the initial random n-bit input
block. The IV need not be secret. Steps of operation are −
CFB mode differs significantly from ECB mode, the ciphertext corresponding to
a given plaintext block depends not just on that plaintext block and the key, but
also on the previous ciphertext block. In other words, the ciphertext block is
dependent of message.
CFB has a very strange feature. In this mode, user decrypts the ciphertext
using only the encryption process of the block cipher. The decryption algorithm
of the underlying block cipher is never used.
Apparently, CFB mode is converting a block cipher into a type of stream cipher.
The encryption algorithm is used as a key-stream generator to produce key-
stream that is placed in the bottom register. This key stream is then XORed
with the plaintext as in case of stream cipher.
By converting a block cipher into a stream cipher, CFB mode provides some of
the advantageous properties of a stream cipher while retaining the
advantageous properties of a block cipher.
On the flip side, the error of transmission gets propagated due to changing of
blocks.
It involves feeding the successive output blocks from the underlying block
cipher back to it. These feedback blocks provide string of bits to feed the
encryption algorithm which act as the key-stream generator as in case of CFB
mode.
Operation
Both encryption and decryption in CTR mode are depicted in the following
illustration. Steps in operation are −
Load the initial counter value in the top register is the same for both the
sender and the receiver. It plays the same role as the IV in CFB (and
CBC) mode.
Encrypt the contents of the counter with the key and place the result in
the bottom register.
Take the first plaintext block P1 and XOR this to the contents of the
bottom register. The result of this is C1. Send C1 to the receiver and
update the counter. The counter update replaces the ciphertext
feedback in CFB mode.
Continue in this manner until the last plaintext block has been encrypted.
The decryption is the reverse process. The ciphertext block is XORed
with the output of encrypted contents of counter value. After decryption
of each ciphertext block counter is updated as in case of encryption.
A typical stream cipher encrypts plaintext one byte at a time, although a stream
cipher may be designed to operate on one bit at a time or on units larger than a
byte at a time. A key is input to a pseudorandom bit generator that produces a
stream of 8-bit numbers that are apparently random. The output of the
generator, called a keystream, is combined one byte at a time with the plaintext
stream using the bit- wise exclusive-OR (XOR) operation. For example, if the
next byte generated by the generator is 01101100 and the next plaintext byte
is 11001100, then the resulting ciphertext byte is
STREAM CIPHERS
RC4
RC4 is a stream cipher designed in 1987 by Ron Rivest for RSA Security. It is a
vari- able key size stream cipher with byte-oriented operations. The algorithm
is based on the use of a random permutation. Analysis shows that the period of
the cipher is over-whelmingly likely to be greater than 10100. Eight to sixteen
machine operations are required per output byte, and the cipher can be
expected to run very quickly in software. RC4 is used in the Secure Sockets
Layer/Transport Layer Security (SSL/TLS) standards that have been defined
for communication between Web browsers and servers.
The RC4 algorithm is remarkably simple and quite easy to explain. A vari- able-
length key of from 1 to 256 bytes (8 to 2048 bits) is used to initialize a 256-
byte state vector S, with elements S[0],S[1],S[2],. . . . . S[255].
Initialization of S
To begin, the entries of are set equal to the values from 0 through 255 in
ascending order; that is, S[0],S[1],S[2],. . . . . S[255]=255.
A temporary vector, T, is also created. If the length of the key K is 256 bytes,
then T is transferred to T. Otherwise, for a key of length keylen bytes, the
first keylen elements of T are copied from K, and then K is repeated as many
times as necessary to fill out T. These preliminary operations can be
summarized as
Once the S vector is initialized, the input key is no longer used. Stream
generation involves cycling through all the elements of S[i] , and for each S[i],
swapping S[i] with another byte in S according to a scheme dictated by the
current configuration of S. After S[255]is reached, the process continues,
starting over again at S[0].
/* Stream Generation */
i, j = 0;
while (true)
i = (i + 1) mod 256;
j = (j + S[i]) mod 256;
Swap (S[i], S[j]);
t = (S[i] + S[j]) mod 256;
k = S[t];
The most powerful and most common approach to securing the points of
vulnerability highlighted in the preceding section is encryption. If encryption is
to be used to counter these attacks, then we need to decide what to encrypt
and where the encryption gear should be located. As Figure indicates, there are
two fundamental alternatives: link encryption and end-to-end encryption.
The second problem that Diffie pondered, and one that was apparently
unrelated to the first, was that of digital signatures.
A public key encryption scheme has the following ingredients which are as
follows
1. Each user generates a pair of keys to be used for the encryption and
decryption of messages.
2. Each user places one of the two keys in a public register or other accessible
file. This is the public key.The companion key is kept private. As in Figure
suggests, each user maintains a collection of public keys obtained from others.
4. When Alice receives the message, she decrypts it using her private key. No
other recipient can decrypt the message because only Alice knows Alice‟s
private key.
The computation of the pair of keys i.e. private key and the public key
must be easy.
Knowing the encryption algorithm and public key of the intended receiver,
computation of cipher text must be easy.
For a receiver of the message, it should be computationally easy to
decrypt the obtained cipher text using his private key.
It is also required that any opponent in the network knowing the public
key should be unable to determine its corresponding private key.
Having the cipher text and public key an opponent should be unable to
determine the original message.
The two keys i.e. public and private key can be implemented in both
orders D[PU, E(PR, M)] = D[PR, E(PU, M)]
In this algorithm two keys were used. One is private key and another one is
public key.
In this scheme the two parties, who want to communicate securely, can agree on
a symmetric key using this technique. This key can then be used for encryption/
decryption. However, we must note that Diffie–Hellman key exchange algorithm
can be used only for key agreement, but not for encryption or decryption of
messages. Once both the parties agree on the key to be used, they need to use
other symmetric key encryption algorithms for actual encryption or decryption
of messages.
1. Key generation
2. Encryption
3. Decryption
The more frequently session keys are exchanged, the more secure they are,
because the opponent has less ciphertext to work with for any given session
The use of a key distribution center imposes the requirement that the KDC be
trusted and be protected from subversion. This requirement can be avoided if
key distribution is fully decentralized. Although full decentralization is not
practical for larger networks using symmetric encryption only, it may be useful
within a local context.
1. Public announcement
2. Publicly available directory
3. Public-key authority
4. Public-key certificates.