Unit III
Unit III
Unit III
The overall structure of the simplified DES shown in Figure 2.5. The S-DES encryption
algorithm takes an 8-bit block of plaintext (example: 10111101) and a 10-bit key as input and
produces an 8-bit block of ciphertext as output.
The S-DES decryption algorithm takes an 8-bit block of ciphertext and the same 10-bit key
used to produce that ciphertext as input and produces the original 8-bit block of plaintext.
First, permute the key in the following fashion. Let the 10-bit key be designated as(k1,
K2, k3, k4, k5, k6, k7, k8, k9, k10). Then the permutation P10 is defined as:
P10 (k1, K2, k3, k4, k5, k6, k7, k8, k9, k10) = (k3, k5, K2, k7, k4, k10 10, k1, k9,k8,
k6).
P10 can be concisely defined by the display:
This table is read from left to right; each position in the table gives the identity of the
input bit that produces the output bit in that position. So, the first output bit is bit 3 ofthe input;
the second output bit is bit 5 of the input, and so on.
Example
The 10 bit key is (1010000010), now find the permutation from P10 for this key so
it becomes (10000 01100).
Next, perform a circular left shift (LS-1), or rotation, separately on the first five bits and
the second five bits. In our example, the result is (00001 11000).
Next, apply P8, which picks out and permutes 8 of the 10 bits according to the following
rule:
So, The result is subkey 1 (K1). In our example, this yield (10100100).
Then go back to the pair of 5-bit strings produced by the two LS-1 functions and performs
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
Encryption involves the sequential application of five functions (Figure 2.7).
1. Initial Permutations
The input to the algorithm is an 8-bit block of plaintext, which we first permute using the
IP function
The most complex component of S-DES is the function fk, which consists of a
combination of permutation and substitution functions. The functions can be expressed asfollows.
Let L and R be the leftmost 4 bits and rightmost 4 bits of the 8-bit input to f K, 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 sub key and ⊕is the bit-by- bit exclusive OR function
Now, describe the mapping F. The input is a 4-bit number (n1 n2 n3 n4). The firstoperation is
an expansion/permutation operation:
The S-boxes operate as follows. The first and fourth input bits are treated as a 2- bit
number that specify a row of the S-box, and the second and third input bits specify a column of the
S-box. Each s box gets 4-bit input and produce 2 bits as output. It follows 00- 0, 01-1, 10-2, 11-3
scheme.
Here, take first 4 bits, Second 4 bits
S0 => 1101 S1 => 1001
11 - > 3 11 -> 3
Now, find P4
1110 1100
4. Second function fk
First, do E/P function and XOR with K 2, the value is 01101001⊕01000011, the answer is
00101010
Now, find S0 and S1
S0 => 00 - > 0 S1 = > 10 -> 2
S-DES Decryption
Decryption involves the sequential application of five functions.
1. Find IP
After IP, value is 11101100
2. Function fk
After step 2, the answer is 11101100
3. Swift
The answer is 11001110
4. Second fk
The answer is 01111110
5. Find IP-1
101111101 -> Plaintext
The most widely used encryption scheme is based on the Data Encryption Standard (DES)
adopted in 1977. The algorithm itself is referred to as the Data Encryption Algorithm (DEA).
For DES, data are encrypted in 64-bit blocks using a 56-bit key. The algorithm transforms 64-bit
input in a series of steps into a 64-bit output.
DES Encryption
The overall scheme for DES encryption is illustrated in the Figure 2.8. There are two inputs to the
encryption function: the plaintext to be encrypted and the key. The plaintext must be 64 bits in length
and the key is 56 bits in length.
This is followed by a phase consisting of 16 rounds of the same function, which involves both
permutation and substitution functions.
The output of the last (sixteenth) round consists of 64 bits that are a function of the input
plaintext and the key. The left and right halves of the output are swapped to produce the preoutput.
Phase 3:
Finally, the preoutput is passed through a permutation (IP -1) that is the inverse of theinitial
permutation function, to produce the 64-bit ciphertext.
The right-hand portion of Figure shows the way in which the 56-bit key is used.
Operation on key:
Initially, the key is passed through a permutation function. Then, for each of the 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, but a different subkey is producedbecause of the repeated shifts of
the key bits.
M1 M2 M3 M4 M5 M6 M7 M8
M9 M10 M11 M12 M13 M14 M15 M16
M17 M18 M19 M20 M21 M22 M23 M24
M25 M26 M27 M28 M29 M30 M31 M32
M33 M34 M35 M36 M37 M38 M39 M40
M41 M42 M43 M44 M45 M46 M47 M48
M49 M50 M51 M52 M53 M54 M55 M56
M57 M58 M59 M60 M61 M62 M63 M64
Inverse permutation Y = IP-1 (X) = IP-1(IP(M)),Therefore we can see that the original ordering ofthe bits is
restored.
The below figure 2.9 shows the internal structure of a single round. The left and right halves of each 64-
bit intermediate value are treated as separate 32-bit quantities, labeled L (left) and R (right). The overall
processing at each round can be summarized in the following formulas:
Li= Ri-1
The round key Ki is 48 bits. The R input is 32 bits. This R input is first expanded to 48 bits by using a
table that defines a permutation plus an expansion that involves duplication of 16 of the R bits. The
resulting 48 bits are XORed with Ki. This 48-bit result passes through a substitution function that
produces a 32-bit output, which is then permuted.
Definition of S-Boxes
The substitution consists of a set of eight S-boxes, each of which accepts 6 bits as input and
produces 4 bits as output. The first and last bits of the input to box Si form a 2-bit binary number to select
one of four substitutions defined by the four rows in the table for Si. The middle four bits select one of the
sixteen columns as shown in figure 2.10.
The decimal value in the cell selected by the row and column is then converted to its 4- bit
representation to produce the output.
For example, in S1 for input 011001, the row is 01 (row 1) and the column is 1100 (column 12).
The value in row 1, column 12 is 9, so the output is 1001.
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
U19CS702
Cryptography and
Network Security
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
DES Decryption:
As with any Feistel cipher, decryption uses the same algorithm as encryption,except that the application
of the subkeys is reversed. Additionally, the initial andfinal permutations are reversed.
The strength of DES depends on two factors: key size and the nature of the algorithm.
3. Timing Attacks
A timing attack is one in which information about the key or the plaintext is obtained by
observing how long it takes a given implementation to perform decryptions on various ciphertexts. A
timing attack exploits the fact that an encryption or decryption algorithm often takes slightly different
amounts of time on different inputs.
Attacks on DES:
Differential Cryptanalysis
Differential cryptanalysis is the first published attack that is capable of breaking DES in less than 255
complexities. The need to strengthen DES against attacks using differential cryptanalysis played a large
part in the design of the S-boxes and the permutation P.
One of the most significant recent (public) advances in cryptanalysis
Powerful method to analyze block ciphers
Used to analyze most current block ciphers with varying degrees of success
U19CS702
Cryptography and
Network Security
The differential cryptanalysis attack is complex. The rationale behind differential cryptanalysis is
to observe the behavior of pairs of text blocks evolving along each round of the cipher, instead of
observing the evolution of a single text block.
Consider the original plaintext block m to consist of two halves m0, m1. Each round of DES maps
the right-hand input into the left-hand output and sets the right-hand output to be a function of the left-
hand input and the subkey for this round.
So, at each round, only one new 32-bit block is created. If we label each new block
m1(2 ≤ i ≤17), then the intermediate message halves are related as follows:
In differential cryptanalysis, we start with two messages, m and m', with a known XOR difference Δm=
m m', and consider the difference between the intermediate message halves: mi= mi mi' Then we have:
Let us suppose that there are many pairs of inputs to f with the same difference yield the same
output difference if the same subkey is used.
Therefore, if we know Δmi-1 and Δmi with high probability, then we know Δmi+1 with high
probability. Furthermore, if a number of such differences are determined, it is feasible to determine the
subkey used in the function f.
Linear Cryptanalysis
This attack is based on the fact that linear equation can be framed to describe thetransformations.
The principle of linear crypt analysis is as followsLength of
CT and PT =n bits;
key=mbit
Block of cipher text is c[1]c[2]…c[n]; Block
of key is k[1]k[2]….k[m]
A[I,j,..k] = A[i] A[j] . A[k]
Can attack DES with 247 known plaintexts, still in practice infeasible
Find linear approximations with prob p != ½
P[i1,i2,...,ia](+)c[j1,j2,...,jb] = k[k1,k2,...,kc]Where ia, jb, kc are bit locations in p, c, k
U19CS702
Cryptography and
Network Security
Number of Rounds
When the greater the number of rounds, the more difficult it is to perform cryptanalysis,even
for a relatively weak F.
The number of rounds is chosen so that known cryptanalytic efforts require greater effortthan a
simple brute-force key search attack
When round DES S= 16, a differential cryptanalysis attack is slightly less efficient thanbrute
force, the differential cryptanalysis attack requires 255 operations.
It makes it easy to judge the strength of an algorithm and to compare different algorithms.
Design of Function F
The key is used to generate one sub key for each round.
The sub keys to maximize the difficulty of deducing individual sub keys and the difficulty of
working back to the main key.
A stream cipher is one that encrypts a digital data stream one bit or one byte at a time.E.g,
vigenere cipher. Figure (2.11a)
A block cipher is one in which a block of plaintext is treated as a whole and used to produce acipher
text block of equal length. Typically, a block size of 64 or 128 bits is used. Figure (2.11b)
U19CS702
Cryptography and
Network Security
Finally, the output of the last round of the decryption process is RE0 || LE0. A 32-bit swap
recovers the original plaintext.
AES is a symmetric block cipher that is intended to replace DES as the approved standard for a
wide range of applications. Compared to public-key ciphers such as RSA, the structure of AES and most
symmetric ciphers is quite complex and cannot be explained as easily as many other cryptographic,
algorithms.
In AES, all operations are performed on 8-bit bytes. The arithmetic operations of addition,
multiplication, and division are performed over the finite field GF.A field is a set inwhich we can
do addition, subtraction, multiplication, and division without leaving the set.Division is defined with the
following rule: a/b = a(b-1).
An example of a finite field (one with a finite number of elements) is the set Zp consisting of all the
integers {0, 1, c, p - 1}, where p is a prime number and in which arithmetic is carried out modulo p.
The way of defining a finite field containing 2nelements; such a field is referred to as GF(2n).
Consider the set, S, of all polynomials of degree n - 1 or less with binary coefficients. Thus, each
polynomial has the form
U19CS702
Cryptography and
Network Security
Where each ai takes on the value 0 or 1. There are a total of 2ndifferent polynomials in S.For n = 3,
the 23 = 8 polynomials in the set are
AES Structure
General Structure
Figure 2.20 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, or32 bytes (128, 192, or 256 bits).
The algorithm is referred to as AES-128, AES-192, orAES-256, depending on the key length.
U19CS702
Cryptography and
Network Security
The input to the encryption and decryption algorithms is a single 128-bit block. The block is depicted
as a 4 * 4 square matrix of bytes. This block is copied into the State array, which is modified at each
stage of encryption or decryption. After the final stage, State is copied to an output matrix. These
operations are depicted in Figure 2.21a. Similarly, the key is depicted as a square matrix of bytes.
This key is then expanded into an array of key schedule words.
Below Figure 2.20 shows the expansion for the 128-bit key. Each word is four bytes, and the total key
schedule is 44 words for the 128-bit key. Note that the ordering of bytes within a matrix is by column.
The first four bytes of a 128-bit plaintext input to the encryption cipher occupy the first column of the
in matrix. The second four bytes occupy the second column, and so on. Similarly, the first four bytes
of the expanded key, which form a word, occupy the first column of the w matrix. The cipher consists
of N rounds, where the number of rounds depends on the key length: 10 rounds for a 16-byte key, 12
rounds for a 24-byte key, and 14 rounds for a 32-byte key (Table 2.3).
The first N - 1 round consist of four distinct transformation functions: Sub Bytes, Shift Rows, Mix
Columns, and AddRoundKey, which are described subsequently. The final round contains only three
transformations, and there is an initial single transformation (AddRoundKey) before the first round,
which can be considered Round 0. Eachtransformation takes one or more 4 * 4 matrices as input and
produces a 4 * 4 matrix as output Figure 5.1 shows that the output of each round is a 4 * 4 matrix,
with the output of the final round being the cipher text.
U19CS702
Cryptography and
Network Security
Detailed Structure
Below Figure 2.20 shows the AES cipher shows the sequence of transformations in each roundand
showing the corresponding decryption function.
U19CS702
Cryptography and
Network Security
6. Each stage is easily reversible. For the Substitute Byte, ShiftRows, and MixColumns stages, an
inverse function is used in the decryption algorithm. For the AddRoundKey stage, the inverse is
achieved by XORing the same round key to the block, using the result that.
7. The decryption algorithm makes use of the expanded key in reverse order. However, the
decryption algorithm is not identical to the encryption algorithm. This is a consequenceof the
particular structure of AES.
U19CS702
Cryptography and
Network Security
8. Once it is established that all four stages are reversible, it is easy to verify that
decryption does recover the plaintext.
9. The final round of both encryption and decryption consists of only three stages. Again, this is a
consequence of the particular structure of AES and is required, to make the cipherreversible
Four transformations used in AES. For each stage, we describe the forward (encryption)algorithm, the
inverse (decryption) algorithm, and the rationale for the stage.
The forward substitute byte transformation, called Sub Bytes, is a simple tablelookup (Figure
2.24a). AES defines a 16 * 16 matrix of byte values, called an S-box that contains a permutation of all
possible 256 8-bit values.
U19CS702
Cryptography and
Network Security
Each individual byte of State is mapped into a new byte in the following way: The leftmost 4
bits of the byte are used as a row value and the rightmost 4 bits are used as a column value. These row
and column values serve as indexes into the S-box to select a unique8-bit output value as shown in figure
2.25.
For example, the hexadecimal value {95} references row 9, column 5 of the S-box, whichcontains
the value {2A}. Accordingly, the value {95} is mapped into the value {2A}.
1. Initialize the S-box with the byte values in ascending sequence row by row. The first row contains
{00}, {01}, {02}, c, {0F}; the second row contains {10}, {11}, etc.; and so on. Thus, the value of the
byte at row y, column x is {yx}.
2. Map each byte in the S-box to its multiplicative inverse in the finite field GF(28); the value
{00} is mapped to itself.
3. Consider that each byte in the S-box consists of 8 bits labeled (b7, b6, b5, b4, b3,b2, b1, b0).Apply the
following transformation to each bit of each byte in the S-box:
Where ci is the ith bit of byte c with the value {63}; that is, (c7c6c5c4c3c2c1c0) = (01100011). Theprime ( „)
indicates that the variable is to be updated by the value on the right.
U19CS702
Cryptography and
Network Security
In ordinary matrix multiplication, each element in the product matrix is the sum of products of
the elements of one row and one column. Each element in the product matrix is the bitwise XOR
of products of elements of one row and one column.
As an example, consider the input value {95}. The multiplicative inverse in GF(28) is
{95}- 1 = {8A}, which is 10001010 in binary. Using above Equation
U19CS702
Cryptography and
Network Security
The result is {2A}, which should appear in row {09} column {05} of the S-box.
The inverse substitute byte transformation, called InvSubBytes, For example, that the input
{2A}produces the output {95}, and the input {95} to the S-box produces {2A}. The inverse S-box is
constructed by applying the inverse of the transformation is followed by taking the
InvSubBytes is the inverse of Sub Bytes, label the matrices in sub Bytes and InvSubBytes as X
and Y, respectively, and the vector versions of constants c and d as C and D, respectively. For some 8-
bit vector B, becomes . We need to show that
. To multiply out, we must show . This becomes
U19CS702
Cryptography and
Network Security
We have demonstrated that YX equals the identity matrix, and the YC = D,so that YC D
equals the null vector.
The forward shift row transformation, called Shift Rows, is depicted in Figure 2.27. The first
row of State is not altered. For the second row, a 1-byte circular left shift is performed. For the third row,
a 2-bytecircular left shift is performed. For the fourth row, a 3-byte circular left shift is performed. The
following is an example of Shift Rows
The inverse shift row transformation, called InvShiftRows, performs the circular shifts in the
opposite direction for each of the last three rows, with a 1-byte circular right shift for the second row, and
as shown in figure 2.28
U19CS702
Cryptography and
Network Security
Forward and Inverse Transformations: The forward mix column transformation, called
MixColumns, operates on each column individually. Each byte of a column is mapped into a new
value that is a function of all four bytes in that column. The transformation can be defined by the
following matrix multiplication on State
Each element in the product matrix is the sum of products of elements of one rowand one
column. In this case, the individual additions and multiplications are performed in GF(28).
For the first equation, we have {02}.{87} =(0000 1110) (0001 1011) =(0001 0101) and
{03}. {6E} = {6E} ({02}. {6E}) = (0110 1110) (1101 1100) = (1011 0010) then
U19CS702
Cryptography and
Network Security
That is, the inverse transformation matrix times the forward transformation matrixequals the
identity matrix. To verify the first column of above Equation.
For the first equation, we have {0E}.{02} =00011100 and {09}.{03} ={09} {09}.{02} =
00001001 00010010 =00011011then
The encryption was deemed more important than decryption for two reasons:
1. For the CFB and OFB cipher modes only encryption is used.
2. AES can be used to construct a message authentication code and for this, only encryption isused.
In the forward add round key transformation, called AddRoundKey, the 128 bits of State arebitwise
XORed with the 128bits of the round key.
The operation is viewed as a column wise operation between the 4 bytes of a State column andone word
of the roundkey; it can also be viewed as a byte-level operation.
The following is an example ofAddRoundKey:
U19CS702
Cryptography and
Network Security
The first matrix is State, and the second matrix is the round key.
The inverse add round key transformation is identical to the forward addround keytransformation,
because the XOR operation is its own inverse.
The Figure 2.29 is another view of a single round of AES, emphasizing the mechanisms andinputs of each
transformation.
1. RotWord performs a one-byte circular left shift on a word. This means that a input word [B0,B1, B2,
B3] is transformed into [B1, B2, B3, B0].
2. SubWord performs a byte substitution on each byte of its input word, using the S-box.
3. The result of steps 1 and 2 is XORed with a round constant, Rcon[j].
The round constant is a word in which the three rightmost bytes are always 0.Thus, theeffect of
an XOR of a word with Rcon is to only perform an XOR on the leftmost byte of the word. The round
constant is different for each round and is defined as Rcon[j] = (RC[j], 0, 0, 0),
with RC[1] = 1, RC[j] = 2 # RC[j-1] and with multiplication defined over the field GF(28). Thevalues of
RC[j] in hexadecimal are
An AES Example
For this example, the plaintext is a hexadecimal palindrome. The plaintext,key, and resulting
ciphertext are
Results
Table 2.4 shows the expansion of the 16-byte key into 10 round keys. The process is formedword by
word, with each four-byte word occupying one column of the word round-key matrix.
The left-hand column shows the four round-key words generated for each round. The right-hand
column shows the steps used to generate the auxiliary word used in key expansion. The key itself serving
as the round key for round 0.
Next, Table 2.5 shows the progression of State through the AES encryption process. The first
column shows the value of State at the start of a round. For the first row, State is just the matrix
arrangement of the plaintext. The second, third, and fourth columns show the value ofState for that round
after the SubBytes, ShiftRows,andMixColumns transformations, respectively. The fifth column shows the
roundkey.
Table 2.5 progression of State through the AES encryption process
1. Plaintext: This is the readable message or data that is fed into the algorithm as input.
2. Encryption algorithm: The encryption algorithm performs various transformations on the
plaintext.
3. Public and private keys: This is a pair of keys that have been selected so that if one is used for
encryption, the other is used for decryption. The exact transformations performed by the algorithm
depend on the public or private key that is provided as input.
4. Ciphertext: This is the scrambled message produced as output. It depends on the plaintextand
the key. For a given message, two different keys will produce two different cipher texts.
5. Decryption algorithm: This algorithm accepts the ciphertext and the matching key and
produces the original plaintext.
Encryption:
1. Each user generates a pair of keys to be used for encryption and decryptionof
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.
3. If A wishes to send a confidential message to B, A encrypts the message usingB"s
public key.
4. When B receives the message, it decrypts using its private key.
With this approach(Fig), all participants have access to public keys and private keys are generatedlocally
by each participant and therefore, need not be distributed.
Let the plaintext be X=[X1, X2. X3, . .,X ] where m is the number of letters in some finite
alphabets. Suppose A wishes to send a message to B.
B generates a pair of keys: a public key KUb and a private key KRb KRb is known only toB,
whereas KUb is publicly available and therefore accessible by A.
With the message X and encryption key KUb as input, A forms the cipher text Y=[Y1, Y2, Y3›
. Y n]
i.e., Y=EKUb(X)
The receiver can decrypt it using the private key KRb i.e., X=D KRb(Y)
The other approach (using sender―s private key for encryption and sender―s public key for
decryption) will provide authentication which is illustrated in the following diagram.
The encrypted message serves as a digital signature. It is important to emphasize that theencryption
process just described does not provide confidentiality.
The message is intended for destination B. B generates a related pair of keys: a publickey,
PUT, and a private key, PRb PRtis known only to B, whereas PL/his publicly available andtherefore
accessible by A. With the message and the encryption key PL/,as input, A forms the ciphertext Y =[Y
1. Yo. . ,YN]
Figure.PubIic-Key Cryptosystem: Secrecy
The intended receiver, in possession of the matching private key, is able to invertthe transformation:
X—— D (PRd›
An adversary, observing Y and having access to PUT, but not having access to PRbor X, must
attempt to recover X and/or PRb It is assumed that the adversary does have knowledge of the
encryption (E) and decryption (D) algorithms.
If the adversary is interested only in this particular message, then the focus of effort is to
recover A by generating a plaintext estimate X *. Often, however, the adversary is interested in being
able to read future messages as well, in which case an attempt is made to recover PRtby generating an
estimate PRb.
Y = E(PRa1)
X = D(PUa1 Y)
In this case, A prepares a message to B and encrypts it using A‘s private key before
transmitting it. B can decrypt the message using A‘s public key. Because the message was encrypted
using A‘s private key, only A could have prepared the message.
It is, however, possible to provide both the authentication function and confidentiality by a
double use of the public-key scheme (Figure 2.29):
Initially, the message is encrypted using the sender―s private key. This provides the digital
signature. Next, we encrypt again, using the receiver―s public key. The final ciphertext can be
decrypted only by the intended receiver, who alone has the matching private key. Thus confidentiality
is provided.
1. Encryption /decryption: The sender encrypts a message with the recipient‘s public key.
2. Digital signature: The sender ―signs" a message with its private key. Signing is achieved by a
cryptographic algorithm applied to the message or to a small block of data that is a function of
the message.
3. Key exchange: Two sides cooperate to exchange a session key. Several different
approaches are possible, involving the private key(s) of one or both parties.
Requirements for public key cryptography
Public-Key Cryptanalysis
Attack Type 1 :
The public-key encryption scheme is vulnerable to a brute-force attack; therefore use large
key.The tradeoff is that makes use of some sort of invertible mathematical function.
Therefore choose key size such that the brute force attack is not possible, at the sametime
should not be too slow for general use.
Attack type 2:
Attack is of other types (i.e.) given the algorithm and the public key deduce private key. This
method has not been successful till date.
Attack Type 3:
A probable-message attack. When a confidential message is to be transmitted using DES,the
56
attacker will find all 2 possible keys using the public key and discover the encrypted
key by matching the generated cipher text and the actual cipher. This attack can be avoided by
appending some random bits to the message.
RSA ALGORITHM
It was developed by Rivest, Shamir and Adleman. This algorithm makes use of an expression
with exponentials. Plaintext is encrypted in blocks, with each block having a binary value less than
some number n.The RSA scheme is a cipher in which the plaintext and cipher text are integers
between 0 and n - 1 for some n. A typical size for n is 1024 bits, or 309 decimal digits. That is, n is
less than 2 1024
That is, the block size must be less than or equal to log 2 (n); in practice, the block size
is k-bits, where 2k< n < 2 k*1. Encryption and decryption are of the following form, for some
plaintext block M and ciphertext block C:
c = Me mod n
M = Cd mod n
= (Me)d mod n
= Me*mod n
Both the sender and receiver know the value of n. the sender knows the value of e andonly
the receiver knows the value of d. thus, this is a public key encryption algorithm with a public key of
KU = {e, n) and a private key of KR = {d, n}. For this algorithm to be satisfactory for public key
encryption, the following requirements must be met:
ed
1. It is possible to find values of e, d, n such that M = M mod n for all M < n.
e d
2. It is relatively easy to calculate M and C for all values of M < n.
3. It is infeasible to determine d given e and n.
Let us focus on the first requirement. We need to find the relationship of the form:
Med = M mod n
Given two prime numbers p and q and two integers, n and m, such that n=pq and 0<m<n, andarbitrary
integer k, the following relationship holds
where 6(n) — Euler totient function, which is the number of positive integers less than n
and relatively prime to n. we can achieve the desired relationship, if
This is equivalent to saying:
ed = k6(n)+1 ed - 1 mod 6(n)
d = e1 - mod 6(n)
That is, e and d are multiplicative inverses mod 6(n). According to the rule of modular arithmetic,this
is true only if d (and therefore e) is relatively prime to 6(n). Equivalently, gcd(6(n), d) = 1.
We are now ready to state the RSA scheme. The ingredients are the following:
n —— pq (public, calculated)
The steps involved in RSA algorithm for generating the key are
The resulting keys are public key PU —— {7, 187} and private key PR —— {23, 187}.
The example shows the use of these keys for a plaintext input of M—— 88.
For encryption,we need to calculate C = 887 mod 187.
11 mod 187 = 11
8
11 mod 187 = 214,358,881 mod 187 = 33
23
11 mod 187 = (11 • 121 • 55 • 33 33) mod 187 = 79,720,245 mod 187 = 88
Security of RSA:
Use large key space (i.e) large number of bits in e and d the better secured but problems are,
Attack:
If the system does lastly the modular multiplication in majority of cases but takes longertime in
few cases. The average is also longer.
1. Constant exponentiation time: All exponentiations take the same amount of time before
returning a result. This is a simple fix but does degrade performance.
2. Random delay: Better performance could be achieved by adding a random delay to the
exponentiation algorithm to confuse the timing attack.
3. Blinding: Multiply the cipher text by a random number before performing exponentiation. This
process prevents the attacker from knowing what cipher text bits are being processedinside the
computer and therefore prevents the bit-by-bit analysis essential to the timing attack.
KEY MANAGEMENT
There are two uses of public key cryptography regarding the issues of key distribution. They are
Several techniques have been proposed for the distribution of public keys. Virtually all
these proposals can be grouped into the following general schemes:
a) Public announcement
b) Publicly available directory
c) Public-key authority
d) Public-key certificates
In public-key encryption the public key is public. Thus, if there is some broadly accepted
public-key algorithm, such as RSA, any participant can send his or her public key to any other
participant or broadcast the key to the community at large as shown in Figure 2.32.
Anyone can forge such a public announcement. That is, some user could pretend tobe user
A and send a public key to another participant or broadcast such a public key.
Until such time as user A discovers the forgery and alerts other participants, the forgeris able to
read all encrypted messages intended for A and can use the forged keys for authentication.
1. The authority maintains a directory with a (name, public key} entry for each participant.
2. Each participant registers a public key with the directory authority. Registration wouldhave to
be in person or by some form of secure authenticated communication.
3. A participant may replace the existing key with a new one at any time, due to either the key
has been used for a large amount of data, or the corresponding private key has been
compromised in some way.
4. Participants could also access the directory electronically. For this purpose, secure,
authenticated communication from the authority to the participant is mandatory
Vulnerabilities:
If an adversary succeeds in obtaining or computing the private key of the directory authority, the
adversary could authoritatively pass out counterfeit public keys and impersonate any
participant and eavesdrop on messages sent to any participant.
Stronger security for public-key distribution can be achieved by providing tighter control over
the distribution of public keys from the directory. A typical scenario is illustrated in Figure 2.34.
As before, the scenario assumes that a central authority maintains a dynamic directory of
public keys of all participants. In addition, each participant reliably knows a public key for the
authority, with only the authority knowing the corresponding private key. The following steps
(matched by number to Figure 2.34) occur:
Figure .PubIic-Key Distribution Scenario
1. A sends a time stamped message to the public-key authority containing a request for thecurrent
public key of B.
2. The authority responds with a message that is encrypted using the authority‘s private key,PRauthT
hus, A is able to decrypt the message using the authority's public key. Therefore, A is assured that the
message originated with the authority. The message includes the following:
• B‘s public key, PL/,which A can use to encrypt messages destined for B
• The original request, to enable A to match this response with the corresponding earlier
request and to verify that the original request was not altered before reception by the authority
• The original timestamp, so A can determine that this is not an old message from the
authority containing a key other than B‘s current public key
3. A stores B's public key and also uses it to encrypt a message to B containing an identifier of A
(IDA) and a nonce (/\/1), which is used to identify this transaction uniquely.
4,5 B retrieves A‘s public key from the authority in the same manner as A retrieved B‘spublic key.
6.B sends a message to A encrypted with K aand containing A‘s nonce (/V1) as well as anew
nonce generated by B (/V2) Because only B could have decrypted message (3), the presence of /V1 in
message (6) assures A that the correspondent is B.
7. A returns 2. encrypted using B‘s public key, to assure B that its correspondent is A.
Thus, a total of seven messages are required. However, the initial four messages need be used
only infrequently because both A and B can save the other‘s public key for future use, a technique
known as caching.
Disadvantages:
The scenario of Figure is attractive, yet it has some drawbacks. The public-key authority
could be somewhat of a bottleneck in the system, for a user must appeal to the authority for a public
key for every other user that it wishes to contact. As before, the directory of names and public keys
maintained by the authority is vulnerable to tampering.
An alternative approach is to use certificates that can be used by participants to exchange keys
without contacting a public-key authority.
A certificate consists of a public key plus an identifier of the key owner, with the whole block
signed by a trusted third party.
A user can present his or her public key to the authority in a secure manner, and obtain a
certificate. The user can then publish the certificate. Anyone needed this user's public key can obtain
the certificate and verify that it is valid by way of the attached trusted signature.
1. Any participant can read a certificate to determine the name and public key of the
certificate‘s owner.
2. Any participant can verify that the certificate originated from the certificate authority and is not
counterfeit.
3. Only the certificate authority can create and update certificates.
These requirements are satisfied by the original proposal in. Denning added the following
additional requirement:
a) Simple
b) Secret key distribution with confidentiality and authentication
c) Hybrid
d) Diffie Hell man key exchange
Advantages:
• No keys exist before the start of the communication no key exist after the completion of
communication
• Secure from eaves dropping
Disadvantages:
• Replay attack
• Meet in the middle attack
• A generates a public/private key pair {PUa, PRaj and transmits a message intended forB
consisting of PL/aand an identifier of A, IDA.
• D intercepts the message, creates its own public/private key pair \PUd, PRO and
transmits PUs 0 0 IDA to B.
• B generates a secret key, Ks, and transmits E(PL/s, Ks).
• D intercepts the message and learns Ks by computing D(PRd, E(PL/d, Ks)).
• D transmits E(PL/a, Ks) to A.
1. A uses B‘s public key to encrypt a message to B containing an identifier of A (ID A) anda
nonce (N1),which is used to identify this transaction uniquely.
2. B sends a message to A encrypted with KUa and containing A‘s decrypted message
(1) ,the presence of N1 in message (2) assures A that correspondent is B.
3. A returns Ne. encrypted using B‘s public key, to assurer B that its correspondent is A.
Advantages:
Scheme ensures both confidentiality and authentication in the exchange of a secret key.
(c) A Hybrid Scheme
Public-key scheme isused to distribute the master keys. The following rationale is providedfor
using thisthree-level approach:
1. Performance:
The public key encryption is used occasionally to update the master key between usesand
KDC When the distribution of session keys is done by public key encryption the performance
degrades because of high computation needed by P.K.E.
The addition of a public-key layer provides a secure, efficient means of distributing master keys.
The purpose of the algorithm is to enable two users to exchange a key securely that can then be
used for subsequent encryption of messages. The Diffie-Hellman algorithm depends for its
effectiveness on the difficulty of computing discrete logarithms.
First, we define a primitive root of a prime number p as one whose power generate all the
integers from 1 to (p-1) i.e., if ‗a‘ is a primitive root of a prime number p, then the numbers
2 p-1
a a mod p,
a mod p, ... mod p
For any integer ‗b‘ and a primitive root ‗a‘ of a prime number ‗p‘, we can find a uniqueexponent ‗i‘ such that
The Alqorithm
Figure 2.37 summarizes the Diffie-Hellman key exchange algorithm.There are publicly known
numbers: a prime number ‗q‘ and an integer a that is primitive root of q. suppose users A and B wish
to exchange a key. User A selects a random integer XA‹ q and computes YA = a XA mod q.
The protocol depicted in figure is insecure against a man-in-the-middle attack. Suppose Aliceand Bob
wish to exchange keys, and Darth is the adversary. The attack proceeds as follows:
1. Darth prepares for the attack by generating two random private keys XD1 and XD2 and then
computing the corresponding public keys YD1 and
Yo2-2. Alice transmits YA to Bob.
X
Darth intercepts YA and transmits YD1 to Bob. Darth aXlso calculates = (YA) D mod q.
Key exchange is based on the use of the prime number q —— 353 and a primitive root of 353, inthis
case a = 3. A and B select secret keys EA—— 97 and XB—— 233, respectively.
Each computes its public key:
7
A computes YA 3 mod 353 = 40.
233
B computes YB—— 3 mod 353 = 248.
After they exchange public keys, each can compute the common secret key:Acomputes K
—— (Yy) mod 353 = 248 mod 353 = 160.
XB 2 3
B computes K —— (Y A) mod 353 = 40 * mod 353 = 160.