Systems and Networks Security: 3-Basics of Cryptography
Systems and Networks Security: 3-Basics of Cryptography
0405702
3- Basics of Cryptography
It is used for:
– Conceal messages from unauthorized persons (secrecy +
privacy)
– Verify correctness of message (authentication)
– Authenticate to other party
It form the basis to many security communication concerns
2
Basic Cryptography Terminology
plaintext - the original message
ciphertext - the coded message
cipher - algorithm for transforming plaintext to ciphertext
key - info used in cipher known only to sender/receiver
encipher (encrypt) - converting plaintext to ciphertext
decipher (decrypt) - recovering ciphertext from plaintext
cryptography - study of encryption principles/methods
cryptanalysis (codebreaking) - the study of principles/
methods of deciphering ciphertext without knowing key
cryptology - the field of both cryptography and
cryptanalysis 3
Cryptography
Can be characterize by:
– Type of encryption operations used
• substitution / transposition / product
– Number of keys used
• single-key or private / two-key or public
– Way in which plaintext is processed
• block / stream
4
Classical Cryptography
6
Caesar Cipher
8
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
e.g. break ciphertext "GCUA VQ DTGCM"
9
Playfair Cipher
11
MON A R
Encrypting and Decrypting CHY B D
E F GI K
plaintext encrypted two letters at a time: L P QS T
1. if a pair is a repeated letter, insert a filler like 'X', U V WX Z
e.g. "balloon" encrypts as "ba lx lo on“
2. if both letters fall in the same row, replace each with letter
to right (wrapping back to start from end e.g. “ar"
encrypts as "RM"
3. if both letters fall in the same column, replace each with
the letter below it (again wrapping to top from bottom),
eg. “mu" encrypts to "CM"
4. otherwise each letter is replaced by the one in its row in
the column of the other letter of the pair, e.g. “hs"
encrypts to "BP", and “ea" to "IM" or "JM" (as desired)
12
Security of the Playfair Cipher
security much improved over monoalphabetic
since have 26 x 26 = 676 digrams
would need a 676 entry frequency table to analyse
(verses 26 for a monoalphabetic)
and correspondingly more ciphertext
was widely used for many years (e.g. US &
British military in WW1)
it can be broken, given a few hundred letters
since still has much of plaintext structure
13
Vigenère Cipher
A method of encrypting text by using a series of different
caesar ciphers
simplest polyalphabetic substitution cipher
1’st described in 1553
effectively multiple caesar ciphers
key is multiple letters long K = k 1 k2 … kd
ith letter specifies ith alphabet to use
use each alphabet in turn
repeat from start after d letters in message
decryption simply works in reverse
14
Vigenère Cipher
To encrypt ; a table of alphabets can be used “ a
tabula recta ” or “Vigenere square” or “
Vigenere table”.
This table consists of the alphabet written out 26-
times in different rows
Each alphabet is shifted cyclically to the left
compared to the previous alphabet, corresponding
to the 26 possible caeser ciphers.
At different points in the encryption process; the
cipher uses a different alphabet from one of the
rows, the alphabet used at each point depends on a
repeating keyword. 15
Tabula Recta
16
Encryption / Decryption
17
Example
write the plaintext out
write the keyword repeated above it
use each key letter as a caeser cipher key
encrypt the corresponding plaintext letter
e.g. using keyword deceptive
To encrypt: the first letter of the PT is encrypted using the alphabet in
row d
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
18
One-Time Pad
It is nothing more than a large non-repeating set of truly random
keys letters written on a sheet of papers and glued together in a
pad.
Originally it was made for teletypewriters
The sender uses each key letter on the pad to encrypt exactly on
plaintext character.
Each key letter is used exactly once for only one message
The sender encrypt the message and then destroyes the used
pages of the pad.
The receiver has an identical pad and uses each key on the pad
then destroys it
The length of the key sequence must be equal to the message
length (new message means new key letters )
The key letters are generated randomely 19
One-Time Pad
Perfect Secrecy!
Used in 1917
Large, non-repeating set of keys
can only use the key once
have problem of safe distribution of key
if a truly random key as long as the message is used, the
cipher will be secure
is unbreakable since ciphertext bears no statistical
relationship to the plaintext
since for any plaintext & any ciphertext there exists a key
mapping one to other
20
One-Time Pad
21
Encryption / Decryption
22
Example
key: TBFRGFARFM
plaintext: O N E T I M E P A D
ciphertext: I P K L P S F H G Q
a b c d e f g h i j k l m n o p q r s t
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
u v w x y z
20 21 22 23 24 25
23
Transposition Ciphers
now consider classical transposition or
permutation ciphers
Here, the plaintext remains the same, but
the order of characters is shuffled around.
these hide the message by rearranging the
letter order
without altering the actual letters used
can recognise these since have the same
frequency distribution as the original text 24
Transposition Cipher
In a simple columnar transposition cipher: the plaintext is written
horizontally onto a piece of graph of paper of a fixed width and the cipher
text is read off vertically
Letters of the message are rearranged
Break patterns, e.g., columnar transposition
Plaintext: this is a test
this
isat tiehssiatst!
est!
Advantages: easy to implement
Disadvantages:
Trivially broken for known plaintext attack
Easily broken for cipher only attack
25
Double Transposition
Two columnar transposition with different
number of columns
– First transposition: breaks up adjacent letters
– Second transposition.: breaks up short patterns
26
Row Transposition Ciphers
a more complex scheme
write letters of message out in rows over a specified number
of columns
then reorder the columns according to some key before
reading off the columns
Key: 3 4 2 1 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
27
Product Ciphers
ciphers using substitutions or transpositions are
not secure because of language characteristics
hence consider using several ciphers in succession
to make harder, but:
– two substitutions make a more complex
substitution
– two transpositions make more complex
transposition
– but a substitution followed by a transposition
makes a new much harder cipher
this is bridge from classical to modern ciphers 28
Encryption Systems Categories:
Symmetric encryption.
Asymmetric encryption.
29
Symmetric Encryption
In a symmetric encryption system, both the sender and receiver must
possess the same key value. The sender encrypts the plaintext message
using the key and the receiver decrypts the cipher-text message using the
same secret key.
The word “symmetric" here means that the same key is used for
encryption and decryption.
Symmetric algorithms
Encryption and decryption is performed using a unique key
Both Tx. and Rx. agree to use the same secret key
The key may have an expiration date for containment of damage.
Key agreement/distribution is a problem
30
Symmetric Encryption
31
Conventional (Secret Key) Cryptosystem
K
C=E(K,M) K needs
M=D(K,C) secure channel
32
Symmetric Cryptosystem: Encryption/Decryption function
Main Properties
– Given plaintext and a key, it is computationally efficient to compute the
ciphertext.
– Given ciphertext and a key, it is computationally efficient to compute the
plaintext.
– But, given ciphertext, it is computationally infeasible to compute the plaintext.
– Keys are secret, but algorithms are public
• Any algorithm is hard to keep secret if used widely
– Reverse engineering
• Public examination helps to find flaws
• Military keeps algorithms secret is to avoid giving enemy good ideas 33
Requirements
two requirements for secure use of symmetric
encryption:
– a strong encryption algorithm
– a secret key known only to sender / receiver
Y = EK(X) and X = DK(Y)
– X = DK(EK(X))
assume encryption algorithm is known
need secure channel to distribute key
34
Symmetric Encryption
The weaknesses:
How you securely distribute the key to the needed
parties
35
Inherent Weaknesses of Symmetric Cryptography
36
Symmetric Encryption
Two classes of symmetric-key encryption algorithms:
37
Steam Ciphers
Convert one symbol of plain text into a symbol of
ciphertext based on the symbol (plain), key, and algorithm
Advantages:
– Speed of transformation
– Low error propagation
Disadvantages:
– Low diffusion
– Vulnerable to malicious insertion and modification
38
Block Ciphers
Encrypt a group of plaintext as one block
and produces a block of ciphertext
Advantages:
– Diffusion
– Immunity to insertions
Disadvantages:
– Slowness of encryption
– Error propagation
39
Examples of Symmetric Encryption Algorithms
Examples of Block:
– DES is a block cipher with a 64 bit block size.
– AES is a block cipher with a 128 bit block size.
– RSA and Diffie-Hellman are block ciphers with variable block
sizes.
Examples of Stream:
– A5, the algorithm used to encrypt GSM communications, is a
stream cipher.
– The RC4 cipher and the one-time pad are also stream ciphers.
40
Stream Ciphers
C = P K, where is XOR Operation.
C K = (P K) K = P ( K K) = P 0 = P
0 1
0 0 1
1 1 0
41
Stream Ciphers
C = P K, where is XOR Operation.
C K = (P K) K = P ( K K) = P 0 = P
Plaintext 1 0 1 1 0 1 1 0 0
Key 1 1 0 1 0 0 0 1 1
Cipher 0 1 1 0 0 1 1 1 1
42
Asymmetric Encryption
Known as "public key" encryption, each entity participating in the
communication uses mathematical algorithms implemented in a software
program to generate a "public key" and a "private key" which are related via
the mathematical formulae. The private key must be kept secret and is never
disclosed; this is a requirement for the security system to function. The public
key, however, is intended to be freely distributed.
Public-key algorithm
The encryption key is different of the decryption key.
A private (secret) key is used either for encryption or decryption, but not
both.
A public key is used for the opposite operation.
Alison still has to deliver her public key to Bob, which has to deliver his
public key to Alison!
43
Asymmetric Encryption:
44
Public Key Cryptosystem
46
Symmetric-key
vs.
Public-key cryptography
47
Advantages of symmetric-key
Have high rates of data throughput .
Keys for symmetric-key ciphers are
relatively short.
Symmetric-key ciphers can be composed to
produce stronger ciphers.
48
Disadvantages of symmetric-key
49
Advantages of Public-key
Only the private key must be kept secret.
Depending on the mode of usage, a private
key/public key pair may remain unchanged for
considerable periods of time.
Many public-key schemes yield relatively
efficient digital signature mechanisms.
50
Disadvantages of Public-key
Slower than the best known symmetric-key
schemes.
Key sizes are typically much larger.
No public-key scheme has been proven to be
secure.
51
What makes a good cryptosystem?
52
Basic Encryption Techniques
Substitution (confusion)
Permutation (diffusion)
Combinations and iterations of these
53
Confusion & Diffusion
Pixels confusion: means re-arranging the original image pixels
locations; this step has the aim of reducing the high degree of
correlation between the neighboring pixels
Diffusion: refers to changing the values of pixels of the image
by performing some transformations on the pixels values due to
the fact that sole confusion will not be enough and any inverse
process that will return the pixels to their original locations will
declare the original image, therefore, giving the pixels new
values will strengthen the encryption operation and cancel the
correlation between pixel resulting in an encrypted image with a
uniform histogram.
54
Brute Force Search
Always possible to simply try every key
Most basic attack, proportional to key size
Assume either know / recognise plaintext
Key Size Number of Time required at 1 Time required at 106
(bits) Alternative Keys decryption/µs decryptions/µs
32 232 = 4.3 109 231 µs = 35.8 2.15 milliseconds
minutes
56 256 = 7.2 1016 255 µs = 1142 years 10.01 hours
128 2128 = 3.4 1038 2127 µs = 5.4 1024 5.4 1018 years
years
168 2168 = 3.7 1050 2167 µs = 5.9 1036 5.9 1030 years
years
26 characters 26! = 4 1026 2 1026 µs = 6.4 1012 6.4 106 years
55
(permutation) years
Block Ciphers: DES
Block Cipher: divide a message into blocks, each block is then en/decrypted
– DES
– AES
DES (Data Encryption Standard): published by NIST (IBM) in 1977
– Block size: 64 bits
– Key size: 56 bits
• 56 bits is ok in 1977, 64 bits is ok in 1995, 128 bits is ok until 2123
– Fast in hardware, slow in software (9 Mbps on Pentium II)
– Has been proven to be insecure in 1998
• EFF (Electronic Frontier Foundation) built a machine that can break DES in 5 days
• Faster to break using chosen plaintext attacks
– But Triple DES is secure (256 times more difficult than breaking DES
• Key size: 56*3=168 bits
• Underlying algorithm is the same
• No effective analytic attacks
• Drawbacks
– Performance: no efficient software codes for DES/3DES
– Efficiency/security: bigger block size desirable
56
Block Ciphers: AES
AES (Advanced Encryption Standard): published by NIST in 2001
– NIST issued call for ciphers in 1997, Rijndael was selected as the AES in
2000
– Block size: 128 bits
– Key size: 128, 192, or 256 bits
– Stronger & faster than Triple-DES
– Provide full specification & design details
– Free to use!
– Evaluation criteria
• Security: effort to practically cryptanalysis
• Cost: computational efficiency and memory requirement
• Algorithm & implementation characteristics: flexibility to apps,
hardware/software suitability, simplicity
57
Stream Cipher
59
Information Hiding
Greek Words:
STEGANOS – “Covered”
GRAPHIE – “Writing”
Stegosaurus: a covered lizard
(but not a type of cryptography)
Implement OP 005 @
1423.
62
Digital Watermarking
64
Digital Steganogaphy & Watermarking
Digital watermarking hides data in a file, and
the act of hiding data makes it a form or
steganography
The key difference is their goals...
– Steganography: hiding information
– Watermarking: extending the file with extra
information
Steganographic information must never be
apparent to a viewer unaware of its presence.
Network Security and Steganography
68
Types of Digital Steganography
Histiaeus, who shaved the head of his most trusted slave and tattooed a message on it. After his
hair had grown the message was hidden. The purpose was to instigate a revolt against the
Persians.
Some techniques:
– Character marking: selected letter of printed or typewritten text are
overwritten in pencil
– Invisible ink
– Pin punctures: small pin punctures are only shown if paper is hold
against a light source
– Typewriter correction ribbon: used between lines of normal black
ribbon. Only visible under strong light.
Modern Steganography Techniques
Masking and Filtering: Is where information is hidden inside of a image using
digital watermarks that include information such as copyright, ownership, or
licenses. The purpose is different from traditional steganography since it is
adding an attribute to the cover image thus extending the amount of
information presented.
Least Significant Bit Insertion: The most common and popular method of modern
day steganography is to make use of the LSB of a picture’s pixel information.
Thus the overall image distortion is kept to a minimum while the message is
spaced out over the pixels in the images. This technique works best when the
image file is larger then the message file and if the image is grayscale.
Basics of Modern Steganography
Watermarking:
– Communication in watermarking is the host signal, with the embedded data
providing copyright protection.
– The existence of a watermark is often declared openly.
– Any attempt to remove or invalidate the embedded content renders the host
useless.
Cryptography:
– Doesn’t conceal the communication.
– Scrambles the data to prevent eavesdroppers understanding the content.
– Cryptography involves various methods and implementations.
– May be considered complementary and orthogonal (unrelated).
http://mozaiq.org/