0% found this document useful (0 votes)
15 views28 pages

Lecture4 Cryptographyw

Uploaded by

Muhammad Yasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views28 pages

Lecture4 Cryptographyw

Uploaded by

Muhammad Yasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Dr. M.

Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)


Cryptography
Basics
• Cryptography is the science of secret, or hidden
writing
• It has two main Components:
1. Encryption
– Practice of hiding messages so that they can not be read by
anyone other than the intended recipient
2. Authentication & Integrity
– Ensuring that users of data/resources are the persons they claim
to be and that a message has not been surreptitiously altered

Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)


Encryption
Cipher
• Cipher is a method for encrypting messages

Plain Text Encryption Cipher Text Decryption Plain Text


Algorithm Algorithm

Key A Key B
• Encryption algorithms are standardized & published
• The key which is an input to the algorithm is secret
•Key is a string of numbers or characters
•If same key is used for encryption & decryption the algorithm is called
symmetric
• If different keys are used for encryption & decryption the algorithm is called
asymmetric
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Encryption
Symmetric Algorithms
• Algorithms in which the key for encryption and
decryption are the same are Symmetric
• Example: Caesar Cipher
• Types:
1. Block Ciphers
– Encrypt data one block at a time (typically 64 bits, or 128 bits)
– Used for a single message
2. Stream Ciphers
– Encrypt data one bit or one byte at a time
– Used if data is a constant stream of information

Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)


Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Symmetric Encryption
Key Strength
• Strength of algorithm is determined by the size of the key
• The longer the key the more difficult it is to crack
• Key length is expressed in bits
• Typical key sizes vary between 48 bits and 448 bits
• Set of possible keys for a cipher is called key space
• For 40-bit key there are 240 possible keys
• For 128-bit key there are 2128 possible keys
• Each additional bit added to the key length doubles the security
• To crack the key the hacker has to use brute-force
(i.e. try all the possible keys till a key that works is found)
• Super Computer can crack a 56-bit key in 24 hours
• It will take 272 times longer to crack a 128-bit key
(Longer than the age of the universe)

Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)


Substitution Ciphers
Caesar Cipher
• Caesar Cipher is a method in which each letter in the alphabet
is rotated by three letters as shown

ABCDEFGHIJKLMNOPQRSTUVWXYZ

DEFGHIJKLMNOPQRSTUVWXYZABC

• Let us try to encrypt the message


– Attack at Dawn
Assignment: Each student will exchange a secret message
with his/her closest neighbor about some other person in the
class and the neighbor will decipher it.

Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)


Substitution Ciphers
Caesar Cipher
Encryption
Plain Text Cipher Text
Cipher:
Message: Caesar Cipher Message:
Attack at Dawn Algorithm Dwwdfn Dw Gdyq

Key (3)
Decryption
Cipher Text Plain Text
Cipher:
Message: Caesar Cipher Message:
Dwwdfn Dw Gdyq Algorithm Attack at Dawn

Key (3)

How many different keys are possible?


Substitution Ciphers
Caesar Cipher
How many different keys are possible?
• In a Caesar cipher, there are 25 possible keys.
• This is because the Caesar cipher is a substitution cipher that shifts each letter in
the plaintext by a fixed number of positions down or up the alphabet.
• Since there are 26 letters in the English alphabet, excluding the key that doesn't
change the letters (a shift of 0), there are 25 different keys (1 to 25) that can be
used in a Caesar cipher.
• Each key represents a different amount of shift.

Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)


Substitution Cipher
Monoalphabetic Cipher
• Any letter can be substituted for any other letter
• Each letter has to have a unique substitute

ABCDEFGH I JKLMNOPQRSTUVWXYZ

MNBVCXZASDFGHJ KLPO IUYTREWQ


• There are 26! pairing of letters (~1026)
• Brute Force approach would be too time consuming
• Statistical Analysis would make it feasible to crack the key

Message: Encrypted
Cipher: Message:
Bob, I tell you. Monoalphabetic Nkn, s gktc wky.
Alice Cipher mgsbc

Key
Substitution Cipher
Polyalphabetic Caesar Cipher
• Developed by Blaise de Vigenere
• Also called Vigenere cipher
• Uses a sequence of monoalpabetic ciphers in tandem
• e.g. C1, C2, C2, C1, C2

Plain Text ABCDEFGH I JKLMNOPQRSTUVWXYZ

C1(k=6) FGH I JKLMNOPQRSTUVWXYZABCDE


C2(k=20) TUVWXYZABCDEFGH I JKLMNOPQRS
• Example

Message: Encrypted
Cipher: Message:
Bob, I tell you. Monoalphabetic Gnu, n etox dhz.
Alice Cipher tenvj

Key
Substitution Cipher
Using a key to shift alphabet
• Obtain a key for the algorithm and then shift the alphabets
• For instance if the key is word we will shift all the letters by four and remove the
letters w, o, r, & d from the encryption
• We have to ensure that the mapping is one-to-one
• no single letter in plain text can map to two different letters in cipher text
• no single letter in cipher text can map to two different letters in plain text

Plain Text ABCDEFGH I JKLMNOPQRSTUVWXYZ

C1(k=6) WORDABCEFGH I JKLMNPQSTUVXYZ

Message:
Encrypted
Cipher: Message:
Bob, I tell you.
??
Alice

WORD
Transposition Cipher
Columnar Transposition
In a Columnar Transposition cipher, the number of possible keys depends on the length of the
keyword used to perform the transposition.

The key in a Columnar Transposition cipher is typically a keyword that determines the order in
which columns are written out. The length of the keyword determines the number of columns
used in the transposition. For example, if the keyword is "KEY", then there are 3 columns used in
the transposition.

The number of possible keys can be calculated based on the permutations of the unique letters in
the keyword. For example, if the keyword has 3 unique letters, there are 3! (3 factorial)
permutations of those letters. If some letters are repeated, then you would divide by the factorial
of the number of times each letter is repeated to account for duplicate permutations.

For instance, if the keyword is "SECRET", there are 3 unique letters (S, E, C), and the letter E is
repeated twice. So, the number of permutations would be 6! / (2! * 2!) = 720 / 4 = 180.

Therefore, for a Columnar Transposition cipher with a keyword of length n and m unique letters,
the number of possible keys is n! / (p₁! * p₂! * ... * pₘ!), where p₁, p₂, ..., pₘ are the factorials of the
number of times each unique letter is repeated in the keyword.
Transposition Cipher
Columnar Transposition
• This involves rearrangement of characters on the plain text into columns
• The following example shows how letters are transformed
• If the letters are not exact multiples of the transposition size there may be a
few short letters in the last column which can be padded with an infrequent
letter such as x or z

Plain Text Cipher Text


T H I S I T S S O H
S A M E S O A N I W
S A G E T H A A S O
O S H O W L R S T O
H O W A C I M G H W
O L U M N U T P I R
A R T R A S E E O A
N S P O S M R O O K
I T I O N I S T W C
W O R K S N A S N S
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)
Cryptanalysis
Basics
• Practice of analyzing and breaking cryptography
• Resistance to crypt analysis is directly proportional to the key
size
• With each extra byte strength of key doubles
• Cracking Pseudo Random Number Generators
• A lot of the encryption algorithms use PRNGs to generate keys
which can also be cracked leading to cracking of algorithms
• Variety of methods for safe guarding keys (Key Management)
• Encryption & computer access protection
• Smart Cards

Dr. M. Muzaffar Hameed, Department of Computer Science, BZU Multan (PAKISTAN)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy