UNIT II Notes
UNIT II Notes
Groups, rings, and fields are the fundamental elements of a branch of mathematics
known as abstract algebra, or modern algebra.
Groups
Rings
A ring R, sometimes denoted by {R, +, X}, is a set of elements with two binary
operations, called addition and multiplication, such that for all a, b, c ,in R the following
axioms are obeyed
Next, we define an integral domain, which is a commutative ring that obeys the following
axioms
Fields
A field F, sometimes denoted by {F, +, X}, is a set of elements with two binary
operations, called addition and subtraction, such that for all a, b, c , in F the following
axioms are obeyed
A kind of integer arithmetic that reduces all numbers to one of a fixed set [0,….,n-1] for
some number n. Any integer outside this range is reduced to one in this range by taking the
remainder after division by n.
Define the set Zn as the set of nonnegative integers less than n: Zn = {0, 1,................ (n - 1)}.
This is referred to as the set of residues, or residue classes (mod n).
To be more precise, each integer in Zn represents a residue class.
we can label the residue classes, (mod n) as [0], [1], [2], ........ [n - 1], where
[r] = {a: a is an integer, a ≡ r (mod n)}
Residue Classes for mod 4
Z4={0,1,2,3}
Residual Class [0] Residual Class [1] Residual Class [2]
a mod n=r mod n
?
0 mod 4=0 1 mod 4=1 2 mod 4=2
4 mod 4=0 5 mod 4=1 6 mod 4=2
8 mod 4=0 9mod 4=1 10 mod 4=2
12 mod 4=0 13 mod 4=1 14 mod 4=2
2.3 EUCLID’ S ALGORITHM
One of the basic techniques of number theory is the Euclidean algorithm, which is a
simple procedure for determining the greatest common divisor of two positive integers. First,
we need a simple definition: Two integers are relatively prime if their only common positive
integer factor is 1.
Recall that nonzero b is defined to be a divisor ofa if a =mb for some m, where a,b,
and m are integers. We will use the notation gcd(a , b) to mean the greatest common divisor
of a and b .The greatest common divisor of a and b is the largest integer that divides both
a and b
Algorithm
1. c is a divisor of a and
of b.
a = q1b + r1 0 ≤ r1 ˂ b
b = q2 r1 +r2 0 ≤ r2 ˂ r1
a dividend
b divisor
q quotient
r remainder
For e.g 7/4 can be written as 7=1 x 4+3
7 dividend
4 divisor
1 quotient
3 remainder
Example1:gcd(a,b)=gcd(24,12)
We have a=q1b+r1
24=2x12+0
If r1=0 return b as result
Hence gcd(24,12) is 12
= gcd (11, 0)
Example 3:
= gcd (10, 0)
Example 4:
Step 1: gcd(a,b)=gcd(1970,1066)
We have a=q1b+r1
1970=1x1066+ 904
Here r1≠0
We have b=q2r1+r2
1066=1x904+162
Here r2 ≠0
We have r1=q3r2+r3904=5x162+94
Here r3 ≠0
Repeat the steps until remainder is 0.if remainder is 0 return previous remainder as
result.
=gcd (10, 6)
=gcd (6, 4)
=gcd (4, 2)
=gcd (2, 0)
Another Method
Properties of Congruences
Congruences have the following properties:
Simplified Data Encryption Standard (S-DES)
The overall structure of the simplified DES. 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.
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 of the input; the
second output bit is bit 5 of the input, and so on. For example, the key (1010000010) is
permuted to (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
we apply P8, which picks out and permutes 8 of the 10 bits according to the following rule:
The result is subkey 1 (K1). In our example, this yields (10100100). We 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).
2 S-DES encryption
The input to the algorithm is an 8-bit block of plaintext, which we first permute using the IP
function:
This retains all 8 bits of the plaintext but mixes them up.
Consider the plaintext to be 11110011.
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
as follows. 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
We now describe the mapping F. The input is a 4-bit number (n1 n2 n3 n4). The first operation
is an expansion/permutation operation:
e.g., R= 1101
The 8-bit subkey K1 = (k11, k12 , k13 , k14 , k15, k16 , k17 , k18) is added to this value using
exclusive-OR:
The first 4 bits (first row of the preceding matrix) are fed into the S-box S0 to produce
a 2- bit output, and the remaining 4 bits (second row) are fed into S1 to produce another
2-bit output.
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. The entry in that row and column, in base 2, is the 2-bit output. For example, if (p0,0 p0,3)
= ) (00) and ( p0,1 p0,2) = (10), then the output is from row 0, column 2 of S0, which is 3, or
(11) in ) binary. Similarly, (p1,0 p1,3) and ( p1,1 p1,2) are used to index into a row and column
of S1 to produce an additional 2 bits. Next, the 4 bits produced by S0 and S1 undergo a further
permutation as follows:
To see that these two permutation functions are indeed the inverse of each other, consider the
following 64-bit input M:
where Mi is a binary digit. Then the permutation X = IP(M) is as follows:
If we then take the inverse permutation Y = IP-1(X) = IP-1(IP(M)), it can be seen that
the original ordering of the bits is restored.
Details of Single Round
Figure 2 shows the internal structure of a single round. Again, begin by focusing on the left-
hand side of the diagram. The left and right halves of each 64-bit intermediate value are treated
as separate 32-bit quantities, labeled L (left) and R (right). As in any classic Feistel cipher, the
overall processing at each round can be summarized in the following formulas:
Figure 2. Single Round of DES Algorithm
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 (Table c). 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 permuted as defined by Table d.
The role of the S-boxes in the function F is illustrated in Figure 3.
Figure 3: Calculation of F(R, K)
The substitution consists of a set of eight S-boxes, each of which accepts 6 bits as input and
produces 4 bits as output. These transformations are defined in Table 3.3, which is interpreted
as follows: 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. 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.
Table 3.3. Definition of DES S-Boxes
Each row of an S-box defines a general reversible substitution. Figure 3.1 may be useful in
understanding the mapping. The figure shows the substitution for row 0 of box S1.The
operation of the S-boxes is worth further comment. Ignore for the moment the contribution of
the key (Ki). If you examine the expansion table, you see that the 32 bits of input are split into
groups of 4 bits, and then become groups of 6 bits by taking the outer bits from the two adjacent
groups. For example, if part of the input word is
... efgh ijkl mnop ...
this becomes
... defghi hijklm lmnopq ...
The outer two bits of each group select one of four possible substitutions (one row of an S-
box). Then a 4-bit output value is substituted for the particular 4-bit input (the middle four input
bits). The 32-bit output from the eight S-boxes is then permuted, so that on the next round the
output from each S-box immediately affects as many others as possible.
Key Generation
DES Decryption
As with any Feistel cipher, decryption uses the same algorithm as encryption, except that the
application of the subkeys is reversed.
Block cipher algorithm is a basic building block for providing data security. To apply a block
cipher in a variety of applications, four "modes of operation" have been defined. In essence, a
mode of operation is a technique for enhancing the effect of a cryptographic algorithm or
adapting the algorithm for an application, such as applying a block cipher to a sequence of data
blocks or a data stream. These modes are intended for use with any symmetric block cipher,
including triple DES and AES. For different applications and uses, there are several modes of
operations for a block cipher.
1. Electronic Code Book
2. Cipher Block Chaining Mode
3. Cipher Feedback Mode
4. Output Feedback Mode
5. Counter Mode
To overcome the security deficiencies of ECB, we would like a technique in which the same
plaintext block, if repeated, produces different ciphertext blocks. A simple way to satisfy this
requirement is the cipher block chaining (CBC) mode. In this scheme, the input to the
encryption algorithm is the XOR of the current plaintext block and the preceding ciphertext
block; the same key is used for each block. In effect, we have chained together the processing
of the sequence of plaintext blocks.
To produce the first block of ciphertext, an initialization vector (IV) is XORed with the first
block of plaintext. On decryption, the IV is XORed with the output of the decryption algorithm
to recover the first block of plaintext. The IV is a data block that is that same size as the cipher
block. The IV must be known to both the sender and receiver but be unpredictable by a third
party. For maximum security, the IV should be protected against unauthorized changes. This
could be done by sending the IV using ECB encryption. In conclusion, because of the chaining
mechanism of CBC, it is an appropriate mode for encrypting messages of length greater than
b bits. In addition to its use to achieve confidentiality, the CBC mode can be used for
authentication.
Cipher Feedback Mode
The DES scheme is essentially a block cipher technique that uses b-bit blocks. However, it is
possible to convert DES into a stream cipher, using either the cipher feedback (CFB) or the
output feedback mode. Figure depicts the CFB scheme. In the figure, it is assumed that the unit
of transmission is s bits; a common value is s = 8. As with CBC, the units of plaintext are
chained together, so that the ciphertext of any plaintext unit is a function of all the preceding
plaintext. In this case, rather than units of b bits, the plaintext is divided into segments of s bits.
First, consider encryption. The input to the encryption function is a b-bit shift register that is
initially set to some initialization vector (IV). The leftmost (most significant) s bits of the output
of the encryption function are XORed with the first segment of plaintext P1 to produce the first
unit of ciphertext C1, which is then transmitted. In addition, the contents of the shift register
are shifted left by s bits and C1 is placed in the rightmost (least significant) s bits of the shift
register. This process continues until all plaintext units have been encrypted. For decryption,
the same scheme is used, except that the received ciphertext unit is XORed with the output of
the encryption function to produce the plaintext unit.
The output feedback (OFB) mode is similar in structure to that of CFB, as illustrated in Figure.
As can be seen, it is the output of the encryption function that is fed back to the shift register
in OFB, whereas in CFB the ciphertext unit is fed back to the shift register.
One advantage of the OFB method is that bit errors in transmission do not propagate. For
example, if a bit error occurs in C1 only the recovered value of is P1 affected; subsequent
plaintext units are not corrupted.
Counter Mode
Figure depicts the CTR mode. A counter, equal to the plaintext block size is used. The only
requirement stated is that the counter value must be different for each plaintext block that is
encrypted. Typically, the counter is initialized to some value and then incremented by 1 for
each subsequent block (modulo 2b where b is the block size). For encryption, the counter is
encrypted and then XORed with the plaintext block to produce the ciphertext block; there is no
chaining. For decryption, the same sequence of counter values is used, with each encrypted
counter XORed with a ciphertext block to recover the corresponding plaintext block.
RC4 (Ron’s Code)
An encryption technique and it uses symmetric key encryption algorithm and it was invented
by Ron Rivest. RC stands for Ron’s Code .RC4 is a stream cipher (i.e we generate streams of
byte) and variable length key algorithm. This algorithm encrypts one byte at a time (or larger
units on a time).
A key input is pseudorandom bit generator, that produces a stream of 8-bit number that is
unpredictable without knowledge of input key, The output of the generator is called key-
stream, is combined one byte at a time with the plaintext stream cipher using X-OR operation.
Block diagram
Key-GenerationAlgorithm –
A variable-length key from 1 to 256 byte is used to initialize a 256-byte state vector S, with
elements S [0] to S[255]. For encryption and decryption, a byte k is generated from S by
selecting one of the 255 entries in a systematic fashion,
Key-Scheduling Algorithm:
1.Initialization: The entries of S are set equal to the values from 0 to 255 in ascending order.
A temporary vector T, is created.
If the length of the key k is 256 bytes, then k is assigned to T. Otherwise, for a key with
length(k-len) bytes, the first k-len elements of T as copied from K and then K is repeated as
many times as necessary to fill T. The idea is illustrated as follow:
2. Key scheduling algorithm (KSA)
we use T to produce the initial permutation of S. Starting with S[0] to S[255], and for each S[i]
algorithm swap it with another byte in S according to a scheme dictated by T[i], but S will still
contain values from 0 to 255 :
• In Symmetric key encryption, the two parties to an exchange must share the same key,
and that key must be protected from access by others. 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:
• 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 are 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 numbers 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 centre is based on the use of a hierarchy of keys. At a
minimum, two levels of keys are used.
• Communication between end systems is encrypted using a temporary key, often
referred to as a Session key.
• Typically, the session key is used for the duration of a logical connection and then
discarded
• Master key is shared by the key distribution centre and an end system or user and used
to encrypt the session key.
Key Distribution Scenario
Let us assume that user A wishes to establish a logical connection with B and requires a one-
time session key to protect the data transmitted over the connection. A has a master key, Ka,
known only to itself and the KDC; similarly, B shares the master key Kb with the KDC (Figure
2.36). The following steps occur:
• The distribution of session keys delays the start of any exchange and places a burden
on network capacity. A security manager must try to balance these competing
considerations in determining the lifetime of a particular session key.
• For connection-oriented protocols, one obvious choice is to use the same session key
for the length of time that the connection is open, using a new session key for each new
session.
• If a logical connection has a very long lifetime, then it would be prudent to change the
session key periodically, perhaps every time the PDU (protocol data unit) sequence
number cycles.
• For a connectionless protocol, such as a transaction-oriented protocol, there is no
explicit connection initiation or termination.
• Thus, it is not obvious how often one needs to change the session key. The most secure
approach is to use a new session key for each exchange.
• A better strategy is to use a given session key for a certain fixed period only or for a
certain number of transactions.