0% found this document useful (0 votes)
28 views37 pages

Lec Cryptography

Uploaded by

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

Lec Cryptography

Uploaded by

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

Cryptography

Why Study Cryptography?


• Secrets are intrinsically interesting
• So much real-life drama:
• Mary Queen of Scots executed for treason
• primary evidence was an encoded letter
• they tricked the conspirators with a forgery
• Students enjoy puzzles
• Real world application of mathematics
Some basic terminology
• Alice wants to send a secret message to Bob
• Eve is eavesdropping
• Cryptographers tell Alice and Bob how to encode their messages
• Cryptanalysts help Eve to break the code
• Historic battle between the cryptographers and the cryptanalysts that
continues today
• Cryptanalysis = the science (art) of breaking encryption
• Cryptology = cryptography + cryptanalysis
Cryptographers vs Cryptanalysts
• A battle that continues today
• Cryptographers try to devise more clever algorithms and keys
• Cryptanalysts search for vulnerabilities
• Early cryptanalysts were linguists:
• frequency analysis
• properties of letters
Cryptography Goals
Eve

Alice Bob
Insecure Channel

• Encryption – Prevent Eve from intercepting message


• Authentication – Prevent Eve from impersonating Alice
Cryptography
• art and science of hiding the meaning of information, in a way that only
some people can see
• the science of secure communication, relies heavily on mathematics to
ensure the confidentiality and integrity of data.
• From encrypting sensitive information to securely transmitting
messages, math plays a crucial role in various cryptographic algorithms
and systems.
• One fundamental mathematical concept employed in cryptography is
modular arithmetic. Modular arithmetic deals with the remainder when
dividing numbers.
• A cipher is an algorithm for performing encryption (and the reverse,
decryption).
• The original information is called plaintext. After it is encrypted, it is
called ciphertext.
Secure Communication
Needs and Requirements
• Well established needs for secure communication
• War time communication
• Business transactions
• Illicit Love Affairs
• Requirements of secure communication
1. Secrecy
– Only intended receiver understands the message
2. Authentication
– Sender and receiver need to confirm each others identity
3. Message Integrity
– Ensure that their communication has not been altered, either maliciously or by
accident during transmission
Cryptography
• art and science of hiding the meaning of information, in a way that
only some people can see
• 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 covertly altered
Encryption

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
CAESAR CIPHER / SHIFT CIPHER
• The Caesar cipher is a simple encryption technique that was used by
Julius Caesar to send secret messages to his allies.
• It works by shifting the letters in the plaintext message by a certain
number of positions, known as the “shift” or “key”.
• It’s simply a type of substitution cipher, i.e., each letter of a given text
is replaced by a letter with a fixed number of positions down the
alphabet.
• The formula of encryption is:
En (x) = (x + n) mod 26
• The formula of decryption is:
Dn (x) = (xi - n) mod 26
• If any case (Dn) value becomes negative (-ve), in this case, we will add 26 in the
negative value.
Where,
E denotes the encryption
D denotes the decryption
x denotes the letters value
n denotes the key value (shift value)
• Thus to cipher a given text we need an integer value, known as a shift
which indicates the number of positions 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.
• For example, if the shift is 3, then the letter A would be replaced by
the letter D, B would become E, C would become F, and so on. The
alphabet is wrapped around so that after Z, it starts back at A.
ENCRYPT THE MESSAGE “HELLO” with a
shift/key of 3:
1. Write down the plaintext message: HELLO
2. Choose a shift value. In this case, we will use a shift of 3.
3. Replace each letter in the plaintext message with the letter that is three
positions to the right in the alphabet.
H becomes K (shift 3 from H)
E becomes H (shift 3 from E)
L becomes O (shift 3 from L)
L becomes O (shift 3 from L)
O becomes R (shift 3 from O)
4.The encrypted message is now “KHOOR”
Advantages:
• Easy to implement and use thus, making suitable for beginners to
learn about encryption.
• Can be physically implemented, such as with a set of rotating disks or
a set of cards, known as a scytale, which can be useful in certain
situations.
• Requires only a small set of pre-shared information.
• Can be modified easily to create a more secure variant, such as by
using a multiple shift values or keywords.
Disadvantages:
• It is not secure against modern decryption methods.
• Vulnerable to known-plaintext attacks, where an attacker has access to
both the encrypted and unencrypted versions of the same messages.
• The small number of possible keys means that an attacker can easily
try all possible keys until the correct one is found, making it vulnerable
to a brute force attack.
• It is not suitable for long text encryption as it would be easy to crack.
• It is not suitable for secure communication as it is easily broken.
• Does not provide confidentiality, integrity, and authenticity in a
message.
Features of Caesar cipher:
• Substitution cipher: The Caesar cipher is a type of substitution cipher, where each letter in
the plaintext is replaced by a letter some fixed number of positions down the alphabet.
• Fixed key: The Caesar cipher uses a fixed key, which is the number of positions by which
the letters are shifted. This key is known to both the sender and the receiver.
• Symmetric encryption: The Caesar cipher is a symmetric encryption technique, meaning
that the same key is used for both encryption and decryption.
• Limited keyspace: The Caesar cipher has a very limited keyspace of only 26 possible keys,
as there are only 26 letters in the English alphabet.
• Vulnerable to brute force attacks: The Caesar cipher is vulnerable to brute force attacks, as
there are only 26 possible keys to try.
• Easy to implement: The Caesar cipher is very easy to implement and requires only simple
arithmetic operations, making it a popular choice for simple encryption tasks.
Rules for the Caesar Cipher:
• Choose a number between 1 and 25. This will be your “shift” value.
• Write down the letters of the alphabet in order, from A to Z.
• Shift each letter of the alphabet by the “shift” value. For example, if the
shift value is 3, A would become D, B would become E, C would become F,
and so on.
• Encrypt your message by replacing each letter with the corresponding
shifted letter. For example, if the shift value is 3, the word “hello” would
become “khoor”.
• To decrypt the message, simply reverse the process by shifting each letter
back by the same amount. For example, if the shift value is 3, the encrypted
message “khoor” would become “hello”.
Example 1:
Use the Caesar cipher to encrypt and decrypt the message
"JAVATPOINT," and the key (shift) value of this message is
3.
• En (x) = (x + n) mod 26

