Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 46

Chapter 3

Lecture Notes

Computer Security Cryptography and Encryption Techniques


Cryptography and Encryption Techniques
3.1 Introduction
Encryption is required for confidentiality and authentication (to assure that
a message comes from the alleged source)
Terminology
 Cryptography: it’s name is derived from Greek word called “Kryptos”
which means “Hidden Secrets”. It is an art and science of secret writing.
Or is the science of using mathematics for decrypting and encrypting data.
◦ Encryption: The process by which plaintext is converted into cipher text
◦ ƒDecryption: Recovering plaintext from the cipher text
◦ Secret key: Used by the encryption algorithm. In a classical (symmetric key)
cryptography, the same secret key is used for encryption and decryption
◦ Cryptanalysis: The study of “breaking the code”. Cryptanalysts!
◦ Cryptology: Cryptography + cryptanalysis

2
Cryptography and Encryption Techniques
3.1 Introduction
Cryptography has five ingredients
◦ Plaintext: the original message that is fed into the algorithm as input
◦ Encryption algorithm: performs various substitutions and transformations
on the plaintext
◦ Secret Key: is also input to the algorithm; the exact substitutions and
transformations performed by the algorithm depend on the key; larger key
size means greater security but may decrease encryption/decryption speed
◦ Cipher text: the scrambled message produced as output. It depends on the
plaintext and the secret key; for a given message, two different keys will
produce two different cipher texts
◦ ƒDecryption algorithm: the encryption algorithm run in reverse. It takes the
cipher text and the same secret key (in symmetric key cryptography) and
produces the original plaintext 3
Cryptography and Encryption Techniques
3.1 Introduction
 Simplified Symmetric Encryption Model

 The need for cryptography


◦ ƒIf you have the best firewall, very tight security policies, hardened operating systems,
virus scanners, intrusion-detection software, antispyware, and every other computer
security angle covered but send your data in raw, plain text, then you simply are not secure
4
Cryptography and Encryption Techniques
3.1 Introduction
 Description
◦ A sender S wants to transmit message M to a receiver R
◦ To protect the message M, the sender first encrypts it into an unintelligible message M’
◦ After receipt of M’, R decrypts the message to obtain M
◦ M is called the plaintext: what we want to encrypt
◦ M’ is called the cipher text: the encrypted output
 Note: Steganography is a technique for hiding a secret message within a
larger one so that others cannot discern the presence or contents of the hidden
message; it is used to claim ownership; it is not encryption

5
Cryptography and Encryption Techniques
3.1 Introduction
 Notation
◦ ƒ Given
 ƒ P = Plaintext
 ƒ C = Ciphertext
◦ ƒ C = EK(P) Encryption
◦ ƒ P = DK (C) Decryption
⇒P = DK (EK (P))
⇒C = EK (DK (C))

6
Cryptography and Encryption Techniques
3.1 Introduction
•Types of Cryptography
Mainly classified into two types :
1. Symmetric key cryptography
2. Asymmetric key cryptography
Cryptography

Symmetric Key Asymmetric(public) Key


Cryptography Cryptography

Classical Cryptography Modern Cryptography

Transposition Cipher Substitution Cipher Stream Cipher Block Cipher


7
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• Symmetric encryption is a form of cryptosystem in which encryption
and decryption are performed using the same key.
• It is also known as conventional encryption.
• Symmetric encryption transforms plaintext into cipher text using a
secret key and an encryption algorithm. Using the same key and a
decryption algorithm, the plaintext is recovered from the cipher text.
• Traditional (precomputer) symmetric ciphers use substitution and/or
transposition techniques. Substitution techniques map plaintext
elements (characters, bits) into cipher text elements. Transposition
techniques systematically transpose the positions of plaintext
elements.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• Substitution Cipher Techniques
Substitution cipher is a method of encryption by which units of plaintext are
substituted with cipher text according to a regular system.

