Chapter 3
Chapter 3
Chapter 3
• Introduction
• What is Cryptography?
• Purpose of cryptography
• Types of Cryptography
• Types of cryptography Algorithms
• Attacks of cryptography
Introduction
• The Internet or the global Internet is the internationally connected network of
computer networks with addresses that are administrated by IANA (Internet
• There are many aspects to security and many applications, ranging from secure
• These algorithms stop third parties, commonly known as enemies or hackers, to peep into your data.
• According to American cryptographer and computer security expert Bruce, cryptography is “the art and
science of keeping messages secure.”.
• The cryptography method transforms plain text into encrypted text (aka ciphertext) using the encryption
key, and the target receiver can decrypt it using a unique decryption key.
Cont…
• Cryptography is the process of converting simple plain text into secret text called
ciphertext, and converting ciphertext back to its original simple text,
• The process uses algorithms known as crypto-algorithms to perform the encryption and
decryption process.
• Sometimes, only one key is used to perform both encryption and decryption and
sometimes two separate keys are used, one for encryption and the other key for
decryption.
Cont…
• Cryptography derived its name from a Greek word called “krypto’s” which means
“Hidden Secrets”.
data and again retransforming that message into its original form.
➢ Secret key: Used to set some or all of the various parameters used by the encryption
algorithm.
• Plaintext
• Encryption algorithm
• Secret Key
• Ciphertext
• Decryption algorithm
Description
message M’
• P=Plaintext
• C=CipherText
• C = EK (P) Encryption
• P = DK (C) Decryption
Why Study Cryptography?
• In today’s Internet world, cryptography applications are used to enable digital signatures,
money transfers, online shopping, online booking, and credit card payments, where
• Cryptography makes transactions on the web more secure through digital certificates, 3-D
• With the rise in government surveillance of Internet data, which is making headlines every day,
people are even more concerned about their privacy and personal data.
Cont…
• Human being from ages had two inherent needs:
• These two needs gave rise to the art of coding the messages in such a way that only the
• Unauthorized people could not extract any information, even if the scrambled messages
• Is the study of how to alter a message so that someone intercepting it cannot read
it without the appropriate algorithm and key.
• Is the study of secure communications techniques that allow only the sender and
intended recipient of a message to view its contents
• Confidentiality
• It is a security service that keeps the information from an unauthorized person.
• It is sometimes referred to as privacy or secrecy.
• Data Integrity
• Integrity service confirms that whether data is intact or not since it was last created, transmitted, or stored
by an authorized user.
• Authentication
• It confirms to the receiver that the data received has been sent only by an identified and verified sender.
• Non-repudiation
• It is an assurance that the original creator of the data cannot deny the creation or transmission of the said
data to a recipient or third party.
Cryptography Algorithms
data.
• The strength of the encryption depends on the keys and cryptographic algorithm
which makes use of these keys to encrypt.
Cryptography Algorithms
2. Asymmetric Key(Public Key) Cryptography: Uses one key for encryption and another
different key for decryption and is also called asymmetric encryption. It is primarily used for
authentication, nonrepudiation, and key exchange.
3. Hash functions: Uses a mathematical transformation that transforms the message into a fixed
length data that is unique to the corresponding source.
Cont….
Cont…
Symmetric Cryptography
• Symmetric cryptography, known also as secret key cryptography, is the use of a single
shared secret to share encrypted data between parties.
• In simple terms, the sender encrypts data using a password, and the recipient must know
that password to access the data.
• Symmetric Encryption is useful for protecting data between parties with an established
shared key and is also frequently used to store confidential data.
Cont…
• Symmetric cryptography methods employ a single key for both encryption and
decryption.
• Symmetric keys are also known as secret keys. The sender uses the key to
encrypt the plaintext and sends the ciphertext to the receiver.
• The receiver then applies the same key to decrypt the message and recover the
plaintext.
• Because a single key is used for both functions, it is called symmetric encryption.
Cont…
Cont…
Cont…
Cont…..
Common Symmetric Algorithms
• Some of the most popular crypto algorithms are:
• AES (Advanced Encryption Standard)
• DES (Data Encryption Standard)
• IDEA (International Data Encryption Algorithm)
• Blowfish (Drop-in replacement for DES or IDEA)
• RC4 (Rivest Cipher 4)
• RC5 (Rivest Cipher 5)
• RC6 (Rivest Cipher 6)
What are some advantages of symmetric encryption?
• Speed: Because of its shorter key lengths and relative simplicity compared to
asymmetric encryption, is much faster to execute.
• Each user has two keys: a public key and a private key and Both keys are mathematically
related (both keys together are called the key pair).
• The public key is made available to anyone and the private key is kept secret.
• Data encrypted with the public key is unencrypted with the private key.
• Encrypting data with the private key creates a digital signature and this ensures the message has
come from the stated sender (because only the sender had access to the private key to be able to
create the signature).
Cont…
• Asymmetric cryptography is often used to exchange the secret key to prepare for
using symmetric cryptography to encrypt data.
• In the case of a key exchange, one party creates the secret key and encrypts it with the
public key of the recipient.
• The receiver would then decrypt it with their private key and the remaining
communication would be done with the secret key being the encryption key.
• Asymmetric encryption uses two separate keys: a public key and a private key and
often a public key is used to encrypt the data while a private key is required to decrypt
the data.
• The private key is only given to users with authorized access. As a result, asymmetric
encryption can be more effective, but it is also more costly.
Cont…
Cont…
• Key distribution not necessary: securing key distribution channels has long been a headache
in cryptography. Asymmetric encryption eliminates key distribution entirely.
• Exchange of private keys not necessary: with asymmetric encryption, private keys should
remain stored in a secure location and thus private to the entities using them.
• Digital signature/message authentication: with asymmetric encryption, senders can use their
private keys to digitally sign and verify that a message or file originated from them and not an
• Hash functions, also referred to as message digests, do not use a key, but instead create a largely
unique and fixed-length hash value, commonly referred to as a hash, based on the original
message, something along the same lines as a fingerprint. Any slight change to the message will
change the hash.
• Hashes cannot be used to discover the contents of the original message, or any of its other
characteristics, but can be used to determine whether the message has changed.
• For instance, a rudimentary example of a hashing algorithm is simply adding up all the letter
• The result of a hashing algorithm is called a message Digest (or sometimes Checksum, or
Fingerprint). The result of our example hashing on the original message of hello was 52.
• If someone were to change our original message and process it through the same hashing
• The receiver simply hashes the message again using the same algorithm, then compares the two
hashes. If the hashes match, the message has not changed.
• Although it is theoretically possible to engineer a matching hash for two different sets of data,
called a collision, this is a very difficult task indeed, and generally requires that the hashing
Lecture 2
Classical Encryption Technique
• If the plain text (original message) is considered as the string of bits, then the substitution technique would replace
bit pattern of plain text with the bit pattern of cipher text.
• If the plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit
patterns with cipher text bit patterns.
Substitution technique: Caesar Cipher
• Is one of the earliest and simplest method of encryption technique.
• It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced
by a letter some fixed number of positions down the alphabet.
• Thus to cipher a given text we need an integer value, known as shift which
indicates the number of position each letter of the text has been moved down.
• The encryption can be represented using modular arithmetic by first transforming the letters into
numbers, according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a shift n
can be described mathematically as the figure bellow.
Substitution technique: Caesar Cipher
• Examples 1:
Text (P): ATTACKATONCE
Shift (Key): 4
Cipher (C): EXXEGOEXSRGI
Workout
Plain Text: MEET ME TOMORROW
Key: 3
Cipher (C):??????
Substitution Technique: Monoalphabetic Cipher
• Monoalphabetic cipher is a substitution cipher, where the cipher
alphabet for each plain text alphabet is fixed, for the entire encryption.
• In simple words, if the alphabet ‘p’ in the plain text is replaced by the
cipher alphabet ‘d’.
• Then in the entire plain text wherever alphabet ‘p’ is used, it will be
replaced by the alphabet ‘d’ to form the ciphertext.
Substitution Technique: Monoalphabetic Cipher
Substitution Technique: Polyalphabetic Cipher
• In the monoalphabetic ciphers (shift, substitution) we have looked at so far, we
have always replaced a single plaintext letter with the same ciphertext letter.
• Step 1: Create a 5X5 matrix and place the key in that matrix row-wise from left to
right. Then put the remaining alphabets in the blank space.
Substitution Technique: Playfair Cipher
• A 5X5 matrix of letters based on a keyword
• Key : MONARCHY
Example : P= HELLO Then
Pair p into two letter together
P=HE LL O (HE LX OX) why?
C=CFSUAV
Cont…
Workout
Given
• Key=PASSWORD
• P=ETHIOPIA
Then What is C?
Substitution Technique: One-Time Pad
• One Time Pad algorithm is also known as Vernam Cipher and it is a method
of encrypting alphabetic plain text.
• It is an unbreakable cipher.
Why is it Unbreakable?
• Each key should be used once and destroyed by both sender and receiver.
• There should be two copies of key: one with the sender and other with the
receiver.
Example of One-Time Pad
Substitution Technique: Hill Cipher
• In classical cryptography, the Hill cipher is a polygraphy substitution
cipher based on linear algebra.
• It was the first polygraphy cipher in which it was practical (though barely) to
operate on more than three symbols at once.
• The matrix used for encryption is the cipher key, and it should be chosen
randomly from the set of invertible n × n matrices (modulo 26).
Substitution Technique: Hill Cipher
Substitution Technique: Hill Cipher
Substitution Technique: Hill Cipher
Substitution Technique: Hill Cipher
Substitution Technique: Hill Cipher
Substitution Technique: Hill Cipher
Example 2
• Consider the Plaintext(message) is 'ACT', and the key below (GYB/NQK/URP in letters):
ciphertext = ‘POH'.
ciphertext = 'FIN'.
Transposition Cipher
• Transposition cipher, simple data encryption scheme in which plaintext characters are shifted in
some regular pattern to form ciphertext.
• In manual systems transpositions are generally carried out with the aid of an easily remembered
mnemonic.
• For example, a popular schoolboy cipher is the “rail fence,” in which letters of the plaintext are
written alternating between rows and the rows are then read sequentially to give the cipher.
• In a depth-two rail fence (two rows) the message WE ARE DISCOVERED SAVE YOURSELF
would be written
• The Rail Fence Cipher is a type of transposition cipher and a transposition cipher involves the
rearranging of the letters in the plaintext to encrypt the message.
• This is in contrast to a substitution cipher, in which the plaintext letters are replaced by letters
from another alphabet (or by different letters from the same alphabet).
Cont…
• The rail fence cipher is the simplest transposition cipher.
• The steps to obtain cipher text using this technique are as follow:
• Step 1: The plain text is written as a sequence of diagonals.
• Step 2: Then, to obtain the cipher text the text is read as a sequence of rows.
Example
• So, reading the first row the first half of cipher text will be:
memtmro
• reading the second row of the rail fence, we will get the second half of the cipher text:
eteoorw
• Now, to obtain the complete cipher text combine both the halves of cipher text and the complete
cipher text will be:
• Cipher Text: M E M T M R O E T E O O R W
Cont…
• Is simplest of such cipher, in which the plaintext is written down as a sequence of diagonals and then
read off as a sequence of rows
• Plaintext = meet at the school house
To encipher this message with a rail fence of depth 2
m . e. a . t . e . c . o . l . o . S .
. e . t . t . h . s . h. o . h . u . E
C: meat ec olo setths hohue
Example 2: using three "rails" and a message of 'WE ARE DISCOVERED FLEE AT ONCE', the
ciphered writes out:
W. . . E . . . C . . . R . . . L . . . T . . . E
. E . R . D . S . O . E . E . F . E . A. O . C .
. . A. . . I . . . V. . . D. . . E. . . N . .
✓ Key(Depth): 3
• In a columnar transposition, the message is written out in rows of a fixed length, and then read out again
column by column, and the columns are chosen in some scrambled order.
• Both the width of the rows and the permutation of the columns are usually defined by a keyword.
• For example,
• Keyword ZEBRAS is of length 6 (so the rows are of length 6), and
• The permutation is defined by the alphabetical order of the letters in the keyword. In this case, the
order would be "6 3 2 4 1 5".
Cont…
For example,
• Keyword ZEBRAS is of length 6 (so the rows are of length 6), and
• The permutation is defined by the alphabetical order of the letters in the keyword. In this
case, the order would be "6 3 2 4 1 5".
• Encryption
• Example
• Keyword: ZEBRAS
• Text: WE ARE DISCOVERED. FLEE AT ONCE
Providing five nulls (QKJEU), these letters can be randomly selected as they just fill out the incomplete
columns and are not part of the message.
Cont…
• Decryption
• Keyword: ZEBRAS
• Text: EVLNE ACDTK ESEAQ ROFOJ DEECU WIREE= 30 Letter
• 30/6= 5 row
• We start similarly to above, by heading the columns with the keyword ZEBRAS.
• This time, to find how many rows we need, we do 25 ÷ 6 = 4.16 We round this up to the next
• The we multiply 6 x 5 we get 30, and 30 - 25 = 5. Hence we need 5 placeholders in the last row.
• After plugin the ciphertext letters in, in the same way as above, we get the above table.
Common Symmetric Algorithms
• Some of the most popular crypto algorithms are:
• AES (Advanced Encryption Standard)
• DES (Data Encryption Standard)
• IDEA (International Data Encryption Algorithm)
• Blowfish (Drop-in replacement for DES or IDEA)
• RC4 (Rivest Cipher 4)
• RC5 (Rivest Cipher 5)
• RC6 (Rivest Cipher 6)
Advanced Encryption Standard(AES)
• The Advanced Encryption Standard (AES) is a symmetric block cipher chosen
by the U.S. government to protect classified information.
14 rounds respectively.
• The decryption process also has four operations are Inverse substitution byte,
Inverse shift row, Inverse Mix-column and Inverse add round key.
A. Sub-Bytes Transformation: Every byte in the state is replaced by another one using
the S-BOX.
B. Shift Rows: Every row in the 4x4 array is shifted a certain amount to the left.
C. Mix-Column: A linear transformation on the columns of the state. The Mix-column
operation is omitted in the final round
D. Add Round Key: Each byte of the state is XOR with a round key, which is a different
key for each round.
AES Decryption Process
A. Inverse Sub-Byte: Each byte in the state matrix is replaced with inverse S-box table
B. Inverse Shift Row: Every row in the 4x4 array is shifted a certain amount to right.
C. Inverse Mix-Column: This is inverse operation of mix column operation. This
operates on the state matrix column by column and each column is treated as a four
term polynomial.
D. Inverse Add Round Key: Inverse XOR operation is performed with each byte.
Cont….
Cont…
• AES performs operations on bytes of data rather than in bits. Since the
block size is 128 bits, the cipher processes 128 bits (or 16 bytes) of the
input data at a time.
End of
R1
And
start R1
DES(Data Encryption Standard)
• In 1973, the NBS (National Bureau of Standards, now called NIST-National
Institute of Standards and Technology) published a request for an encryption
• Be easily understood
• DES was approved by the NBS in 1978 and it was standardized by the ANSI under the
name of ANSI X3.92, also known as DEA (Data Encryption Algorithm).
• DES Utilizes block cipher, which means that during the encryption process, the plaintext
is broken into fixed length blocks of 64 bits.
• The key is 56 bits wide and 8-bit out of the total 64-bit block key is used for parity
check.
• DES is the most widely used symmetric algorithm despite claims whether 56 bits
is long enough to guarantee security.
• Using current technology, 56-bit key size is vulnerable to a brute force attack.
Cont…
• DES Encryption starts with an initial permutation (IP) of the 64 input bits and
these bits are then divided into two 32-bit halves called L and R.
• The encryption then proceeds through 16 rounds, each using the L and R parts,
and a subkey.
• The R and subkeys are processed in the so called f-function, and exclusive-or of
the output of the f-function with the existing L part to create the new R part.
• That is, subkey 16 is used in round 1, subkey 15 is used in round 2, etc., ending
with subkey 1 being used in round 16.
DES Algorithm Structure
Cont…
• The f-function mixes the bits of the R portion using the Subkey for the current
round.
• First the 32-bit R value is expanded to 48 bits using a permutation E and that
value is then exclusive-or with the subkey.
• The 48 bits are then divided into eight 6-bit chunks, each of which is fed into an
S-Box that mixes the bits and produces a 4-bit output.
• Those 4-bit outputs are combined into a 32-bit value, and permuted once again to
produce the f-function output.
Basic Step of DES
• DES consists of 16 steps, each of which is called a round. Each round performs the steps of
substitution and transposition.
1. In the first step, the 64-bit plain text block is handed over to an initial Permutation (IP) function.
2. The initial permutation is performed on plain text.
3. Next, the initial permutation (IP) produces two halves of the permuted block; says Left Plain
Text (LPT) and Right Plain Text (RPT).
4. Now each LPT and RPT go through 16 rounds of the encryption process.
5. In the end, LPT and RPT are rejoined and a Final Permutation (FP) is performed on the
combined block
• For example, it says that the IP replaces the first bit of the original plain text block with the 58th
bit of the original plain text, the second bit with the 50th bit of the original plain text block, and
so on.
Asymmetric Key
Result:
● n is known as the modulus for both the public and private keys
2. n = pq = 11*3 = 33
phi = (p-1)(q-1) = 10*2 = 20
3. Choose e=3
Check gcd(e, p-1) = gcd(3, 10) = 1 (i.e. 3 and 10 are relatively prime - have no common factors except
1) and check gcd(e, q-1) = gcd(3, 2) = 1,
therefore gcd(e, phi) = gcd(e, (p-1)(q-1)) = gcd(3, 20) = 1