The encrypted message is "MDYDWSRLQW


JAVATPOINT and k= 3.
En (x) = (x + n) mod 26
Suppose we want to encode the secret
message: JOIN ME AT EIGHT BY THE
ZOO
• shift value S=2
• JOIN ME AT EIGHT BY THE ZOO
J O I N M E A T E I G H T B Y T H E Z O O

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
En (x) = (x + n) mod 26 k=2
J 9 + 2 mod 26 11 L B 1 + 2 mod 26 3 D
O 14+2 mod 26 16 Q Y 24 + 2 mod 26 0 A
I 8 +2 mod 26 10 K
N 13+2 mod 26 15 P T 19 +2 mod 26 21 V
H 7+2 mod 26 9 J
M 12+2 mod 26 14 O E 4+2 mod 26 6 G
E 4+2 mod 26 6 G
Z 25 + 2 mod 26 1 B
A 0+2 mod 26 2 C O 14+2 mod 26 16 Q
T 19 +2 mod 26 21 V O 14+2 mod 26 16 Q

E 4+2 mod 26 6 G
I 8+2 mod 26 10 K
G 6 +2 mod 26 8 I
H 7+2 mod 26 9 J
T 19+2 mod 26 21 V
Suppose we want to encode the secret
message/plaintext: Spy Coder
• shift value/key value S=5
• Spy Coder

Plaintext: S P Y C O D E R
Cipher text:
• shift value S=2
• JOIN ME AT EIGHT BY THE ZOO