• Substitution Cipher Techniques are:


 Caesar’s cipher
 Playfair cipher
 Monoalphabetic cipher
 Polyalphabetic cipher
 One time pad and Hill cipher
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Caesar’s cipher substitution technique.
• The method is named after Julius Caesar, who used it to communicate
with his generals.
• It is also known as the shift cipher, Caesar’s code or Caesar shift.
• It is one of the simplest and most widely known encryption
techniques.
• Letter in the plaintext is replaced by a letter some fixed number of
positions down the alphabet.
• Encryption of a letter x by a shift n can be described mathematically as,
• En(x) = (x+n) mod 26
• Example: Encryption of a letter A by a shift 3 can be described
mathematically as,
• En(x) = (A+3) mod 26 = (0+3) mod 26 = 3 mod 26 =3
• Encrypted letter for A is D
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• Decryption of a letter x by a shift n can be described mathematically as,
• Decryption is performed similarly,
• Dn(x) =(x-n) mod 26
• Example: Decryption of a letter D by a shift 3 can be described
mathematically as,
• Dn(x) = (D-3) mod 26 = (3 -3) mod 26 = 0 mod 26 =0
• Decrypted letter for D is A
• Example key = 3/D
Plain text A B C D E F G H I j k l m
Cipher text D E F G H I J K L M N O P

Plain Text N O P Q R S T U V W X Y Z

Cipher Text Q R S T U V W X Y Z A B C
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Monoalphabetic Cipher substitution technique:
• Caesar cipher is far from secure, it can be easily break by brute-force
cryptanalysis because of the key space are small: Simply try all
possible keys. All possible keys are 26.
• It uses fixed substitution over the entire message
• Uses random substitution
• Requires permutation or combination of 26 alphabets / 26! = possible
keys.
• Eliminate brute-force techniques for cryptanalysis
• Example encryption of the alphabet is given bellow
Plain text A B C D E F G H I j k l m
Cipher text Y N L K X B S H M I W D P
Plain Text N O P Q R S T U V W X Y Z

Cipher Text J R O Q V F E A U G T Z C
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Playfair Cipher substitution technique:
• The best-known multiple-letter encryption cipher, which treats
diagrams in the plaintext as single units and translate these into cipher
diagrams.
• Algorithm is based on the use of 5 × 5 matrix of letters constructed
using a keyword.
• Example, solved by lord peter Wismsey in Dorthy Sayers’s have his
Carcase. M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z

• In this case, the keyword is MONARCHY, the matrix is constructed


