Practical Cryptography (Introduction To Cryptography)
Practical Cryptography (Introduction To Cryptography)
(Introduction to Cryptography)
Kasun De Zoysa
1
Definitions
• Cryptography
– Art or science of secret writing
– Protects sensitive information from disclosure
– Storing and transmitting information in a form that allows it to be revealed
only to those intended
– Cryptosystem accomplishes this
– Identifies the corruption or unauthorized change of information
– Designed to make compromise too expensive or too time-consuming
• Cryptanalysis
– art/science relating to converting ciphertext to plaintext without the
(secret) key
• Cryptology
– Includes both cryptography and cryptanalysis
2
Objectives - Cryptography
3
What You Should Know
• Basic concepts and terms within
cryptography
– Public and private key algorithms in terms of
their applications and uses
– Cryptography algorithm construction, key
distribution, key management, and methods of
attack
– Applications, construction, and use of digital
signatures
– Principles of authenticity of electronic
transactions and non-repudiation
4
Basic Concept
Decipher
Encipher
Cipher Algorithm
Cipher Algorithm
Plain Text
Cypher Text
Plain Text
Encrypted Data
5
Definitions , continued
• Encipher
– act of scrambling
• Decipher
– descrambling with secret key
• Key
– secret sequence governing en/deciphering
6
Cryptography Basic
• Why Encrypt?
– Protect stored information
– Protect information in transmission
• Cryptography originally used for secrecy
• Encryption - process by which plaintext
is converted to ciphertext using a key
• Decryption - process by which ciphertext
is converted to plaintext (with the
appropriate key)
• plaintext (cleartext)- intelligible data
7
Cryptography Basics
• Kerckhoffs' principle (19th century) a cryptosystem should be
secure even if everything about the system, except the key, is
public knowledge.
(Opposite of “security through obscurity”)
• Symmetric Key Encryption Scheme
– Each of the parties involved has to know the secret key
9
The goal of a cryptosystem
The goal of a cryptosystem is to provide
10
Cryptography History
Historic examples...
Earliest cryptography: an Egyptian scribe using non-
standard hieroglyphics
Julius Caesar (“Caesar Cipher”)
Each plaintext letter is replaced by a letter some fixed
number of positions further down the alphabet
The Kama Sutra recommends cryptography as 44th
and 45th art
(of 64) men and women should know
One-Time Pad (OTP) first described by Frank Miller in
1882 and Gilbert Vernam for the XOR operation in
1917.
11
Cryptography History
12
Hieroglyphs
The earliest known use of
cryptography is found in non-
standard hieroglyphs carved
into the wall of a tomb from the
Old Kingdom of Egypt circa
1900 BC.
These are not thought to be
serious attempts at secret
communications, however, but
rather to have been attempts
at mystery, intrigue, or even
amusement for literate
onlookers [Wikipedia]. 13
The Caesar Cipher
Ci = E(Pi)= Pi+3
14
Kamasutra
One of the earliest descriptions of encryption by
substitution appears in the Kama-sutra, a text written in
the 4th century AD by the Brahmin scholar Vatsyayana,
but based on manuscripts dating back to the 4th
century BC.
How it work
The kamasutra generate list of 26 alphabet with no
duplicate. Then divide by 2 row. Find for each letter of
message text in table and choose the opposite of the
letter
15
kamasutra
for example:
Key = G H A J R I O B E S Q C L F V Z T Y K M X W N U D P
divide by 2 rows
G H A J R I OB E S Q C L
F V Z TY KMX WN U D P
Cipher : IZOZNQJYZ
16
Monoalphabetic Substitutions
Plain Text :ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher Text : K E Y G H I J K L M N O P Q R S T U V W X Y Z A B C
Letter Frequency
17
Polyalalphabetic Substitutions
18
One Time Pad / Vernam Cipher
• Invented in 1917 by Gilbert Vernam and Joseph Mauborgne.
• Usually implemented as a stream cipher using the XOR
function.
• Key is used once and discarded by both sender and receiver.
• Length of the Key character stream is equal to the message
length.
• Not practical for large amounts of data (MB / GB).
• Pad is theoretically unbreakable by exhaustive brute force.
• Implementation uses a Key that consists of a set of random
• non-repeating characters.
• Each Key letter and Plaintext are added modulo 26 to each
other and then converted back into a letter.
19
One - Time Pad
20
One Time Pad / Vernam Cipher
Plain Text :V E R NA M C I P H E R
Numeric Equivalent : 21 4 17 13 0 12 2 8 15 7 4 17
+Random Number : 76 48 16 82 44 3 58 11 60 5 48 88
= Sum : 97 52 33 95 44 15 60 19 75 12 52 105
=Mod 26 : 19 0 7 17 18 15 8 19 23 12 0 1
Cipher text : t a h r s p I t x m a b
+ Random Stream : 0 1 0 1 1 0 1 0 1 1 1 0 1 0 1
Cipher text :111110010111000
21
Random Numbers
1. Truly Random numbers
•Books
•CD
22
Columnar Transposition Cipher
Plain tex = Geeks for Geeks Length of Key = 4 (no of rows)
Key = HACK Order of Alphabets in HACK = 3124
24
Stream Cipher
Key (Optional)
ISSOPMI WEHTUA..
Y
Plain text Cipher text
Cipher
Advantage
•Speed of transformation
Cipher text(F)
•Low error propagation Plain text (A)
Disadvantage
•Low diffusion
•Susceptibility to malicious insertion and modifications
25
Block Cipher
XN
OI BA
TP QC
YR Key (Optional) KD
CN EM
ES MC
Y
Disadvantage Plain text Cipher text
Cipher
•Slowness of encryption
•Error propagation
Cipher text(FRWSU)
Advantage
Plain text (AKEDF)
•Diffusion
•Immunity to insertion
26
Block vs Stream Ciphers
•Block ciphers process messages in blocks, each of which
is then en/decrypted
•Like a substitution on blocks of characters
•64-bits or more
27
Secrecy Requirements
• If ciphertext and plaintext are known, it should
be computationally infeasible to determine the
deciphering algorithm
• It should be computationally infeasible to
systematically determine plaintext from
intercepted ciphertext (Even if you decrypt
ciphertext once, it should require the same
amount of work to do it again.)
• Note: “systematically” allows for a lucky
guess
• Note: “Computationally infeasible” means
great effort, doesn’t account for advances in
computing, mathematics
28
Characteristic
Characteristic of
of “Good”
“Good” Cipher
Cipher -- Shannon
Shannon
Characteristics
Characteristics -- 1949
1949
29
Kerckhoff’s
Kerckhoff’s Principle
Principle
Reasons:
•Algorithms are difficult to change
•Cannot design an algorithm for every pair of users
•Expert review
•No security through obscurity!
30
Confusion
Confusion and
and Diffusion
Diffusion
31
Confusion
Confusion
Confusion
The interceptor should not be able to
predict what changing one character in
the plaintext will do to the ciphertext
Plaintext
Ciphertext
32
Diffusion
Diffusion
Diffusion
The characteristics of distributing the
information from single plaintext letter
over the entire ciphertext
Plaintext
KASUN
ANHYJ
Ciphertext
33
Information
Information Theoretic
Theoretic Tests
Tests
34
Redundancy
Redundancy
Meaningless messages
P1 C1
P2
Meaningful message P3
P4
P5
35
What
What the
the Cryptanalyst
Cryptanalyst Has
Has to
to Work
Work With
With
•Ciphertext only
•Full or partial plaintext
•Ciphertext of any plain text
•Algorithm of ciphertext
36
Types
Types of
of Cryptanalytic
Cryptanalytic Attacks
Attacks
Ciphertext only
only knows encryption algorithm and ciphertext, goal is to
identify plaintext
Known plaintext
know encryption algorithm and one or more plaintext &
ciphertext pairs formed with the secret key
37
Types
Types of
of Cryptanalytic
Cryptanalytic Attacks
Attacks
Chosen ciphertext
know encryption algorithm and can select ciphertext and
obtain
plaintext to attack cipher
Chosen text
know encryption algorithm and can select either plaintext or
ciphertext to en/decrypt to attack cipher
38
Brute
Brute Force
Force Search
Search
•Always possible to simply try every key
•Most basic attack, proportional to key size
•Assume either know/recognize plaintext
http://password-checker.online-domain-tools.com/ 39
Unconditional/Computational
Unconditional/Computational Security
Security
Unconditional security
no matter how much computer power is
available, the cipher cannot be broken since the
ciphertext provides insufficient information to
uniquely determine the corresponding plaintext
Computational security
given limited computing resources (e.g. time
needed for calculations is greater than age of
universe), the cipher cannot be broken
40
Books
42