ciphers-converted
ciphers-converted
’
UNIT-2
SYMMETRIC-KEY CRYPTOGRAPHY
In this technique,
● Both sender and receiver uses a common key to encrypt and decrypt the message.
● This secret key is known only to the sender and to the receiver.
● It is also called as secret key cryptography.
W orking-
The message exchange using symmetric key cryptography involves the following steps-
● Before starting the communication, sender and receiver shares the secret key.
● This secret key is shared through some external means.
● At sender side, sender encrypts the message using his copy of the key.
● The cipher text is then sent to the receiver over the communication channel.
● At receiver side, receiver decrypts the cipher text using his copy of the key.
● After decryption, the message converts back into readable format.
A – Monoalphabetic Cipher
Let’s look at an example of monoalphabetic cipher called Caesar cipher.
Caesar Cipher:
Is the simplest and the oldest known encryption techniques where elements in the plaintext
are shifted a fixed number of spaces. For example, they’re moved 3 places:
Example:
Solution:
We apply the encryption algorithm to the plaintext, character by character. The result is
“WTAAD”. Note that the cipher is monoalphabetic because two instances of the same
plaintext character (ls) are encrypted as the same character (A).
Playfair Cipher:
Not even the large number of keys in a monoalphabetic cipher provides security. One
approach to improving security is to encrypt multiple letters at a time.The Playfair Cipher is
the best known such cipher.
● The key is a 5x5 square (I and J are treated as the same letter).
A key word, ‘tutorials’ In a key table, the first characters (going left to right) in the table is
the phrase, excluding the duplicate letters. The rest of the table will be filled with the
remaining letters of the alphabet, in natural order. The key table works out to be −
Playfair Cipher: Encryption
Rules:
● First, a plaintext message is split into pairs of two letters (digraphs). If there is an odd
number of letters, a Z is added to the last letter. Let us say we want to encrypt the
message “hide money”. It will be written as −
HI DE MO NE YZ
● The rules of encryption are −
o If both the letters are in the same column, take the letter below each one
(going back to the top if at the bottom)
T U O R I
A L S B C
D E F G H ‘H’ and ‘I’ are in same column, hence take letter below them
to replace. HI → QC
K M N P Q
V W X Y Z
● If both letters are in the same row, take the letter to the right of each one (going back
to the left if at the farthest right)
T U O R I
‘D’ and ‘E’ are in same row, hence take letter to the right of
them to replace. DE → EF
A L S B C
D E F G H
K M N P Q
V W X Y Z
● If neither of the preceding two rules are true, form a rectangle with the two letters
and take the letters on the horizontal opposite corner of the rectangle.
Using these rules, the result of the encryption of ‘hide money’ with the key of ‘tutorials’
would be −
QC EF NU MF ZV
Decrypting the Playfair cipher is as simple as doing the same process in reverse. Receiver
has the same key and can create the same key table, and then decrypt any messages made
using that key.
S trength :
of playfair cipher Playfair cipher is a great advance over simple mono alphabetic ciphers. Since
there are 26 letters, 26x26 = 676 diagrams are possible, so identification of individual diagram is
more difficult.
HILL CIPHER:
Description
The Hill cipher is an example of a block cipher. A block cipher is a cipher in which groups of
letters are enciphered together in equal length blocks. The Hill cipher was developed by
Lester Hill and introduced in an article published in 1929[1].
Encipher
In order to encrypt a message using the Hill cipher, the sender and receiver must first agree
upon a key matrix A of size n x n. Amust be invertible mod 26. The plaintext will then be
enciphered in blocks of size n. In the following example A is a 2 x 2 matrix and the message
will be enciphered in blocks of 2 characters.
Formula: C= KP MOD 26 (K MEANS KEY,P MEANS PLAIN TEXT
Key Matrix: A =
Message: MISSISSIPPI
The first block MI corresponds to the matrix . The sender will then
Vigenère
Cipher
Description
The Vigenère cipher is an example of a polyalphabetic substitution cipher. A polyalphabetic
substitution cipher is similar to a monoalphabetic substitution except that the cipher alphabet
is changed periodically while enciphering the message. This makes the cipher less vulnerable
to cryptanalysis using letter frequencies.
Encipher: In order to encipher a message using the Vigenère autokey method, the sender
and receiver must first agree on a priming key. The priming key is a single letter that will be
added to the beginning of the message to form the key. The sender will encrypt the message
by writing the plaintext on one line and writing the key on the line beneath it. The sender will
use the plaintext and key letters to select a row and a column in the Vigenère square. The
selected row is the row in which the plaintext letter is in the first column and the selected
column is the column in which the key letter is in the first row. A ciphertext letter will be the
letter that appears in the Vigenère square at the position corresponds to the selected row and
column.
FORMULA: C= (P+K) MOD 26
P=(C-K) MOD 26
Priming key: L
plaintext: T O B E O R N O T T O B E
key: L T O B E O R N O T T O B
ciphertext: E H P F S F E B H M H P F
One Time Pad(vernam cipher) :(OTP) is the only potentially unbreakable encryption
method. Plain text encrypted using an OTP cannot be retrieved without the encrypting key.
However, there are several key conditions that must be met by the user of a one time pad
cipher, or the cipher can be compromised.
Encryption:
A typical one time pad system works like this: Generate a long fresh new random key. XOR
the plaintext with the key to create the ciphertext.
Decryption:
To decrypt the ciphertext, XOR it with the original key. The system as presented is thus a
symmetric and reciprocal cipher. Other functions (e.g., addition modulo n) could be used to
combine the key and the plaintext to yield the ciphertext, although the resulting system may
not be a reciprocal cipher.
E xample:
T ransposition Cipher:
Description
The idea behind a transposition cipher is to create a permutation (rearrangement) of the
letters of the plaintext that will make the ciphertext appear to be well-encrypted.
Transposition ciphers are not highly secure because they do not change the letters in the
plaintext or even cover up frequencies, but they can be built upon to make more secure
methods of encryption. One example of transposition cipher is the rail fence cipher.
Example
The rail fence cipher is a very simple columnar transposition that takes a string and splits
the letters into two groups by way of a zigzag pattern, as shown below:
Encipher
plaintext = WHEN DRINKING WATER, REMEMBER ITS SOURCE.
compressed plaintext = WHENDRINKINGWATERREMEMBERITSSOURCE
zig: W E D I K N W T R E E B R T S U C
zag: H N R N I G A E R M M E I S OR E
zig=WEDIKNWTREEBRTSUC
zag=HNRNIGAERMM/8EISO
RE
ciphertext=zig+zag
ciphertext=WEDIKNWTREEBRTSUCHNRNIGAERMMEISORE
Decipher
To decipher, simply cut the ciphertext in half and create a new string with alternating letters
from both substrings.
substring_1=WEDIKNWTREEBRTSUC
substring_2=HNRNIGAERMMEISORE
newstring = W + H + E + N + D + R + … + U + R + C + E"
Modern Symmetric Key Encryption:
Digital data is represented in strings of binary digits (bits) unlike alphabets. Modern
cryptosystems need to process this binary strings to convert in to another binary string.
Based on how these binary strings are processed, a symmetric encryption schemes can be
classified in to −
Block Ciphers
In this scheme, the plain binary text is processed in blocks (groups) of bits at a time; i.e. a
block of plaintext bits is selected, a series of operations is performed on this block to
generate a block of ciphertext bits. The number of bits in a block is fixed. For example, the
schemes DES and AES have block sizes of 64 and 128, respectively.
Stream Ciphers
In this scheme, the plaintext is processed one bit at a time i.e. one bit of plaintext is taken,
and a series of operations is performed on it to generate one bit of ciphertext. Technically,
stream ciphers are block ciphers with a block size of one bit.
Block cipher:
Block Size:
However any size of block is satisfactory, resulting aspects are borne in mind while selecting
a size of a block.
● Avoid very small block size − Say a block size is m bits. Then the likely plaintext bits
combinations are then 2m. If the attacker learns the plain text blocks consistent to some
before sent ciphertext blocks, then the attacker can launch a type of ‘dictionary attack’ by
building up a dictionary of plaintext/ciphertext pairs sent using that encryption key. A
larger block size makes attack harder as the dictionary needs to be larger.
● Do not have very large block size − With very large block size, the cipher becomes
inefficient to operate. Such plaintexts will need to be padded before being encrypted.
● Multiples of 8 bit − A preferred block size is a multiple of 8 as it is easy for
implementation as most computer processor handle data in multiple of 8 bits.
Padding in Block Cipher:
Block ciphers method blocks of fixed sizes (say 64 bits). The length of plaintexts is typically
not a many of the block size. For instance, a 150-bit plaintext delivers two blocks of 64 bits
each with third block of balance 22 bits. The latter block of bits wants to be padded up with
dismissed information so that the length of the final block equal to block size of the scheme.
In our instance, the remaining 22 bits need to have additional 42 redundant bits added to offer
a complete block. The procedure of adding bits to the last block is referred to as padding.
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.
All rounds have the same structure. A substitution is performed on the left half of the data
(as similar to S-DES). This is done by applying a round function F to the right half of the data
and then taking the XOR 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 ki . 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.
The exact realization of a Feistel network depends on the choice of the following
parameters and design features: Block size - Increasing size improves security, but slows
cipher
· Key size - Increasing size improves security, makes exhaustive key searching harder,
but may slow cipher
Number of rounds - Increasing number improves security, but slows cipher
· Subkey generation - Greater complexity can make analysis harder, but slows cipher
· Round function - Greater complexity can make analysis harder, but slows cipher
· Fast software en/decryption· & ease of analysis - are more recent concerns for practical
use and testing.
The process of decryption is essentially the same as the encryption process. The rule is 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 the
value swapped.
After the last iteration of the encryption process, the two halves of the output are
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 round of the encryption process.
First consider the encryption process,
Feistel encryption and decryption