by filling the letter of the keyword from left to right and from top to
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• and filling the remainder of the matrix with the remaining letters in
alphabetic order.
• The letters I and J count as one letter. Plain text is encrypted two letters
at a time, according to the following rules:
1. Repeating plaintext letters that are in the same pair are separated with
a filler letter, such as x, so that hello would be treated as he lx lo.
2. Two plaintext letters that fall in same row of matrix are each replaced
by the letter to the right, with the first element of the row circularly
following the last. E.g. AR is encrypted as RM
3. Two plaintext letters that fall in the same column in a pair is replaced
by the letter beneath, with the top element of the column circularly
following the last. E.g. MU is encrypted as CM
4. Otherwise, each plaintext letter in a pair is replaced by the letter that
lies in its own row and the column occupied by other plain text.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• The playfair cipher is a great a advance over simple monoalphabetic
ciphers.
• One thing, There are only 26 letters, there are 26 × 26 = 676 diagrams,
so that identification of individual diagram is more difficult.
• Furthermore, the relative frequency of individual letters exhibit a
much greater range than that of diagrams, making frequency analysis
much more difficult.
• It was for along time unbreakable.
• It was standard field used by British army in World War I and still
enjoyed considerable by use by U.S. army and other Allied forces
during World War II.
• E.g. assume the key is playfair and encrypt the following
plaintexts:
1. Hello
2. Congratulation
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Hill cipher substitution technique
• Is another interesting multi-letter cipher, developed by the
mathematician Lester Hill in 1929.
• The encryption algorithm takes m successive plaintext letters and
substitutes for them m ciphertext letters.
• The substitution is determined by m linear equations in which each
character is assigned a numerical value (a = 0, b = 1 …..z =25).
• For m = 3, the system can be described as follows:
C1 = (K11P1 + K12P2 + K13P3) mod 26
C2 = (K21P1 + K22P2 + K23P3) mod 26
C3 = (K31P1 + K32P2 + K33P3) mod 26
• This can be expressed in term of column vector and matrices
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• = mod 26
Or
C = KP mod 26
Where c and p are column vectors of length 3, representing the plaintext
and cipher text, and k is a 3 × 3 matrix, representing the encryption key.
Operations are performed mod 26.
E.g. consider the plaintext “paymoremoney” and use the encryption key
K=
The first three letters of the plaintext are represented by vector
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
• . Then K = mod 26 = = LNS. Continuing in this fashion.
The ciphertext for the entire plaintext is LNSHDLEWMTRW
• Decryption requires using the inverse of the matrix K. the inverse of a
matrix K is defined by the equation K = K = I, where I is the matrix
that is all zeros except for ones along the main diagonal from upper left
to lower right.
• Decryption of ciphertext (C)= C
• Read more about matrix inverse
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Polyalphabetic substitution cipher
• Another way to improve on the simple monoalphabetic technique is to
Use different monoalpahbetic substitution as one precedes through the
plaintext .
• All those techniques have the following features in common.
1. A set of related monoalphabetic substitution rule is used.
2. A key determines which particular rule is chosen for a given
transformation.
• The best example is Vigenere cipher.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Vigenere cipher.
• Is polyalphabetic substitution cipher that is a natural evolution of the
Caesar cipher.
• The message is encrypted using a secret key, as well as encrypted table
called Vigenere table.
• A key is needed that is along as the message. Usually the key is
repeating keyword. E.g. if the key is deceptive, the message “we are
discovered save yourself” is encrypted as follows:
Key: deceptivedeceptivedeceptive
Plaintext: wearediscoveredsaveyourself
Ciphertext: zicvtwqngrzgvtwavzhcqyglmgj
Encryption The plaintext(P) and key(K) are:
Ei = (Pi + Ki) mod 26
Decryption Di = (Ei - Ki) mod 26
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 One-time pad substitution cipher.
• Is a type of vigenere cipher which include the following features
• It is unbreakable cipher
• The key is exactly the same as the length of the message which is
encrypted
• The key is made up of random symbols
• As the name suggests, key is used one time only and never used again
for any other message to be encrypted. Key never reused.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Transposition techniques
• Transposition technique is a cryptographic technique that converts the
plain text to cipher text by performing permutations on the plain text
i.e. change the position of each character of plain text for each round.
• It includes like Rail fence technique, simple columnar transposition
technique, vernam cipher, simple columnar transposition technique
with multiple rounds and book cipher to encrypt the plaintext.
• A transposition is an encryption in which the letters of the message are
rearranged. With transposition, the cryptography aims for diffusion,
widely spreading the information from the message or the key across
the ciphertext.
Symmetric key Cryptography
Columnar Transpositions
• The columnar transposition is a rearrangement of the characters of the
plaintext into columns.
• The following set of characters is a five-column transposition.
 The plaintext characters are written in rows of five and arranged one row after
another, as shown here.

23
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Rail-Fence technique
• The simple transposition techniques which involves writing plain text
as a sequence of diagonals and then reading it row to produce the
cipher text. Algorithm works as follows:
Step 1: Write down all the characters of plaintext message in a sequence
of diagonals
Step 2: Read the plaintext in step 1 as a sequence of rows.
E.g. create a cipher text from “corporate bridge” plain text.
First, we arrange the plaintext in a sequence of diagonal as :

Now read the plaintext by row wise. i.e. croaerdeoprtbig


Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Simple columnar transposition techniques cont..
Example: Let’s assume that Plain text is a corporate bridge and we need to
calculate the cipher text using a simple columnar transposition technique.
Let’s take 6 columns and arrange the plain text in a row-wise manner.

Decide the column order for reading the message – let’s assume 1,3,5,2,4,6 is
an order.
Now read the message in a columnar manner using the decided order. –
cadreeorotgpbri cadreeorotgpbri is a cipher text.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Simple columnar transposition techniques
 The simple columnar transposition technique can be categorized into two
parts – Basic technique and multiple rounds.
 Simples columnar transposition technique – basic technique. The simple
