Chapter 2
Chapter 2
•Each block is of equal size and has fixed no of bits. The generated ciphertext
has blocks equal to the number of blocks in plaintext and also has the same
number of bits in each block as of plain text.
•Most modern block ciphers are designed to encrypt data in fixed-size blocks of
either 64 or 128 bits. Block cipher has a specific number of rounds and keys
for generating ciphertext.
•Block cipher uses the same key for encryption and decryption.
Block Ciphers
•Block cipher is an encryption method which
divides the plain text into blocks of fixed size.
Each block has an equal number of bits.
•Too much padding makes the system inefficient. Also, padding may render
the system insecure at times, if the padding is done with same bits always.
Block cipher principles
•The design of a block cipher involves several important principles to ensure
the security and efficiency of the algorithm. Some of these principles are:
•Key Size: The key size should be large enough to prevent brute-force attacks.
A larger key size means that there are more possible keys, making it harder
for an attacker to guess the correct one. A key size of 128 bits is considered to
be secure for most applications.
Block cipher principles
•Key Schedule: The key schedule should be designed carefully to ensure that the
keys used for encryption are independent and unpredictable.
•Block Size: The block size should be large enough to prevent attacks that
exploit statistical patterns in the plaintext. A block size of 128 bits is generally
considered to be secure for most applications.
•Avalanche Effect: The cipher should exhibit the avalanche effect, which means
that a small change in the plaintext or key should cause a significant change in
the ciphertext. This ensures that any change in the input results in a complete
change in the output.
•We need to generate public and private keys before running the functions to
generate ciphertext and plaintext.
Steps in RSA Algorithm
•Choose two large prime numbers (p and q)
•Calculate n = p*q and z = (p-1)(q-1)
•Choose a number e where 1 < e < z (Prime number)
•Calculate d such that e*d mod z = 1
•You can bundle private key pair as (n,d)
•You can bundle public key pair as (n,e)
•Once you generate the keys, you pass the parameters to the functions that
calculate your ciphertext and plaintext using the respective key.
If the plaintext is m, ciphertext = me mod n.
If the ciphertext is c, plaintext = cd mod n
cryptosystems
•Different keys are used for encryption and decryption. Each receiver possesses a unique
decryption key, generally referred his private key.
•This type of cryptosystem involves trusted third party which certifies that a particular
public key belongs to a specific person or entity only.
•Encryption algorithm is complex enough to prohibit attacker from deducing the plaintext
from the ciphertext.
•Though private and public keys are related mathematically, it is not be feasible to calculate
the private key from the public key. The best part of any public-key cryptosystem is in
designing a relationship between two keys.
Diffie-Hellman Algorithm
•Diffie-Hellman algorithm is one of the most important algorithms used for establishing a
shared secret. At the time of exchanging data over a public network, we can use the shared
secret for secret communication.
•We will take four variables, i.e., P (prime), G (the primitive root of P), and a and b (private
values).
•The variables P and G both are publicly available. The sender selects a private value, either
a or b, for generating a key to exchange publicly. The receiver receives the key, and that
generates a secret key, after which the sender and receiver both have the same secret key
to encrypt.
Algebraicall
y, 5th step
can be
shown as
follows: k =k
a b
It means
that both
the users
have the
symmetric
secret key
to encrypt.
Block Cipher
•Block cipher is an encryption method which divides the plain text into blocks
of fixed size. Each block has an equal number of bits. At a time, block cipher
operates only on one block of plain text and applies key on it to produce the
corresponding block of ciphertext. Typically a block size of 64 or 128 bits is
used.
•While decryption also only one block of ciphertext is operated to produce its
corresponding plain text. Data Encryption Standard (DES) is the best example
of it.
The strength of cipher
depends upon the key
length.
Block Cipher
•Block cipher has a specific number of rounds and keys for generating
ciphertext. For defining the complexity level of an algorithm few design
principles are to be considered.
•Number of Rounds –
The number of Rounds is regularly considered in design criteria, it just reflects
the number of rounds to be suitable for an algorithm to make it more complex,
in DES we have 16 rounds ensuring it to be more secure while in AES we have
10 rounds which makes it more secure.
Block Cipher
Design of function F –The core part of the Feistel Block cipher structure is the
Round Function. The complexity of cryptanalysis can be derived from the
Round function i.e. the increasing level of complexity for the round function
would be greatly contributing to an increase in complexity.
•To increase the complexity of the round function, the avalanche effect is also
included in the round function, as the change of a single bit in plain text would
produce a mischievous output due to the presence of avalanche effect.
•Blowfish is significantly faster than DES and available free for all uses.
However, it couldn't completely replace DES due to its small block size, which is
considered insecure.
•Blowfish features a 64-bit block size and takes a variable-length key, from 32
bits to 448 bits. Blowfish uses a single encryption key to both encrypt and
decrypt data.
RC5 Algorithm
•In the RC5 algorithm, the input plain text block size, number of rounds and
key can be of variable length.
•Once the values of this are decided, the values will remain the same for a
particular execution of the cryptographic algorithm.
•The size of plain text block can be of 32 bits, 64 bits or 128 bits. The length of
the key can be of 0 to 255 bytes. The output generated by RC5 is the ciphertext
which has the size the same as plain text size.
RC5 Algorithm
•In RC5, the plain text message is divided into two blocks A and B each of 32
bits. Then two subkeys are generated S[0] and S[1].
•These two subkeys are added into A and B respectively. This process produces
C and D respectively and marks the end of the one-time operation.
•Then the process of the round begins. In each round, the following operation
is performed.
Bitwise XOR.
Left circular shift.
addition to the next subkey, for both C and D.
Details of Round
•In this section, we will discuss the result for one round. The process for the
first round will be the same for other rounds.
Step 1: XOR C and D
This is the first step in every round where C and D are XOR to form E.
Step 2: Circular left shift E
The output generated in step 1 i.e. E is now circular left-shifted by D positions.
Step 3: Add E and next subkey
In this step, E is added to the next subkey to form the F.
Note: Step 4 to step 6 are similar to Step 1 to step 3 only difference is the input
used for the operations.
Details of Round
Step 4: XOR D and F
D and F are XORed to from G.
Step 5: circular left shift G
The output generated in step 4 i.e. G is now circular left-shifted by F position.
Step 6: Add G and next subkey
In this step, G is added to the next subkey to form the H.
Step 7: In these steps, the checking is done to ensure that all-round is done
properly. This is performed using the following steps.
Increment i by 1
check if i < r
if i is less than r then rename F as C and H as D. If i is greater than r then the
process will stop.
Standard (AES)
•It is found at least six time faster than triple DES.
•A replacement for DES was needed as its key size was too small. With increasing
computing power, it was considered vulnerable against exhaustive key search
attack. Triple DES was designed to overcome this drawback but it was found slow.
•Unlike DES, the number of rounds in AES is variable and depends on the
length of the key. AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit
keys and 14 rounds for 256-bit keys. Each of these rounds uses a different 128-
bit round key, which is calculated from the original AES key.
Next comes the permutation step. In this step, all rows except the
first are shifted by one, as shown above.
3. Mixing the columns
In the final step, the message is XORed with the respective round
key. When done repeatedly, these steps ensure that the final
ciphertext is secure.
The steps listed above constitute one round, so there are nine,
11, and 13 rounds left to go for 128-bit AES encryption, 192-
bit AES encryption, and 256-bit AES encryption, respectively.