Encryptionst
Encryptionst
001010010111001
100101001011001
001011100100101
1
Definitions - Crypto-speak
Cryptography is the study of secret (crypto-)
writing (-graphy)
Cryptography deals with all aspects of secure
messaging, authentication, digital signatures,
electronic money, and other applications
The practitioner of Cryptography is called
Cryptographer
2
Definitions
3
Why Cryptography?
Concerned with developing algorithms which
may be used to:
Conceal the context of some message from all
except the sender and recipient (privacy or secrecy),
and/or
Verify the correctness of a message to the recipient
(authentication)
Forms the basis of many technological solutions to
computer and communications security problems
4
Definitions
In cryptographic terminology, the message is called plaintext or
cleartext.
Encoding the contents of the message in such a way that hides its
contents from outsiders is called encryption.
A method of encryption and decryption is called a cipher - The
name cipher originates from the Hebrew word "Saphar," meaning
"to number.”
The encrypted message is called the ciphertext.
The process of retrieving the plaintext from the ciphertext is
called decryption.
Encryption and decryption usually make use of a key, and the
coding method is such that decryption can be performed only by
knowing the proper key.
5
Cryptography is
Mathematical
Encryption C = EK(P)
Decryption P = E -1(C)
K
E is chosen from a family of transformations
K
known as a cryptographic system.
The parameter that selects the individual
transformation is called the key K, selected
from a keyspace K
6
Cryptography is
Mathematical
A cryptographic system is a single parameter
family of invertible transformations
EK ; K in K : P C
with the inverse algorithm EK -1 ; K in K : C P
such that the inverse is unique
Usually we assume the cryptographic system is
public, and only the key is secret information
7
Cryptanalaysis
The study of principles and methods of
transforming an unintelligible message back
into an intelligible message without knowledge
of the key is called Cryptanalysis.
Also called “code breaking” sometimes.
Whereas people who do cryptography are
cryptographers, and practitioners of
cryptanalysis are cryptanalysts.
8
Cryptology
Cryptology is the branch of mathematics that
studies the mathematical foundations of
cryptographic methods.
Cryptology comes from the Greek words
Kryptos, meaning hidden, and Graphen,
meaning to write. Cryptology is actually the
study of codes and ciphers.
Cryptology = both cryptography and
cryptanalysis
9
Algorithm Secrecy
Some cryptographic methods rely on the secrecy
of the algorithms; such algorithms are only of
historical interest and are not adequate for real-
world needs.
Kerchoff’s Principle: If the strength of your
new cryptosystems relies on the fact that the
attacker does not know the algorithm's inner
workings , you are sunk.
Security through Obscurity Does Not
Work !!!
10
The Key
All modern algorithms use
a key to control encryption
and decryption; a message
can be decrypted only if
the key matches the
encryption key.
The key used for
decryption can be different
from the encryption key,
but for most algorithms
they are the same.
11
Encryption Algorithm Types
There are two classes of key-based algorithms:
Symmetric (or secret-key)
Asymmetric (or public-key) algorithms
The difference is that symmetric algorithms use the
same key for encryption and decryption (or the
decryption key is easily derived from the encryption
key), whereas asymmetric algorithms use a different
key for encryption and decryption, and the decryption
key cannot be derived from the encryption key.
12
Symmetric Algorithms
Symmetric algorithms can be divided into two
categories: (1) stream ciphers and (2) block
ciphers.
Stream ciphers can encrypt a single bit/byte of
plaintext at a time, whereas …
Block ciphers take a number of bits (typically
64 /128 bits in modern ciphers), and encrypt
them as a single unit.
13
Asymmetric Algorithms
Asymmetric ciphers (also called public-key
algorithms or generally public-key cryptography)
permit the encryption key to be public (it can
even be published in a newspaper), allowing
anyone to encrypt with the key, whereas only the
proper recipient (who knows the decryption key)
can decrypt the message.
The encryption key is also called the Public Key
and the decryption key the Private Key or Secret
Key.
14
Comparison of Symmetric
and Asymmetric Encryption
Secret Key
Original
Plaintext Ciphertext Plaintext
Encryption Decryption
Original
Plaintext Ciphertext Plaintext
Encryption Decryption
17
Symmetric Algorithms are
Faster
Generally, symmetric algorithms are much
faster to execute on a computer than
asymmetric ones.
In practice they are often used together, so that
a public-key algorithm is used to encrypt a
randomly generated encryption key, and the
random key is used to encrypt the actual
message using a symmetric algorithm.
18
Encryption Algorithms vs.
Other Encoding Algorithms
Encryption vs. Error Detection/Correction.
Encryption vs. Compression.
19
History - Caesar Cipher
Julius Caesar used a simple alphabet (letter) substitution,
offset by 3 letters.
Taking the word “cipher" you would move ahead in the
alphabet 3 letters to get “FLSKHU”.
c = 3 3+3 = 6 F
i = 9 9+3 = 12 L
p = 16 16+3 = 19 S
h = 8 8+3 = 11 K
e = 5 5+3 = 8 H
r = 18 18+3 = 21 U
This worked for a while, until more people learned to read
and studied his secret cipher.
20
Concealment Messages
Some of the more fun secret writings are
concealment messages like invisible inks made
out of potato juice, lemon juice, and other types
of juices and sugars!
Deciphering and decoding messages take a lot
of time and be very frustrating. But with
experience, strategies, and most of all, luck,
you'll be able to crack lots of codes and ciphers.
21
Cryptography vs.
Steganography
What is steganography?
In an ideal world we would all be able to openly send
encrypted email or files to each other with no fear of
reprisals. However there are often cases when this is
not possible, either because you are working for a
company that does not allow encrypted email or
perhaps the local government does not approve of
encrypted communication (a reality in some parts of
the world). This is where steganography can come into
play.
22
Classical Cryptographic
Techniques
Three Eras of Cryptography:
Classical
Traditional
Modern
We have two basic components of classical
ciphers: substitution and transposition.
Substitution: In substitution ciphers letters are
replaced by other letters.
Transposition: In transposition ciphers the
letters are arranged in a different order.
23
Monoalphabetic and
Polyalphabetic Ciphers
Monoalphabetic - only one substitution/
transposition is used.
Polyalphabetic - where several substitutions/
transpositions are used.
Several such ciphers may be concatenated
together to form a Product Cipher.
24
Caesar Cipher - A Monoalphabetic
Substitution Cipher
Replace each letter of message by a letter a fixed distance
away e.g. use the 3rd letter on
Reputedly used by Julius Caesar, e.g.
L FDPH L VDZ L FRQTXHUHG
I CAME I SAW I CONQUERED
i.e. mapping is
ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
Can describe this cipher as:
Encryption Ek : i i + k mod 26
Decryption Dk : i i - k mod 26
25
Caesar Cipher Key
26
A Simple (mono)
Substitution Cipher
Plaintext:
abcdefghijklmnopqrstuvwxyz
QIAYMWFUBKPDGJZSOCVLXNETRH
Ciphertext:
27
Frequency-based
Cryptanalytic Attacks
Cryptanalyst knows the letter-frequency
distribution of the language.
Cryptanalyst constructs the letter frequency
table of the cipher-text.
Cryptanalyst tries to find letter pairs with the
same frequency distribution in the plain text and
cipher text.
Also uses the frequencies of digrams and tri-
grams.
Finally a little bit of trial and error.
28
Frequency Distribution of
Letters in Standard English
A 8.167 J 0.153 S 6.327
B 1.492 K 0.772 T 9.056
C 2.782 L 4.025 U 2.758
D 4.253 M 2.406 V 0.978
E 12.702 N 6.749 W 2.360
F 2.228 O 7.507 X 0.150
G 2.015 P 1.929 Y 1.974
H 6.094 Q 0.095 Z 0.074
I 6.966 R 5.987
29
Polyalphabetic Substitution
Cipher
Polyalphabetic Substitution - several
substitutions are used.
Used to hide the statistics of the plain-text.
30
Polyalphabetic
Substitution Example
Suppose that a polyalphabetic cipher of period 3 is being used, with the three
monoalphabetic ciphers M1, M2, M3 as defined below. To encrypt a message, the
first 3 letters of the plaintext are enciphered according to ciphers M1, M2, M3
respectively, with the process being repeated for each subsequent block of 3 plaintext
letters.
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
M1: K D N H P A W X C Z I M Q J B Y E T U G V R F O S L
M2: P A G U K H J B Y D S O E M Q N W F Z I T C V L X R
M3: J M F Z R N L D O W G I A K E S U C Q V H Y X T P B
Plaintext
now is the time for every good man
Ciphertext
JQX CZ VXK VCER AQC PCRTX LBQZ QPK
Note:
The two o’s in good have been enciphered as different letters. Also the three letters
“X” in the ciphertext represent different letters in the plaintext. 31
Transposition Ciphers
Transposition or permutation ciphers hide the
message contents by rearranging the order of
the letters.
Scytale Cipher is an example of a transposition
cipher.
How does a cryptanalyst know that a
transposition cipher has been used?
Single transposition vs. double transposition
32
Transposition Cipher
Example (1)
Key
M E G A B U C K
Weights to be used for double transposition
7 4 5 1 2 8 3 6
p l e a s e t r Plaintext
a n s f e r o n Please transfer one million dollars to my
e m i l l i o n swiss bank account six two two
d o l l a r s t
o m y s w i s s Ciphertext
b a n k a c c o AFLLSKSO SELAWAIA TOOSSCTC
LNMOMANT
u n t s i x t w
ESILYNTWRNNTSOWDPAEDOBUOERI
o t w o a b c d RICXB 33
Transposition Cipher
Example (2)
Key S H O E S
Weights to be used for double transposition 1 3 5 4 2
p a y m e
Plaintext
b y s u n
paymebysundayorsuffertheconsequences
d a y o r
s u f f e
Ciphertext r t h e c
o n s e q
PBDSROUSENRECQEZAYAUTNE
ZMUOFEECZYSYFHSNZ u e n c e
s z z z z
34
Types of Encryption
Systems
There are two types of encryption algorithms:
Symmetric or Private Key systems
Asymmetric or Public Key systems
35
Symmetric or Private Key
Systems
A Private-Key (or secret-key, or single-key)
encryption algorithm is one where the sender and the
recipient share a common, or closely related, key.
“Symmetric” means it uses the same key for
encryption as for decryption. As with all symmetric
ciphers, the sender must transmit the key to the
recipient via some secure and tamperproof channel,
otherwise the recipient won’t be able to decrypt the
ciphertext.
All traditional encryption algorithms are private-key.
36
One Time Pad - OTP
A one-time pad is a very simple yet completely
unbreakable symmetric cipher.
A one-time pad involves sheets of paper with random
numbers on them: These numbers are used to transform
the message; each number or sequence of numbers is
used only once.
The recipient of the message has an identical pad to use
to decrypt the message. One-time pads have been proven
to be foolproof-without having a copy of the pad.
Supposedly, mathematicians can prove that a one-time
pad is impossible to break.
37
What is a One-Time Pad?
The key for a one-time pad cipher is a string of
random bits, usually generated by a cryptographically
strong pseudo-random number generator (CSPRNG).
It is better to generate the key using the natural
randomness of quantum mechanical events (such as
those detected by a Geiger counter), since quantum
events are believed by many to be the only source of
truly random information in the universe.
One-time pads that use CSPRNGs are open to attacks
which attempt to compute part or all of the key.
38
What is a One-Time Pad?
With a one-time pad, there are as many bits in
the key as in the plaintext.
This is the primary drawback of a one-time pad,
but it is also the source of its perfect security.
It is essential that no portion of the key ever be
reused for another encryption (hence the name
"one-time pad"), otherwise cryptanalysis can
break the cipher.
39
One Time Pad Algorithm
The cipher itself is exceedingly
simple. To encrypt plaintext, P, with a
key, K, producing ciphertext, C,
simply compute the bitwise exclusive-
or of the key and the plaintext:
C = K XOR P
P
To decrypt ciphertext, C, the recipient
+ C
computes
P = K XOR C K
It's that simple, and it’s perfectly
secure, as long as the key is random C + P
and is not compromised.
K
40
Why are One-Time Pads
Perfectly Secure?
If the key is truly random, an xor-based one-
time pad is perfectly secure against ciphertext-
only cryptanalysis.
This means an attacker can’t compute the
plaintext from the ciphertext without
knowledge of the key, even via a brute force
search of the space of all keys!
Trying all possible keys doesn't help you at all,
because all possible plaintexts are equally
likely decryptions of the ciphertext.
41