Cis Unit2 Notes
Cis Unit2 Notes
Cis Unit2 Notes
Symmetric key Ciphers: Block Cipher principles, DES, AES, Block cipher operations,
Asymmetric key Ciphers: Principles of public key cryptosystems, RSA algorithm, Diffie-Hellman Key
Exchange.
1. Plain Text: This is the original message or data which is fed into the algorithm as input.
3. Secret Key: The key is another input to the algorithm. The substitutions and
transformations performed by algorithm depend on the key.
4. Cipher Text: This is the scrambled (unreadable) message which is output of the
encryption algorithm. This cipher text is dependent on plaintext and secret key. For a given
plaintext, two different keys produce two different cipher texts.
5. Decryption Algorithm: This is the reverse of encryption algorithm. It takes the cipher
text and secret key as inputs and outputs the plain text.
The important point is that the security of conventional encryption depends on the secrecy
of the key, not the secrecy of the algorithm i.e. it is not necessary to keep the algorithm
secret, but only the key is to be kept secret. This feature that algorithm need not be kept
secret made it feasible for wide spread use and enabled manufacturers develop low cost
chip implementation of data encryption algorithms. With the use of conventional algorithm,
as follows: use the cipher text as input to the algorithm, but use the subkey ki in reverse
order. i.e., kn in the first round, kn-1 in second round and so on. For clarity, we use the
notation LEi and REi for data traveling through the decryption algorithm. The diagram
below indicates that, at each round, the intermediate value of the decryption process is
same (equal) to the corresponding value of the encryption process with two halves of
swapped, so that the cipher text is RE16 || LE16. The output of that round is the cipher
text. Now take the cipher text and use it as input to the same algorithm. The input to the
first round is RE16 || LE16, which is equal to the 32-bit swap of the output of the
sixteenth round of the encryption process. Now we will see how the output of the first
round of the decryption process is equal to a 32-bit swap of the input to the sixteenth
LE16 = RE15
= LE15
Therefore, LD1 = RE15 RD1 = LE15 In general, for the ith iteration of the encryption
Finally, the output of the last round of the decryption process is RE 0 || LE0. A 32-bit swap
DEFINITIONS
Public Key encryption: Uses different keys for encryption & decryption
The main standard for encrypting data was a symmetric algorithm known as the
Data Encryption Standard (DES). However, this has now been replaced by a new
standard known as the Advanced Encryption Standard (AES) which we will look at later.
DES is a 64 bit block cipher which means that it encrypts data 64 bits at a time. This is
contrasted to a stream cipher in which only one bit at a time (or sometimes small
groups of bits such as a byte) is encrypted. DES was the result of a research project set
up by International Business Machines (IBM) corporation in the late 1960’s which
resulted in a cipher known as LUCIFER. In the early 1970’s it was decided to
commercialise LUCIFER and a number of significant changes were introduced. IBM was
not the only one involved in these changes as they sought technical advice from the
National Security Agency (NSA) (other outside consultants were involved but it is likely
that the NSA were the major contributors from a technical point of view). The altered
version of LUCIFER was put forward as a proposal for the new national encryption
standard requested by the National Bureau of Standards (NBS)3 . It was finally adopted
in 1977 as the Data Encryption Standard - DES (FIPS PUB 46). Some of the changes
made to LUCIFER have been the subject of much controversy even to the present day.
The most notable of these was the key size. LUCIFER used a key size of 128 bits however
this was reduced to 56 bits for DES. Even though DES actually accepts a 64 bit key as
input, the remaining eight bits are used for parity checking and have no effect on DES’s
security. Outsiders were convinced that the 56 bit key was an easy target for a brute
force attack4 due to its extremely small size. The need for the parity checking scheme
was also questioned without satisfying answers. Another controversial issue was that
the S-boxes used were designed under classified conditions and no reasons for their
particular design were ever given. This led people to assume that the NSA had
introduced a “trapdoor” through which they could decrypt any data encrypted by DES
even without knowledge of the key. One startling discovery was that the S-boxes
appeared to be secure against an attack known as Differential Cryptanalysis which was
only publicly discovered by Biham and Shamir in 1990. This suggests that the NSA were
aware of this attack in 1977; 13 years earlier! In
fact the DES designers claimed that the reason they never made the design
specifications for the S-boxes available was that they knew about a number of attacks
that weren’t public knowledge at the time and they didn’t want them leaking - this is
quite a plausible claim as differential cryptanalysis has shown. However, despite all this
controversy, in 1994 NIST reaffirmed DES for government use for a further five years
for use in areas other than “classified”. DES of course isn’t the only symmetric cipher.
There are many others, each with varying levels of complexity. Such ciphers include:
IDEA, RC4, RC5, RC6 and the new Advanced Encryption Standard (AES). AES is an
important algorithm and was originally meant to replace DES (and its more secure
variant triple DES) as the standard algorithm for non-classified material. However as of
2003, AES with key sizes of 192 and 256 bits has been found to be secure enough to
protect information up to top secret. Since its creation, AES had underdone intense
scrutiny as one would expect for an algorithm that is to be used as the standard. To date
it has withstood all attacks but the search is still on and it remains to be seen whether or
not this will last. We will look at AES later in the course.
DES (and most of the other major symmetric ciphers) is based on a cipher known as the Feistel
block cipher. It consists of a number of rounds where each round contains bit-shuffling, non-
linear substitutions (S-boxes) and exclusive OR operations. As with most encryption schemes,
DES expects two inputs - the plaintext to be encrypted and the secret key. The manner in which
the plaintext is accepted, and the key arrangement used for encryption and decryption, both
determine the type of cipher it is. DES is therefore a symmetric, 64 bit block cipher as it uses the
same key for both encryption and decryption and only operates on 64 bit blocks of data at a
time5 (be they plaintext or ciphertext). The key size used is 56 bits, however a 64 bit (or eight-
byte) key is actually input. The least significant bit of each byte is either used for parity (odd for
DES) or set arbitrarily and does not increase the security in any way. All blocks are numbered
from left to right which makes the eight bit of each byte the parity bit. Once a plain-text message
is received to be encrypted, it is arranged into 64 bit blocks required for input. If the number of
bits in the message is not evenly divisible by 64, then the last block will be padded. Multiple
permutations and substitutions are incorporated throughout in order to increase the difficulty
OVERALL STRUCTURE
Figure below shows the sequence of events that occur during an encryption operation.
DES performs an initial permutation on the entire 64 bit block of data. It is then split
into 2, 32 bit sub-blocks, Li and Ri which are then passed into what is known as a round
(see figure 2.3), of which there are 16 (the subscript i in Li and Ri indicates the current
round). Each of the rounds are identical and the effects of increasing their number is
twofold - the algorithms security is increased and its temporal efficiency decreased.
Clearly these are two conflicting outcomes and a compromise must be made. For DES
the number chosen was 16, probably to guarantee the elimination of any correlation
between the ciphertext and either the plaintext or key6 . At the end of the 16th round,
the 32 bit Li and Ri output quantities are swapped to create what is known as the pre-
output. This [R16, L16] concatenation is permuted using a function which is the exact
inverse of the initial permutation. The output of this final permutation is the 64 bit
ciphertext.
So in total the processing of the plaintext proceeds in three phases as can be seen from
1. Initial permutation (IP - defined in table 2.1) rearranging the bits to form the
“permuted input”.
output of the last iteration consists of 64 bits which is a function of the plaintext and
key. The left and right halves are swapped to produce the preoutput.
3. Finally, the preoutput is passed through a permutation (IP−1 - defined in table 2.1)
which is simply the inverse of the initial permutation (IP). The output of IP−1 is the 64-
bit ciphertext
As figure shows, the inputs to each round consist of the Li , Ri pair and a 48 bit subkey
which is a shifted and contracted version of the original 56 bit key. The use of the key
can be seen in the right hand portion of figure 2.2: • Initially the key is passed through a
permutation function (PC1 - defined in table 2.2) • For each of the 16 iterations, a
subkey (Ki) is produced by a combination of a left circular shift and a permutation (PC2
- defined in table 2.2) which is the same for each iteration. However, the resulting subkey is
The main operations on the data are encompassed into what is referred to as the cipher function
and is labeled F. This function accepts two different length inputs of 32 bits and 48 bits and
outputs a single 32 bit number. Both the data and key are operated on in parallel, however the
operations are quite different. The 56 bit key is split into two 28 bit halves Ci and Di (C and D
being chosen so as not to be confused with L and R). The value of the key used in any round is
simply a left cyclic shift and a permuted contraction of that used in the previous round.
Ci = Lcsi(Ci−1), Di = Lcsi(Di−1)
Ki = P C2(Ci , Di)
where Lcsi is the left cyclic shift for round i, Ci and Di are the outputs after the shifts, P C2(.) is a
function which permutes and compresses a 56 bit number into a 48 bit number and Ki is the
actual key used in round i. The number of shifts is either one or two and is determined by the
round number i. For i = {1, 2, 9, 16} the number of shifts is one and for every other round it is
two
S-B OX Details
This is a DES that was susceptible to attacks due to tremendous advances in computer hardware in cryptography.
Hence, it was a very complex or competent algorithm it would be feasible to reuse DES rather than writing an of
cryptography.
Required to this variation of DES were introduced known as multiple DES which was as follows as Shown:
1) Double DES
Mainly, Double DES is simple as it does that normal DES does. Double DES uses twp keys to say K1 and K2
in this algorithm. It first performs DES on the original plain text using K! to get the encrypted text in
cryptography. Here, it again performs DES on the encrypted text but this time with the other key K2 in this
algorithm.
Firstly, the final output is the encryption of encrypted text with the original plain text encrypted twice with
two different keys shown in the structure as given below
While the doubly encrypted ciphertext block is first decrypted using the key K2 to produce singly encrypted
ciphertext by plaintext or original text. Hence, this ciphertext block is then decrypted using the key K1 to
obtain the original plain text block in cryptography.
Mainly, the cryptanalysis for the basic version of DES requires a search of 256 thus the assumption
is Double DES require 2128 keys which is not true for the message.
Here, a Meet-in-the-middle attack is the drawback of double DES in this. Mainly, this attack involves
encryption from one end, decryption from the other and matching the results in the middle hence the
name in the message.
Therefore, the simplest form of multiple encryptions has two encryption stages and two keys in this. Here, given a
plaintext P and two encryption keys K1 and K2, ciphertext C is created as: C = E(K2, E(K1, P))
Then, Decryption requires that the keys be applied in reverse order as: P = D(K1, D(K2, C))
Now, For DES, this scheme involves a key length of 56 * 2 = 112 bits, resulting in a dramatic increase in
cryptographic strength in this. Further, but we need to examine the algorithm more closely for this.
2) Triple DES
Here, to improve the security of DES to a higher level triple DES was proposed in this. While this uses three stages
on DES for encryption and decryption in cryptography.
While in triple DES with two keys there are only two keys K1 used by the first and third stages and K2 used
in the second stage in this. Basically, first, the plain text is encrypted with key K1 then the output of step
one is decrypted with K2 and final the output second step is encrypted again with key K1 in cryptography.
It is also called encrypt decrypt encrypt (ECE) mode in cryptography. Hence, Triple DES with two keys is not
susceptible to the meet-in-the-middle attack in cryptography.
While the plain text block P is first encrypted with a key K1 then encrypts with a second key K2 and finally
with a third key K3 where K1, K2, and K3 are all different from each other in this algorithm. This is
Decryption is done in reverse order in this way. Therefore, this algorithm is mostly used in PGP and S/MIME
in cryptography.
Therefore, the DES cipher's key size of multiple of 56 bits of the message was generally enough when that
algorithm was designed but the availability of increasing computational power made brute force attacks
feasible in this algorithm. Thus, the Triple-DES provides a relatively simple method of increasing the key
size of DES to secure against such attacks like that, without the need to design a completely new block
cipher algorithm by this technique in cryptography.
ADVANCED ENCRYPTION ALGORITHM (AES)
AES is a block cipher with a block length of 128 bits.
AES allows for three different key lengths: 128, 192, or 256 bits. Most of our
discussion will assume that the key length is 128 bits.
Encryption consists of 10 rounds of processing for 128-bit keys, 12 rounds for
192-bit keys, and 14 rounds for 256-bit keys.
Except for the last round in each case, all other rounds are identical.
Each round of processing includes one single-byte based substitution step, a
row- wise permutation step, a column-wise mixing step, and the addition of the
round key. The order in which these four steps are executed is different for
encryption and decryption.
To appreciate the processing steps used in a single round, it is best to think of a
128-bit block as consisting of a 4 × 4 matrix of bytes, arranged as follows:
Therefore, the first four bytes of a 128-bit input block occupy the first column in
the 4 × 4 matrix of bytes. The next four bytes occupy the second column, and so
on.
The 4×4 matrix of bytes shown above is referred to as the state array in AES.
The algorithm begins with an Add round key stage followed by 9 rounds of four stages
and a tenth round of three stages.
This applies for both encryption and decryption with the exception that each stage of a
round the decryption algorithm is the inverse of its counterpart in the encryption
algorithm.
The four stages are as follows: 1. Substitute bytes 2. Shift rows 3. Mix Columns 4. Add
Round Key
Substitute Bytes
• This stage (known as SubBytes) is simply a table lookup using a 16 × 16 matrix of byte
values called an s-box.
• This matrix consists of all the possible combinations of an 8 bit sequence (28 = 16 × 16
= 256).
• However, the s-box is not just a random permutation of these values and there is a
well defined method for creating the s-box tables.
• The designers of Rijndael showed how this was done unlike the s-boxes in DES for
which no rationale was given.Our concern will be how state is effected in each round.
• For this particular round each byte is mapped into a new byte in the following way:
the leftmost nibble of the byte is used to specify a particular row of the s-box and the
rightmost nibble specifies a column.
• For example, the byte {95} (curly brackets represent hex values in FIPS PUB 197)
selects row 9 column 5 which turns out to contain the value {2A}.
• This is then used to update the state matrix.
2.) digital signatures – how to verify a message comes intact from the claimed sender
Public-key/two-key/asymmetric cryptography involves the use of two keys:
a public-key, which may be known by anybody, and can be used to encrypt
messages, and verify signatures
a private-key, known only to the recipient, used to decrypt messages, and sign
(create) signatures.
is asymmetric because those who encrypt messages or verify signatures cannot
decrypt messages or create signatures
Public-Key algorithms rely on one key for encryption and a different but related key
for decryption. These algorithms have the following important characteristics:
it is computationally infeasible to find decryption key knowing only algorithm &
encryption key
it is computationally easy to en/decrypt messages when the relevant
(en/decrypt) key is known
either of the two related keys can be used for encryption, with the other used for
decryption (for some algorithms like RSA)
The following figure illustrates public-key encryption process and shows that a public-key
encryption scheme has six ingredients: plaintext, encryption algorithm, public & private
keys, ciphertext & decryption algorithm.
The essential steps involved in a public-key encryption scheme are given below:
1.) Each user generates a pair of keys to be used for encryption and decryption.
2.) Each user places one of the two keys in a public register and the other key is kept
private.
3.) If B wants to send a confidential message to A, B encrypts the message using A’s
public key.
4.) When A receives the message, she decrypts it using her private key. Nobody else can
decrypt the message because that can only be done using A’s private key (Deducing a
private key should be infeasible).
5.) If a user wishes to change his keys –generate another pair of keys and publish the
public one: no interaction with other users is needed.
Notations used in Public-key cryptography:
The public key of user A will be denoted KUA.
The private key of user A will be denoted KRA.
Encryption method will be a function E.
Decryption method will be a function D.
If B wishes to send a plain message X to A, then he sends the cryptotext Y=E(KUA,X)
The intended receiver A will decrypt the message: D(KRA,Y)=X
The first attack on Public-key Cryptography is the attack on Authenticity. An attacker may
impersonate user B: he sends a message E(KUA,X) and claims in the message to be B –A
has no guarantee this is so. To overcome this, B will encrypt the message using his private
key: Y=E(KRB,X). Receiver decrypts using B’s public key KR B. This shows the authenticity of
the sender because (supposedly) he is the only one who knows the private key. The entire
encrypted message serves as a digital signature. This scheme is depicted in the following
figure:
But, a drawback still exists. Anybody can decrypt the message using B’s public key. So,
secrecy or confidentiality is being compromised. One can provide both authentication and
confidentiality using the public-key scheme twice:
B encrypts X with his private key: Y=E(KRB,X)
A will decrypt Z (and she is the only one capable of doing it): Y=D(KRA,Z)
A can now get the plaintext and ensure that it comes from B (he is the only one who
knows his private key): decrypt Y using B’s public key: X=E(KUB,Y).
2.) Digital signature: sender “signs” the message (or a representative part of the
message) using his private key
3.) Key exchange: two sides cooperate to exchange a secret key for later use in a secret-
key cryptosystem.
Requires the use of very large numbers, hence is slow compared to private key
schemes
Both the sender and receiver must know the values of n and e, and only the receiver
knows the value of d. Encryption and Decryption are done using the following
equations. To encrypt a message M the sender:
– obtains public key of recipient KU={e,n}
– computes: C=Me mod n, where 0≤M<n
To decrypt the ciphertext C the owner:
– uses their private key KR={d,n}
– computes: M=Cd mod n = (Me) d mod n = Med mod n
For this algorithm to be satisfactory, the following requirements are to be met.
a) Its possible to find values of e, d, n such that Med = M mod n for all M<n
b) It is relatively easy to calculate Me and C for all values of M < n.
c) It is impossible to determine d given e and n
The way RSA works is based on Number theory: Fermat’s little theorem: if p is
prime and a is positive integer not divisible by p, then ap-1 ≡ 1 mod p. Corollary: For
any positive integer a and prime p, ap ≡ a mod p.
Fermat’s theorem, as useful as will turn out to be does not provide us with
integers d,e we are looking for –Euler’s theorem (a refinement of Fermat’s) does. Euler’s
function associates to any positive integer n, a number φ(n): the number of positive
integers smaller than n and relatively prime to n. For example, φ(37) = 36 i.e. φ(p) = p-
1 for any prime p. For any two primes p,q, φ(pq)=(p-1)(q-1). Euler’s theorem: for any
relatively prime integers a,n we have aφ(n)≡1 mod n. Corollary: For any integers a,n
we have aφ(n)+1≡a mod n Corollary: Let p,q be two odd primes and n=pq. Then:
φ(n)=(p-1)(q-
1) For any integer m with 0<m<n, m(p-1)(q-1)+1 ≡ m mod n For any integers k,m with
0<m<n, mk(p-1)(q-1)+1 ≡ m mod n Euler’s theorem provides us the numbers d, e such
that Med=M mod n. We have to choose d,e such that ed=kφ(n)+1, or equivalently, d≡e-
1mod φ(n)
Security of RSA
There are three main approaches of attacking RSA algorithm.
Brute force key search (infeasible given size of numbers) As explained before, involves
trying all possible private keys. Best defence is using large keys.
Mathematical attacks (based on difficulty of computing ø(N), by factoring modulus N)
There are several approaches, all equivalent in effect to factoring the product of two
primes. Some of them are given as:
– find d directly
The possible defense would be using large keys and also choosing large numbers for p
and q, which should differ only by a few bits and are also on the order of magnitude
1075 to 10100. And gcd (p-1, q-1) should be small.
Let Alice pick a = 10. Alice calculates 1310 (mod 37) which is 4 and sends that to Bob. Let
Bob pick b = 7. Bob calculates 13 7 (mod 37) which is 32 and sends that to Alice. (Note: 6
and 7 are secret to Alice and Bob, respectively, but both 4 and 32 are known by all.)
10 (mod 37) which is 30, the secret key.
2) Let p = 47 and g = 5. Let Alice pick a = 18. Alice calculates 5 18 (mod 47) which is 2 and
sends that to Bob. Let Bob pick b = 22. Bob calculates 522 (mod 47) which is 28 and
sends that to Alice.
18 (mod 47) which is 24, the secret key.
3. Darth intercepts YA and transmits YD1 to Bob. Darth also calculates K2 = (YA)XD2mod q.
6. Darth intercepts XA and transmits YD2 to Alice. Darth calculates K1 = (YB)XD1 mod q.
3. Darth sends Bob E(K1, M) or E(K1, M'), where M' is any message. In the first
case, Darth simply wants to eavesdrop on the communication without altering
it. In the second case, Darth wants to modify the message going to Bob.
The key exchange protocol is vulnerable to such an attack because it does not
authenticate the participants. This vulnerability can be overcome with the use
of digital signatures and public-key certificates.