Unit 2
Unit 2
UNIT II
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.
A block cipher can be used to achieve the same effect as a stream cipher. In general,
they seem applicable to a broader range of applications than stream ciphers. The vast
majority of network-based symmetric cryptographic applications make use of block ciphers.
Encryption should be reversible. Figure shows the logic of a general substitution cipher for
n=4 (block size).
In general the logic of a general substitution cipher for n=4 with 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 cipher text bits. The
encryption and decryption mappings can be defined by tabulation, as shown below.
This is the most general form of block cipher and can be used to define any
reversible mapping between plaintext and ciphertext. Feistel refers to this as the ideal block
cipher, because it allows for the maximum number of possible encryption mappings from
the plaintext block.
Adding k successive letters to get a ciphertext letter yn. The letter frequencies in the
ciphertext will be more nearly equal than in the plaintext (structure dissipated).
Confusion seeks to make the relationship between the statistics of the ciphertext and and
the value of the encryption key as complex as possible. This is achieved by the use of a
complex substitution algorithm. These operations became the cornerstone of modern block
cipher design.
The inputs to the encryption algorithm are a plaintext block of length 2w bits and a key K.
The plaintext block is divided into 2 halves, L0 and R0. The 2 halves of the data pass through
n rounds of processing and the combine to produce the ciphertext block. Each round i has as
inputs L i-1 and Ri-1, derived from the previous round, as well as a subkey K i, derived from
the overall K. In general, the subkeys K i are different from K and from each other.
All rounds have the same structure. A substitution is performed on the left half of the data.
This is done by applying a round function F to the right half of the data and then taking
exclusive –OR of the output of that function and the left half of the data. The round function
has the same general structure for each round but is parameterized by the round subkey K i .
Following this substitution, a permutation is performed that consists of the interchange of
the two halves of the data. This structure is a particular form of the substitution-
permutation network (SPN) proposed by Shannon.
The exact realization of a Feistel network depends on the choice of the following
parameters and design features:
Block size: large size means greater security but greater overhead (64, 128 bits)
Key size: large size means greater security but greater overhead (64, 128 bits)
Number of rounds: multiple rounds increase security (16 rounds)
Subkey generation algorithm: greater complexity – more secure
Round function: greater complexity – more secure
Additionally:
We can see that SDES exhibits a Feistel structure with 2 rounds. The one difference from a
“pure” Feistel structure is that the algorithm begins and ends with a permutation function.
This difference also appears in full DES.
********************************************
SIMPLIFIED DES
S-DES encryption algorithm takes 8-bit block of plaintext and a 10-bit key, and produces 8-
bit ciphertext block. Encryption algorithm involves 5 functions: an initial permutation (IP); a
complex function fK, which involves both permutation and substitution and depends on a
key input; a simple permutation function that switches (SW) the 2 halves of the data; the
function fK again; and finally, a permutation function that is the inverse of the initial
permutation (IP-1). Decryption process is similar.
The function fK takes 8-bit key which is obtained from the 10-bit initial key. The key is
first subjected to a permutation P10. Then a shift operation is performed. The output of the
shift operation then passes through a permutation function that produces an 8-bit output
(P8) for the first subkey (K1). The output of the shift operation also feeds into another shift
and another instance of P8 to produce the 2nd subkey K2.
-1
Ciphertext = IP ( f K2 ( SW ( f K1 ( IP( pla int ext )))))
Where,
-1
Plaintext = IP ( f K1 ( SW ( f K 2 ( IP (ciphertext )))))
P10(k1,k2,k3,k4,k5,k6,k7,k8,k9,k10) = (k3,k5,k2,k7,k4,k10,k1,k9,k8,k6)
Next, perform a circular shift (LS-1), or rotation, separately on the 1st 5 bits and the 2nd 5
bits. In our example, the result is (00001 11000) Next, we apply P8, which picks out and
permutes 8 out of 10 bits according to the following rule:
P8
6 3 7 4 8 5 10 9
The result is subkey is K1. In our example, this yields (10100100)
We then go back to the pair of 5-bit strings produced by the 2 LS-1 functions and perform a
circular left shift of 2 bit positions on each string. In our example, the value (00001 11000)
becomes (00100 00011). Finally, P8 is applied again to produce K2. In our example, the
result is (01000011).
S-DES ENCRYPTION
The input to the algorithm is an 8-bit block of plaintext, which is permuted by IP function:
IP
2 6 3 1 4 8 5 7
IP-1
4 1 3 5 7 2 8 6
The most complex component of S-DES is the function fK, which consists of a combination of
permutation and substitution functions. The function can be expressed as follows. Let L and
R be the leftmost 4 bits and rightmost 4 bits of the 8-bit input to fK, and let F be a mapping
(not necessarily one to one) from 4-bit strings to 4-bit strings. Then we let
fK(L,R) = (L ⊕ F(R,SK),R)
where SK is a subkey and ⊕ is the bit-by-bit XOR operation. For example, suppose the
output of the IP stage in Fig.3.3 is (1011 1101) and F(1101,SK) = (1110) for some key SK.
Then fK(1011 1101) = (0101 1101) because (1011) ⊕ (1110) = (0101).
We now describe the mapping F. The input is a 4-bit number (n1 n2 n3 n4). The 1st
operation is an expansion/permutation:
E/P
4 1 2 3 2 3 4 1
output, and the remaining 4 bits (2nd row) are fed into S1 to produce another 2-bit output.
These 2 boxes are defined as follows:
0123 0 12 3
1 032 0 01 2 3 0
3 210 1 20 1 3 1
S0 = 2 S 1 = 30 2
0 213 1 0
3 3 21 3
132 0 3
The S-boxes operate as follows. The 1st and 4th input bits are treated as a 2-bit number
that specify a row of the S-box, and the 2nd and 3rd input bits specify a column of the S-
box. The entry in that row and column, in base 2, is the 2-bit output. For example, if
(p00, p03) = (00) and (p01, p02) = (10), then the output is from row 0, column 2 of S0,
which is 3, or (11) in binary. Similarly, (p10, p13) and (p11, p12) are used to index into a
row and column of S1 to produce an additional 2 bits.
P4
2 4 3 1
The output of P4 is the output of function F.
The function fK only alters the leftmost 4 bits of input. The switch function SW interchanges
the left and right bits so that the 2nd instance of fK operates on a different 4 bits. In the 2nd
instance, the E/P, S0, S1, and P4 functions are the same. The key input is K2.
q=abcd+ab+ac+b+d
r=abcd+abd+ab+ac+ad+a+c+1
where all additions are made modulo 2. Similar equations define S1. Alternating linear maps
with these nonlinear maps results in very complex polynomial expressions for the cipher
text bits, making cryptanalysis difficult.
********************************************
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the
National Institute of Standards and Technology (NIST).
DES is an implementation of a Feistel Cipher. It uses 16 round Feistel structure. The block
size is 64-bit. Though, key length is 64-bit, DES has an effective key length of 56 bits, since 8
of the 64 bits of the key are not used by the encryption algorithm (function as check bits
only).
The 64 bit input enters into initial permutation and the permutated output is fed into
sixteen rounds with kay values and then 32-bit swap swaps left and 32-bit halves obtained
after Round 16, we get preoutput. Finally, preoutput passes through a permutation IP-1,
that is inverse to initial permutation IP, to produce the 64-bit ciphertext. The right-hand
portion of Fig. 3.7 shows the way in which 56-bit is used. For each of 16 rounds a subkey Ki
is produced by the combination of a left circular shift and a permutation. The permutation
function is the same for each round.
IP:
IP-1
The left and right halves of each 64-bit intermediate value are treated as separate 32-bit
quantities, labeled L and R. As in the classic Feistel cipher, the overall process at each round
is summarized as follows:
Li = Ri −1
Ri = Li −1 ⊕ F ( Ri −1 , K i )
The round key Ki is 48 bits. The R input is 32 bits. This R input is first expanded to 48 bits by
Expansion/Permutation (E table):
Expansion/Permutation
(E / P table)
32 1 2 3 4 5
4 5 6 7 8 9
8 9 10 11 12 13
12 13 14 15 16 17
16 17 18 19 20 21
20 21 22 23 24 25
24 25 26 27 28 29
28 29 30 31 32 1
The resulting 48 bits are XORed with Ki. This 48 bit result passes through a substitution
function that produces 32-bit output, which is permuted by Permutation function (P):
Permutation function( P )
16 7 20 21 29 12 28 17
1 15 23 26 5 18 31 10
2 8 24 14 32 27 3 9
19 13 30 6 22 11 4 25
The role of S-boxes is illustrated in the below figure:
The substitution consists of a set of 8 S-boxes, each of which accepts 6 bits input and
produces 4 bits as output. These transformations are:
Each row of an S-box defines a general reversible substitution: middle 4 bits of each group
of 6-bit input are substituted by S-box output, 1st and last 6th bits define what particular
substitution out of to use.
KEY GENERATION
Input key has 64 bits. But each 8th bit is not used: bits 8,16,24,32,40,48,56,64 are not further
used. The 56-bit key is first subjected to permutation Permuted Choice 1:
F ( Ri −1 , K i ) .
Permuted Choice 2 (PC-2)
14 17 11 24 1 5 3 28
15 6 21 10 23 19 12 4
26 8 16 7 27 20 13 2
41 52 31 37 47 55 30 40
51 45 33 48 44 49 39 56
34 53 46 42 50 36 29 32
DES DECRYPTION
As with any Feistel cipher, decryption uses the same algorithm as encryption, except that
the application of subkeys is reversed.
Avalanche effect − A small change in plaintext results in the very grate change in the
ciphertext. 1 bit change in the plaintext leads to 34 bit difference in the ciphertext. 1 bit
change in the key leads to 35 bit difference in the ciphertext.
********************************************
Design criteria for S-boxes were not made public, so there was a concern that cryptanalysis
is possible for an opponent who knows the weaknesses in S-boxes. Up to now, there are no
published results about such weaknesses in S-boxes.
DES also appears to be resistant to timing attack but suggest some avenues to explore.
Timing attack tries to understand essence of algorithm by analysis of time of its work on
different inputs.
One of such approaches yields a Hamming weight (number of bits equal to 1) of the secret
key.
********************************************
Next, we look at the use of encryption to counter traffic analysis attacks. Then we discuss
the difficult problem of key distribution. Finally, we discuss the principles underlying an
important tool in providing a confidentiality facility: random number generation.
PLACEMENT OF ENCRYPTION
If encryption is to be used to counter attacks on confidentiality, we need to decide what to
encrypt and where the encryption function should be located. To begin, this section
examines the potential locations of security attacks and then looks at the two major
approaches to encryption placement: link and end to end.
There are a large number of locations at which an attack can occur. Furthermore, for wide
area communications, many of these locations are not under the physical control of the end
user. Even in the case of local area networks, in which physical security measures are
possible, there is always the threat of the disgruntled employee.
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. There are two fundamental alternatives: link encryption and end-to-end
encryption.
End-To-End Encryption
With end-to-end encryption, the encryption process is carried out at the two end
systems. The source host or terminal encrypts the data. The data in encrypted form are
then transmitted unaltered across the network to the destination terminal or host. The
destination shares a key with the source and so is able to decrypt the data. This plan
seems to secure the transmission against attacks on the network links or switches. Thus,
end-to-end encryption relieves the end user of concerns about the degree of security of
networks and links that support the communication. There is, however, still a weak spot.
Thus, with end-to-end encryption, the user data are secure. However, the traffic
pattern is not, because packet headers are transmitted in the clear. On the other hand,
end-to-end encryption does provide a degree of authentication. If two end systems share
an encryption key, then a recipient is assured that any message that it receives comes
from the alleged sender, because only that sender shares the relevant key. Such
authentication is not inherent in a link encryption scheme.
To achieve greater security, both link and end-to-end encryptions are needed, as is
shown in Figure. When both forms of encryption are employed, the host encrypts the
user data portion of a packet using an end-to-end encryption key. The entire packet is
then encrypted using a link encryption key. As the packet traverses the network, each
switch decrypts the packet, using a link encryption key to read the header, and then
encrypts the entire packet again for sending it out on the next link. Now the entire
packet is secure except for the time that the packet is actually in the memory of a
packet switch, at which time the packet header is in the clear.
Link Encryption End-to-End Encryption
Link encryption encrypts all the data along a End-to-end encryption, the headers,
specific communication path. Not only is the addresses, routing, and trailer information
user information encrypted, but the header, are not encrypted, enabling attackers to learn
trailers, addresses, and routing data that are more about a captured packet and where it is
part of the packets are also encrypted. headed.
Requires one key per host pair. Requires one key per user pair.
With link encryption, the encryption function is performed at a low level of the
communications hierarchy i.e. physical or link layers.
For end-to-end encryption, several choices are possible for the logical placement
of the encryption function. At the lowest practical level, the encryption function could be
performed at the network layer.
The following figure illustrates the issues involved. In this example, an electronic mail
gateway is used to interconnect an internetwork that uses a TCP/IP-based architecture. In
such a configuration, there is no end-to-end protocol below the application layer. The
transport and network connections from each end system terminate at the mail gateway,
which sets up new transport and network connections to link to the other end system.
Even if both end systems use TCP/IP or OSI, there are plenty of instances in actual
configurations in which mail gateways sit between otherwise isolated internetworks. Thus,
for applications like electronic mail that have a store-and-forward capability, the only place
to achieve end-to-end encryption is at the application layer.
Furthermore, the gateway is treated as a destination by the underlying IP. Thus, the
encrypted portions of the data unit are decrypted at the gateway. If the next hop is over a
TCP/IP network, then the user data and TCP header are encrypted again before
transmission. However, in the gateway itself the data unit is buffered entirely in the clear.
Finally, for link-level encryption , the entire data unit except for the link header and trailer
is encrypted on each link, but the entire data unit is in the clear at each router and
gateway.
********************************************
TRAFFIC CONFIDENTIALITY
The following types of information that can be derived from a traffic analysis attack:
• Identities of partners
• The events that correlate with special conversations between particular partners
Another concern related to traffic is the use of traffic patterns to create a covert channel.
Typically, the channel is used to transfer information in a way that violates a security policy.
For example, an employee may wish to communicate information to an outsider in a way
that is not detected by management and that requires simple eavesdropping on the part of
the outsider.
With the use of link encryption, network-layer headers (e.g., frame or cell header)
are encrypted, reducing the opportunity for traffic analysis. However, it is still possible in
those circumstances for an attacker to assess the amount of traffic on a network and to
observe the amount of traffic entering and leaving each end system. An effective
countermeasure to this attack is traffic padding.
Traffic padding produces cipher text output continuously, even in the absence of
plaintext. A continuous random data stream is generated. When plaintext is available, it
is encrypted and transmitted. When input plaintext is not present, random data are
encrypted and transmitted. This makes it impossible for an attacker to distinguish
between true data flow and padding and therefore impossible to deduce the amount of
traffic.
One technique that might prove useful is to pad out data units to a uniform length
at either the transport or application level. In addition, null messages can be inserted
randomly into the stream. These tactics deny opponent knowledge about the amount of
data exchanged between end users and obscure the underlying traffic pattern.
*******************************************
KEY DISTRIBUTION
For symmetric encryption to work, the two parties to an exchange must share the
same key, and that key must be protected from access by others. Furthermore, frequent
key changes are usually desirable to limit the amount of data compromised if an attacker
learns the key. Therefore, the term that refers to the means of delivering a key to two
parties who wish to exchange data, without allowing others to see the key. For two
parties A and B, key distribution can be achieved in a number of ways, as follows:
2. A third party can select the key and physically deliver it to A and B.
3. If A and B have previously and recently used a key, one party can transmit the new
key to the other, encrypted using the old key.
4. If A and B each has an encrypted connection to a third party C, C can deliver a key
on the encrypted links to A and B.
Physical delivery (1 & 2) is simplest - but only applicable when there is personal contact
between recipient and key issuer. This is fine for link encryption where devices & keys
occur in pairs, but does not scale as number of parties who wish to communicate grows. 3
is mostly based on 1 or 2 occurring first.
A third party, whom all parties trust, can be used as a trusted intermediary to
mediate the establishment of secure communications between them (4). Must trust
intermediary not to abuse the knowledge of all session keys. As number of parties grow,
some variant of 4 is only practical solution to the huge growth in number of keys
potentially needed.
• The use of a key distribution center is based on the use of a hierarchy of keys. At a
minimum, two levels of keys are used.
• Typically, the session key is used for the duration of a logical connection and then
discarded
• master key is shared by the key distribution center and an end system or user and
used to encrypt the session key.
1. A issues a request to the KDC for a session key to protect a logical connection to B.
The message includes the identity of A and B and a unique identifier, N1, for this
transaction, which we refer to as a nonce. The nonce may be a timestamp, a counter,
or a random number; the minimum requirement is that it differs with each request.
Also, to prevent masquerade, it should be difficult for an opponent to guess the
nonce. Thus, a random number is a good choice for a nonce.
2. The KDC responds with a message encrypted using Ka Thus, A is the only one who can
successfully read the message, and A knows that it originated at the KDC. The
message includes two items intended for A:
Thus, A can verify that its original request was not altered before reception by the KDC
and, because of the nonce, that this is not a replay of some previous request.
3. A stores the session key for use in the upcoming session and forwards to B the
information that originated at the KDC for B, namely, E(Kb, [Ks || IDA]). Because this
information is encrypted with Kb, it is protected from eavesdropping. B now knows
the session key (Ks), knows that the other party is A (from IDA), and knows that the
information originated at the KDC (because it is encrypted using
Kb).
At this point, a session key has been securely delivered to A and B, and they may begin
their protected exchange. However, two additional steps are desirable:
4. Using the newly minted session key for encryption, B sends a nonce, N2, to A.
5. Also using Ks, A responds with f(N2), where f is a function that performs some
transformation on N2 (e.g., adding one).
These steps assure B that the original message it received (step 3) was not a replay.
Note that the actual key distribution involves only steps 1 through 3 but that steps 4 and 5,
as well as 3, perform an authentication function.
To balance security & effort, a new session key should be used for each new
connection-oriented session. For a connectionless protocol, a new session key is used for
a certain fixed period only or for a certain number of transactions.
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. In addition to separating master keys from session keys,
may wish to define different types of session keys on the basis of use.
********************************************
RANDOM NUMBER GENERATION
Random Numbers many uses of random numbers in cryptography
– session keys
********************************************