columnar transposition technique simply arranges the plain text in a
sequence of rows of a rectangle and reads it in a columnar manner.
How does this algorithm work?
Step 1: Write all the characters of plain text message row by row in a
rectangle of predefined size.
Step 2: Read the message in a columnar manner i.e. column by column.
Note: For reading the message, it needs not to be in the order of columns. It
can by any random sequence.
Step 3: The resultant message is cipher text.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Vernam Cipher
A subset of Vernam cipher is called a one-time pad because it is implemented
using a random set of nonrepeating characters as an input cipher text.
Note: Once the input cipher text is used for transposition, it never used for any
other message. The length of input ciphertext must be equal to the length of
plain text.
Working of Algorithm
Step 1: Arrange all characters in the plain text as a number i.e. A = 0, B = 1,
….. Z = 25.
Step 2: Repeat the same procedure for all characters of the input ciphertext.
Step 3: Add each number corresponding to the plain text characters to the
corresponding input ciphertext character number.
Step 4: If the sum of the number is greater than 25, subtract 26 from it.
Step 5: Translate each number of the sum into the corresponding characters.
Cryptography and Encryption Techniques
3.2 Symmetric key Cryptography
 Vernam Cipher cont..
In Vernam cipher, once the input cipher text is used, it will never be used for any other message, hence it
is suitable only for short messages.
Example: The plain text is educba and cipher text is ntcbar
Symmetric key Cryptography(modern)
DES

29
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography

 Asymmetric Encryption is a form of Encryption where keys come in


pairs.
o Asymmetric Encryption is also known as Public Key Cryptography,
since users typically create a matching key pair, and make one public
while keeping the other secret.
o Users can "sign" messages by encrypting them with their private keys.
o a public-key, which may be known by anybody, and can be used to
encrypt messages, and verify signatures
o a private-key, known only to the recipient, used to decrypt messages, and
sign(create)signatures
o Those who encrypt messages or verify signatures cannot decrypt
messages or create signatures
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography

 Public Key encryption


o Public key encryption, commonly known asymmetric encryption,
uses two different keys, a public key known by all and a private
key known by only the sender and the receiver.
o Both the sender and the receiver own a pair of keys, one public
and The other a closely guarded private one. To encrypt a message
from sender A to receiver B, both A and B must create their own
pairs of keys.
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography

 Public Key encryption cont..


o Then A and B publicize their public keys–anybody can acquire them.
When A is to send a message M to B, A uses B’s public key to encrypt
M. On receipt of M, B then uses his or her private key to decrypt the
message M. As long as only B, the recipient, has access to the private
key, then A, the sender, is assured that only B, the recipient, can
decrypt the message.
o This ensures data confidentiality.
o Data integrity is also ensured because for data to be modified by an
attacker it requires the attacker to have B’s, the recipient’s private key.
Data confidentiality and integrity in public key encryption is also
guaranteed.
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography

 Why Public Key encryption?


o Developed to address two key issues:

 key distribution–how to have secure communications in general


without having to trust insecure systems
 digital signatures–how to verify a message comes intact from the
claimed sender
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography

 Public Key characteristics

o Public-Key algorithms rely on two keys with the characteristics that it


is:
 computationally infeasible to find decryption key knowing
only algorithm & encryption key
 computationally easy to en/decrypt messages when the
relevant (en/decrypt) key is known
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA algorithm

•Stands for Rivest, Shamir & Adleman.


•Proposed arround1977
•best known & widely used public-key scheme
•based on exponentiation in a finite (Galois) field over integers modulo a prime
•uses large integers (eg. 1024 bits)
•security due to cost of factoring large numbers
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA Key setup
•each user generates a public/private key pair by:
•selecting two large primes at random -p, q
•computing their system modulus n=p.q
•note ø(n)=(p-1)(q-1)
•selecting at random the encryption key e
•where 1<e<ø(N), gcd(e,ø(N))=1
•solve following equation to find decryption key d
•e.d=1 mod ø(n) and 0≤d≤n
•publish their public encryption key: {e,n}
•keep secret private decryption key: {d,p,q}
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 Encryption using RSA
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 Why RSA Works ?
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA Example
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA Example cont..
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA security

• brute force key search (infeasible given size of numbers)


Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA signature generation and verification
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA signature generation and verification cont..
•RSA can be used both for encryption and digital signatures, simply by
reversing the order in which the exponents are used: the secret exponent (d)
to create the signature, the public exponent (e) for anyone to verify the
signature. Everything else is identical.
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA signature generation and verification cont..
•Example: Try to communicate with your friend by exchanging with your
signature.
Use primes p and q with p=5, q=7, n = 35 to send the message "the first
letter of your name} over the alphabet .
Cryptography and Encryption Techniques
3.2 Asymmetric key Cryptography
 RSA signature generation and verification cont..
Thank you!

You might also like