J O I N M E A T E I G H T B Y T H E Z O O

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

J O I N M E A T E I G H T B Y T H E Z O O
Plaintext:
Cipher text: L Q K P O G C V G K I J V D A V J G B Q Q
En (x) = (x + n) mod 26 k=5

S 18 + 5 mod 26 23 X
P 15 + 5mod 26 20 U
Y 24 +5 mod 26 3 D

C 2 + 5 mod 26 7 H
O 14 + 5 mod 26 19 T
D 3+ 5 mod 26 8 I
E 4 + 5 mod 26 9 J
R 17 + 5 mod 26 22 W
Suppose we want to encode the secret
message: Spy Coder E (x) = (x + n) mod 26 k = 5
n

S 18 + 5 mod 26 23 X
• shift value S=5 P 15 + 5mod 26 20 U

• Spy Coder Y 24 +5 mod 26 3 D

Plaintext: S P Y C O D E R C 2 + 5 mod 26 7 H
Cipher text: X U D H T I J W O 14 + 5 mod 26 19 T
D 3+ 5 mod 26 8 I
E 4 + 5 mod 26 9 J
R 17 + 5 mod 26 22 W
Decryption
• Deciphering is done in reverse
• The formula of decryption is:
Dn (x) = (xi - n) mod 26
Decrypt: XUD HTIJW; shift value S=5

Dn (x) = (x - n) mod 26 k=5

X 23 - 5 mod 26 18 S

U 20 - 5mod 26 15 P

D 3 - 5 mod 26 24 Y

H 7 - 5 mod 26 2 C

T 19 - 5 mod 26 14 O

I 8 - 5 mod 26 3 D

J 9 - 5 mod 26 4 E

W 22 - 5 mod 26 17 R
Use the Caesar cipher to encrypt and decrypt the message
"HELLO," and the key (shift) value of this message is 15.

En (x) = (x + n) mod 26 k = 15 Dn (x) = (x - n) mod 26 k = 15

H 7 + 15 mod 26 22 W W 22 - 15 mod 26 7 H
E 4 + 15 mod 26 19 T T 19 -15 mod 26 4 E
L 11 + 15 mod 26 0 A A 0 - 15 mod 26 11 L
L 11 + 15 mod 26 0 A A 0 - 15 mod 26 11 L
O 14 + 15 mod 26 3 D D 3 - 15 mod 26 14 O
Cryptanalysis of Caesar Cipher
• only have 26 possible ciphers
• A maps to A,B,..Z
• could simply try each in turn
• a brute force search
• given ciphertext, just try all shifts of letters
• do need to recognize when have plaintext
• eg. break ciphertext "GCUA VQ DTGCM"
GCUA VQ DTGCM – decipher via brute force
1 FBTZ UP CSFBL 9 17 25

2 EASY TO BREAK 10 18 26

3 DZRX SN AQDZJ 11 19

4 CYQW RM ZPCYI 12 20

5 13 21

6 14 22

7 15 23

8 16 24
Vigenère Cipher
POLYALPHABETIC CIPHER
Polyalphabetic Ciphers
• It uses a simple form of polyalphabetic substitution.
• A polyalphabetic cipher is any cipher based on substitution, using
multiple substitution alphabets.

• The relationship between a character in the plaintext to a character


in the cipher text is one-to-many.

• The Vigenere key stream dose not depend on the plaintext characters.
It depends only on the position of the character in the plain text.
• Encryption
The plaintext(P) and key(K)
Ei = (Pi + Ki) mod 26

• Decryption
Di = (Ei - Ki) mod 26
Vigenère square or Vigenère table
Key: AYUSH
Plaintext: GEEKFORGEEKS
KEY A Y U S H A Y U S H A Y U
PLAINTEXT G E E K S F O R G E E K S
GCYCZFMLYLEIM G C Y C Z F M L Y L E I M

You might also like