Understanding Cryptography - Part1
Understanding Cryptography - Part1
Peter Gutmann
University of Auckland
http://www.cs.auckland.ac.nz/~pgut001
Security Requirements
Confidentiality
Protection from disclosure to unauthorised persons
Integrity
Maintaining data consistency
Authentication
Assurance of identity of person or originator of data
Non-repudiation
Originator of communications cant deny it later
Access control
Unauthorised users are kept out
Security Threats
Information disclosure/information leakage
Integrity violation
Masquerading
Denial of service
Illegitimate use
Generic threat: Backdoors, trojan horses, insider attacks
Most Internet security problems are access control or
authentication ones
Denial of service is also popular, but mostly an annoyance
Attack Types
Security Services
From the OSI definition:
Access control: Protects against unauthorised use
Authentication: Provides assurance of someone's identity
Confidentiality: Protects against disclosure to unauthorised
identities
Integrity: Protects from unauthorised data alteration
Non-repudiation: Protects against originator of
communications later denying it
Security Mechanisms
Three basic building blocks are used:
Encryption is used to provide confidentiality, can provide
authentication and integrity protection
Digital signatures are used to provide authentication, integrity
protection, and non-repudiation
Checksums/hash algorithms are used to provide integrity
protection, can provide authentication
Conventional Encryption
Uses a shared key
Public-key Encryption
Uses matched public/private key pairs
Anyone can encrypt with the public key, only one person
can decrypt with the private key
Key Agreement
Allows two parties to agree on a shared key
Hash Functions
Creates a unique fingerprint for a message
Anyone can alter the data and calculate a new hash value
Hash has to be protected in some way
MACs
Message Authentication Code, adds a password/key to a
hash
Digital Signatures
Combines a hash with a digital signature algorithm
Message/Data Encryption
Combines conventional and public-key encryption
Historical Ciphers
Nonstandard hieroglyphics, 1900BC
Atbash cipher (Old Testament, reversed Hebrew alphabet,
600BC)
Caesar cipher:
letter = letter + 3
fish ilvk
rot13: Add 13/swap alphabet halves
Usenet convention used to hide possibly offensive jokes
Applying it twice restores original text
Substitution Ciphers
Simple substitution cipher:
a = p, b = m, c = f, ...
s
18
e
5
c
r
3 17
+15
1 12 19
7 13
g m
4
d
e
t
5 19
5
3 24 24
c x x
Simple substitution
"
" "
Stream Ciphers
Binary pad (keystream), use XOR instead of addition
Plaintext = original, unencrypted data
Ciphertext = encrypted data
Plaintext
1
Keystream XOR 0
Ciphertext
1
Keystream XOR 0
Plaintext
1
0
1
1
1
0
0
0
0
0
0
1
1
0
1
1
0
1
1
1
0
1
0
1
0
1
1
1
0
1
1
RC4
Stream cipher optimised for fast software implementation
2048-bit key, 8-bit output
Former trade secret of RSADSI, reverse-engineered and
posted to the net in 1994
while( length-- )
{
x++; sx = state[ x ]; y += sx;
sy = state[ y ]; state[ y ] = sx; state[ x ] = sy;
*data++ ^= state[ ( sx+sy ) & 0xFF ];
}
RC4 (ctd)
Extremely fast
Used in SSL (Netscape, MSIE), Lotus Notes, Windows
password encryption, MS Access, Adobe Acrobat, MS
PPTP, Oracle Secure SQL, ...
Usually used in a manner which allows the keystream to be
recovered (Windows password encryption, early
Netscape server key encryption, some MS
server/browser key encryption, MS PPTP, Access, ...)
Illustrates the problem of treating a cipher as a magic black
box
Recommendation: Avoid this, its too easy to get wrong
Block Ciphers
Originated with early 1970s IBM effort to develop
banking security systems
First result was Lucifer, most common variant has 128-bit
key and block size
It wasnt secure in any of its variants
Linear cryptanalysis
Looks for correlations between key and cipher input and output
Related-key cryptanalysis
Looks for correlations between key changes and cipher
input/output
Strength of DES
Key size = 56 bits
Brute force = 255 attempts
Differential cryptanalysis = 247 attempts
Linear cryptanalysis = 243 attempts
(but the last two are impractical)
> 56 bit keys dont make it any stronger
> 16 rounds dont make it any stronger
Breaking DES
DES was designed for efficiency in early-70s hardware
Makes it easy to build pipelined brute-force breakers in
late-90s hardware
Budget Tool
Pedestrian
hacker
Tiny
$400
PC
FPGA
Small
business
Corporate
department
$10K
FPGA
$300K
FPGA
ASIC
Big
company
$10M
FPGA
ASIC
Keylen (bits)
for security
40 bits
56 bits
1995
1 week Infeasible
45
5 hours
38 years
50
$0.08
$5,000
55
12 mins 556 days
$5,000
$0.08
19 days
24 secs
60
$0.08
$5,000
0.18 secs 3 hours
$0.001
$38
0.7 secs 13 hours
70
$0.08
$5,000
0.005 s
6 mins
$0.001
$38
0.0002 s
12 secs
75
$0.001
$38
2015
59
64
69
74
84
89
RC2
Companion to RC4, 1024 bit key
RSADSI trade secret, reverse-engineered and posted to the net
in 1996
RC2 and RC4 have special status for US exportability
Blowfish
Optimised for high-speed execution on 32-bit processors
448 bit key, relatively slow key setup
CAST-128
Used in PGP 5.x, 128 bit key
GOST
GOST 28147, Russian answer to DES
32 rounds, 256 bit key
Incompletely specified
Relative Performance
Fast
RC4
Blowfish, CAST-128, AES
Skipjack
DES, IDEA, RC2
3DES, GOST
Slow
Typical speeds
RC4 = Tens of MB/second
3DES = MB/second
Recommendations
For performance, use Blowfish
For job security, use 3DES
Example: RSA
n, e = public key, n = product of two primes p and q
d = private key
Encryption: C = Me mod n
Decryption: M = Cd mod n
p, q = 5, 7
n=pq
= 35
e=3
d = e-1 mod ((p-1)(q-1))
= 16
Public-key Algorithms
RSA (Rivest-Shamir-Adleman), 1977
DH (Diffie-Hellman), 1976
Key exchange algorithm
Elgamal
DH variant, one algorithm for encryption, one for signatures
Non-patented alternative to RSA
Advantages/Disadvantages of ECCs
Advantages
Useful for smart cards because of their low resource
requirements
Useful where high-speed operation is required
Disadvantages
New, details are still being resolved
Many techniques are still too new to trust
ECCs are a minefield of patents, pending patents, and
submarine patents
Public-key
(400 bits)
512 bits
768 bits
1024 bits
1792 bits
2048 bits
2304 bits
ECC
160 bits
195 bits
210 bits
256 bits
Hash Algorithms
Reduce variable-length input to fixed-length (128 or 160
bit) output
Requirements
Cant deduce input from output
Cant generate a given output (CRC fails this requirement)
Cant find two inputs which produce the same output (CRC
also fails this requirement)
Used to
Produce fixed-length fingerprint of arbitrary-length data
Produce data checksums to enable detection of modifications
Distill passwords down to fixed-length encryption keys
MAC Algorithms
Hash algorithm + key to make hash value dependant on the
key
Most common form is HMAC (hash MAC)
hash( key, hash( key, data ))
Key affects both start and end of hashing process
Algorithms
MD2: 128-bit output, deprecated
MD4: 128-bit output, broken
MD5: 128-bit output, weaknesses
SHA-1: 160-bit output, NSA-designed US government
secure hash algorithm, companion to DSA
RIPEMD-160: 160-bit output
HMAC-MD5: MD5 turned into a MAC
HMAC-SHA: SHA-1 turned into a MAC
Recommendation: Use SHA-1, HMAC-SHA