Date post: | 17-Jan-2016 |
Category: |
Documents |
Upload: | eustace-oliver |
View: | 227 times |
Download: | 2 times |
Network Security EssentialsNetwork Security EssentialsChapter 2Chapter 2
Fourth EditionFourth Editionby William Stallingsby William Stallings
(Based on Lecture slides by (Based on Lecture slides by Lawrie Brown)Lawrie Brown)
Outline
Symmetric encryption (Ref. Chap.2) Block encryption algorithms (Ref. Chap.3
& 5) Stream ciphers (Ref. Chap.7) Block cipher modes of operations (Ref.
Chap.6)
Symmetric EncryptionSymmetric Encryption
Or conventional / Or conventional / private-keyprivate-key / single-key / single-key Sender and recipient share a common keySender and recipient share a common key All classical encryption algorithms are All classical encryption algorithms are
private-keyprivate-key Was the only type prior to invention of Was the only type prior to invention of
public-key in 1970’spublic-key in 1970’s By far most widely usedBy far most widely used
Some Basic TerminologySome Basic Terminology
plaintextplaintext - original message - original message
ciphertextciphertext - coded message - coded message
ciphercipher - algorithm for transforming plaintext to ciphertext - algorithm for transforming plaintext to ciphertext
keykey - info used in cipher known only to sender/receiver - info used in cipher known only to sender/receiver
encipher (encrypt)encipher (encrypt) - converting plaintext to ciphertext - converting plaintext to ciphertext
decipher (decrypt)decipher (decrypt) - recovering plaintext from ciphertext - recovering plaintext from ciphertext
cryptographycryptography - study of encryption principles/methods - study of encryption principles/methods
cryptanalysis (codebreaking)cryptanalysis (codebreaking) - study of principles/ - study of principles/ methods of deciphering ciphertext methods of deciphering ciphertext withoutwithout knowing key knowing key
cryptologycryptology - field of both cryptography and cryptanalysis - field of both cryptography and cryptanalysis
Symmetric Cipher ModelSymmetric Cipher Model
RequirementsRequirements
Two requirements for secure use of Two requirements for secure use of symmetric encryption:symmetric encryption: A strong encryption A strong encryption algorithmalgorithm A secret A secret keykey known only to sender / receiver known only to sender / receiver
Mathematically have:Mathematically have:Y Y = E(K, = E(K, XX))X X = D(K, = D(K, YY))
Assume encryption algorithm is knownAssume encryption algorithm is known Implies a secure channel to distribute keyImplies a secure channel to distribute key
CryptographyCryptography
Cryptographic systems classified by:Cryptographic systems classified by: Type of encryption operations usedType of encryption operations used
• SubstitutionSubstitution (e.g. Caesar cipher) (e.g. Caesar cipher)• TranspositionTransposition (e.g. rail fence technique) (e.g. rail fence technique)
Number of keys usedNumber of keys used• Single-key or privateSingle-key or private• Two-key or publicTwo-key or public
Way in which plaintext is processedWay in which plaintext is processed• BlockBlock• StreamStream
CryptanalysisCryptanalysis
Attempting to recover key not just Attempting to recover key not just messagemessage
General approaches:General approaches: Cryptanalytic attackCryptanalytic attack Brute-force attackBrute-force attack
If either succeeds all key use If either succeeds all key use compromisedcompromised
Cryptanalytic AttacksCryptanalytic Attacks Ciphertext onlyCiphertext only
Only know algorithm & ciphertext, is Only know algorithm & ciphertext, is statistical, know or can identify plaintext statistical, know or can identify plaintext
Known plaintextKnown plaintext Know/suspect plaintext & ciphertextKnow/suspect plaintext & ciphertext
Chosen plaintextChosen plaintext Select plaintext and obtain ciphertextSelect plaintext and obtain ciphertext
Chosen ciphertextChosen ciphertext Select ciphertext and obtain plaintextSelect ciphertext and obtain plaintext
Chosen textChosen text Select plaintext or ciphertext to en/decryptSelect plaintext or ciphertext to en/decrypt
An encryption scheme is computationally secure if The cost of breaking the cipher exceeds the
value of information The time required to break the cipher exceeds
the lifetime of information
Brute Force SearchBrute Force Search
Always possible to simply try every key Always possible to simply try every key Most basic attack, proportional to Most basic attack, proportional to key size key size Assume either know / recognise plaintextAssume either know / recognise plaintext
Key Size (bits) Number of Alternative Keys
Time required at 1 decryption/µs
Time required at 106 decryptions/µs
32 232 = 4.3 109 231 µs = 35.8 minutes 2.15 milliseconds
56 256 = 7.2 1016 255 µs = 1142 years 10.01 hours
128 2128 = 3.4 1038 2127 µs = 5.4 1024 years 5.4 1018 years
168 2168 = 3.7 1050 2167 µs = 5.9 1036 years 5.9 1030 years
26 characters (permutation)
26! = 4 1026 2 1026 µs = 6.4 1012 years 6.4 106 years
Feistel Cipher StructureFeistel Cipher Structure
Horst Feistel devised the Horst Feistel devised the feistel cipherfeistel cipher Based on concept of Based on concept of invertible product cipherinvertible product cipher Product cipher: two or more simple ciphers in Product cipher: two or more simple ciphers in
sequencesequence Partitions input block into two halvesPartitions input block into two halves
Process through multiple rounds whichProcess through multiple rounds which Perform a substitution on left data halfPerform a substitution on left data half Based on round function of right half & subkeyBased on round function of right half & subkey Then have permutation swapping halvesThen have permutation swapping halves
Implements Shannon’s SPN (Substitution-Implements Shannon’s SPN (Substitution-Permutation Network) conceptPermutation Network) concept
Feistel Cipher StructureFeistel Cipher Structure
Feistel Cipher Design ElementsFeistel Cipher Design Elements
Choices of parameters:Choices of parameters: Block size: 128 bits Block size: 128 bits Key size: 128 bits Key size: 128 bits Number of rounds: 16 Number of rounds: 16 Subkey generation algorithmSubkey generation algorithm Round function FRound function F
Two considerations:Two considerations: Fast software en/decryptionFast software en/decryption Ease of analysisEase of analysis
Symmetric Block Cipher Algorithms
DES (Data Encryption Standard) 3DES (Triple DES) AES (Advanced Encryption Standard)
Data Encryption Standard (DES)Data Encryption Standard (DES)
Most widely used block cipher in world Most widely used block cipher in world Adopted in 1977 by NBS (now NIST)Adopted in 1977 by NBS (now NIST)
As FIPS PUB 46As FIPS PUB 46 Encrypts 64-bit data using 56-bit keyEncrypts 64-bit data using 56-bit key Has widespread useHas widespread use Has considerable controversy over its Has considerable controversy over its
securitysecurity
DES HistoryDES History
IBM developed Lucifer cipherIBM developed Lucifer cipher By team led by Feistel in late 60’sBy team led by Feistel in late 60’s Used 64-bit data blocks with 128-bit keyUsed 64-bit data blocks with 128-bit key
Then redeveloped as a commercial cipher Then redeveloped as a commercial cipher with input from NSA and otherswith input from NSA and others
In 1973 NBS issued request for proposals In 1973 NBS issued request for proposals for a national cipher standardfor a national cipher standard
IBM submitted their revised Lucifer which IBM submitted their revised Lucifer which was eventually accepted as the DESwas eventually accepted as the DES
DES Design ControversyDES Design Controversy
Although DES standard is public, Although DES standard is public, considerable controversy over design considerable controversy over design In choice of 56-bit key (vs Lucifer 128-bit)In choice of 56-bit key (vs Lucifer 128-bit) And because design criteria were classified And because design criteria were classified
Subsequent events and public analysis Subsequent events and public analysis show in fact design was appropriateshow in fact design was appropriate
Use of DES has flourishedUse of DES has flourished Especially in financial applicationsEspecially in financial applications Still standardised for legacy application useStill standardised for legacy application use
Time to Break a DES Code (assuming 106 decryptions/s)
Multiple Encryption & DESMultiple Encryption & DES
Clear a replacement for DES was neededClear a replacement for DES was needed Theoretical attacks that can break itTheoretical attacks that can break it Demonstrated exhaustive key search attacksDemonstrated exhaustive key search attacks
AES is a new cipher alternativeAES is a new cipher alternative Prior to this alternative was to use multiple Prior to this alternative was to use multiple
encryption with DES implementationsencryption with DES implementations Triple-DES is the chosen formTriple-DES is the chosen form
Double-DES?Double-DES?
Could use 2 DES encrypts on each blockCould use 2 DES encrypts on each block C = EC = EK2K2(E(EK1K1(P))(P))
Issue of reduction to single stageIssue of reduction to single stage And have “meet-in-the-middle” attackAnd have “meet-in-the-middle” attack
Works whenever use a cipher twiceWorks whenever use a cipher twice Since Since X = EX = EK1K1(P) = D(P) = DK2K2(C)(C) Attack by encrypting P with all keys and storeAttack by encrypting P with all keys and store Then decrypt C with keys and match X valueThen decrypt C with keys and match X value Takes Takes O(2O(25656)) steps steps
Triple-DES with Two-KeysTriple-DES with Two-Keys
Hence must use 3 encryptionsHence must use 3 encryptions Would seem to need 3 distinct keysWould seem to need 3 distinct keys
But can use 2 keys with E-D-E sequenceBut can use 2 keys with E-D-E sequence C = EC = EK1K1(D(DK2K2(E(EK1K1(P)))(P))) nb encrypt & decrypt equivalent in securitynb encrypt & decrypt equivalent in security If If K1=K2K1=K2 then can work with single DES then can work with single DES
Standardized in ANSI X9.17 & ISO8732Standardized in ANSI X9.17 & ISO8732 No current known practical attacksNo current known practical attacks
Several proposed impractical attacks might Several proposed impractical attacks might become basis of future attacksbecome basis of future attacks
Triple-DES with Three-KeysTriple-DES with Three-Keys
Although no practical attacks on two-key Although no practical attacks on two-key Triple-DES have some concernsTriple-DES have some concerns Two-key: key length = 56*2 = 112 bitsTwo-key: key length = 56*2 = 112 bits Three-key: key length = 56*3 = 168 bitsThree-key: key length = 56*3 = 168 bits
Can use Triple-DES with Three-Keys to Can use Triple-DES with Three-Keys to avoid even theseavoid even these C = EC = EK3K3(D(DK2K2(E(EK1K1(P)))(P)))
Has been adopted by some Internet Has been adopted by some Internet applications, e.g. PGP, S/MIMEapplications, e.g. PGP, S/MIME
Triple DES
OriginsOrigins
Clearly a replacement for DES was neededClearly a replacement for DES was needed Have theoretical attacks that can break itHave theoretical attacks that can break it Have demonstrated exhaustive key search attacksHave demonstrated exhaustive key search attacks
Can use Triple-DES – but slow, has small blocksCan use Triple-DES – but slow, has small blocks US NIST issued call for ciphers in 1997US NIST issued call for ciphers in 1997 15 candidates accepted in Jun 98 15 candidates accepted in Jun 98 5 were shortlisted in Aug-99 5 were shortlisted in Aug-99 Rijndael was selected as the AES in Oct-2000Rijndael was selected as the AES in Oct-2000 Issued as FIPS PUB 197 standard in Nov-2001 Issued as FIPS PUB 197 standard in Nov-2001
The AES Cipher - Rijndael The AES Cipher - Rijndael
Designed by Rijmen-Daemen in Belgium Designed by Rijmen-Daemen in Belgium Has 128/192/256 bit keys, 128 bit data Has 128/192/256 bit keys, 128 bit data An An iterativeiterative rather than rather than feistelfeistel cipher cipher
Processes Processes data as block of 4 columns of 4 bytesdata as block of 4 columns of 4 bytes Operates on entire data block in every roundOperates on entire data block in every round
Designed to be:Designed to be: Resistant against known attacksResistant against known attacks Speed and code compactness on many CPUsSpeed and code compactness on many CPUs Design simplicityDesign simplicity
AES AES Encryption Encryption
ProcessProcess
AES StructureAES Structure Data block of Data block of 4 columns of 4 bytes is state4 columns of 4 bytes is state Key is expanded to array of wordsKey is expanded to array of words Has 9/11/13 rounds in which state undergoes: Has 9/11/13 rounds in which state undergoes:
Byte substitution (1 S-box used on every byte) Byte substitution (1 S-box used on every byte) Shift rows (permute bytes between groups/columns) Shift rows (permute bytes between groups/columns) Mix columns (subs using matrix multiply of groups) Mix columns (subs using matrix multiply of groups) Add round key (XOR state with key material)Add round key (XOR state with key material) View as alternating XOR key & scramble data bytesView as alternating XOR key & scramble data bytes
Initial XOR key material & incomplete last roundInitial XOR key material & incomplete last round With fast XOR & table lookup implementationWith fast XOR & table lookup implementation
AES StructureAES Structure
AES RoundAES Round
Substitute bytes: table lookupSubstitute bytes: table lookup Shift rows: Shift rows:
Row 1: not alteredRow 1: not altered Row 2: 1-byte circular left shiftRow 2: 1-byte circular left shift Row 3: 2-byte circular left shiftRow 3: 2-byte circular left shift Row 4: 3-byte circular left shiftRow 4: 3-byte circular left shift
Mix columns: to ensure a good mixing among Mix columns: to ensure a good mixing among the bytes of each columnthe bytes of each column
Add round key: bitwise XORAdd round key: bitwise XOR
AES Key ExpansionAES Key Expansion
KeyExpansion(byte key[16], word w[44])KeyExpansion(byte key[16], word w[44]){{ word temp; word temp; for (i=0; i<4; i++) for (i=0; i<4; i++) w[i]=(key[4*i, key[4*i+1], key[4*i+2], key[4*i+3]); w[i]=(key[4*i, key[4*i+1], key[4*i+2], key[4*i+3]); for (i=4; i<44; i++) for (i=4; i<44; i++) { { temp=w[i-1]; temp=w[i-1]; if (i%4==0) temp=SubWord(RotWord(temp)) if (i%4==0) temp=SubWord(RotWord(temp)) XOR Rcon[i/4];XOR Rcon[i/4]; w[i]=w[i-4] XOR temp; w[i]=w[i-4] XOR temp; } }
Comments and Some Insights Comments and Some Insights into AESinto AES
The structure is quite simpleThe structure is quite simple 10 rounds, 4 stages each10 rounds, 4 stages each
The scheme is efficient and highly secureThe scheme is efficient and highly secure Alternating operations of XOR and scrambling of the Alternating operations of XOR and scrambling of the
blockblock Each stage is easily reversibleEach stage is easily reversible Decryption algorithm is not identical to encryption Decryption algorithm is not identical to encryption
algorithmalgorithm Avalanche Effect: a small change in the key or Avalanche Effect: a small change in the key or
plaintext produces a large change in the ciphertextplaintext produces a large change in the ciphertext
Random NumbersRandom Numbers
Many uses of Many uses of random numbersrandom numbers in cryptography in cryptography NoncesNonces in authentication protocols to prevent replay in authentication protocols to prevent replay Session keysSession keys Public key generationPublic key generation Keystream for a one-time padKeystream for a one-time pad
It’s critical that these values be It’s critical that these values be Statistically randomStatistically random: uniform distribution, : uniform distribution,
independenceindependence UnpredictabilityUnpredictability of future values from of future values from previous valuesprevious values
True random numbers provide thisTrue random numbers provide this Care needed with generated random numbersCare needed with generated random numbers
Pseudorandom Number Pseudorandom Number Generators (PRNGs)Generators (PRNGs)
Often use deterministic algorithmic Often use deterministic algorithmic techniques to create “random numbers”techniques to create “random numbers” Although are Although are notnot truly random truly random Can pass many tests of “randomness”Can pass many tests of “randomness”
Known as “pseudorandom numbers”Known as “pseudorandom numbers” Created by “Created by “Pseudorandom Number Pseudorandom Number
Generators (PRNGs)”Generators (PRNGs)”
Random & Pseudorandom Random & Pseudorandom Number GeneratorsNumber Generators
PRNG Algorithm Design
Purpose-built algorithms E.g. RC4
Algorithms based on existing cryptographic algorithms Symmetric block ciphers Asymmetric ciphers Hash functions and message authentication
codes
Stream Cipher StructureStream Cipher Structure
Stream Cipher PropertiesStream Cipher Properties
Some design considerations are:Some design considerations are: Long period with no repetitions Long period with no repetitions Statistically random Statistically random Depends on large enough key, e.g. 128 bitsDepends on large enough key, e.g. 128 bits Large linear complexityLarge linear complexity
Properly designed, can be as secure as a Properly designed, can be as secure as a block cipher with same size keyblock cipher with same size key
But usually simpler & fasterBut usually simpler & faster
RC4RC4
A proprietary cipher owned by RSA DSI A proprietary cipher owned by RSA DSI Another Ron Rivest design, simple but effectiveAnother Ron Rivest design, simple but effective Variable key size, byte-oriented stream cipher Variable key size, byte-oriented stream cipher Widely used (web SSL/TLS, wireless Widely used (web SSL/TLS, wireless
WEP/WPA) WEP/WPA) Key forms random permutation of all 8-bit values Key forms random permutation of all 8-bit values Uses that permutation to scramble input info Uses that permutation to scramble input info
processed a byte at a time processed a byte at a time
RC4 Key Schedule RC4 Key Schedule
Starts with an array S of numbers: 0..255 Starts with an array S of numbers: 0..255 Use key to well and truly shuffle Use key to well and truly shuffle S forms S forms internal stateinternal state of the cipher of the cipher
for i = 0 to 255 dofor i = 0 to 255 doS[i] = i;S[i] = i;T[i] = K[i mod keylen];T[i] = K[i mod keylen];
j = 0j = 0for i = 0 to 255 do for i = 0 to 255 do
j = (j + S[i] + T[i]) (mod 256);j = (j + S[i] + T[i]) (mod 256);swap (S[i], S[j]);swap (S[i], S[j]);
RC4 EncryptionRC4 Encryption
Encryption continues shuffling array valuesEncryption continues shuffling array values Sum of shuffled pair selects "stream key" value Sum of shuffled pair selects "stream key" value
from permutationfrom permutation XOR S[t] with next byte of message to XOR S[t] with next byte of message to
en/decrypten/decrypti = j = 0;i = j = 0;
for each message byte Mfor each message byte Mii
i = (i + 1) (mod 256);i = (i + 1) (mod 256);j = (j + S[i]) (mod 256);j = (j + S[i]) (mod 256);swap(S[i], S[j]);swap(S[i], S[j]);t = (S[i] + S[j]) (mod 256); t = (S[i] + S[j]) (mod 256);
CCii = M = Mii XOR S[t]; XOR S[t];
RC4 OverviewRC4 Overview
RC4 SecurityRC4 Security
Claimed secure against known attacksClaimed secure against known attacks Have some analyses, none practical Have some analyses, none practical
Result is very non-linear Result is very non-linear Since RC4 is a stream cipher, must Since RC4 is a stream cipher, must never never
reuse a keyreuse a key Have a concern with WEP, but due to key Have a concern with WEP, but due to key
handling rather than RC4 itself handling rather than RC4 itself
Modes of OperationModes of Operation
Block ciphers encrypt fixed size blocksBlock ciphers encrypt fixed size blocks eg. DES encrypts 64-bit blocks with 56-bit key eg. DES encrypts 64-bit blocks with 56-bit key
Need some way to en/decrypt arbitrary Need some way to en/decrypt arbitrary amounts of data in practiceamounts of data in practice
NIST SP 800-38ANIST SP 800-38A defines 5 modes defines 5 modes Have Have blockblock and and streamstream modes modes To cover a wide variety of applicationsTo cover a wide variety of applications Can be used with any block cipherCan be used with any block cipher
The Most Important Modes
Electronic Codebook Mode (ECB) Cipher Block Chaining Mode (CBC) Cipher Feedback Mode (CFB) Counter Mode (CTR)
Electronic Codebook Mode Electronic Codebook Mode (ECB)(ECB)
Message is broken into Message is broken into independentindependent blocks which are encrypted blocks which are encrypted
Each block is a value which is substituted, Each block is a value which is substituted, like a codebook, hence the name like a codebook, hence the name
Each block is encoded independently of Each block is encoded independently of the other blocks the other blocks CCii = E = EKK(P(Pii))
Uses: secure transmission of single valuesUses: secure transmission of single values
Advantages and Limitations of Advantages and Limitations of ECBECB
Message repetitions may show in ciphertext Message repetitions may show in ciphertext If aligned with message block If aligned with message block Particularly with data such as graphics Particularly with data such as graphics Or with messages that change very little, which Or with messages that change very little, which
become a code-book analysis problem become a code-book analysis problem Weakness is due to the encrypted message Weakness is due to the encrypted message
blocks being independent blocks being independent Main use is sending a few blocks of data Main use is sending a few blocks of data
Cipher Block Chaining (CBC) Cipher Block Chaining (CBC)
Message is broken into blocks Message is broken into blocks Linked together in encryption operation Linked together in encryption operation Each previous cipher blocks is chained Each previous cipher blocks is chained
with current plaintext block, hence the with current plaintext block, hence the name name
Use Initial Vector (IV) to start process Use Initial Vector (IV) to start process CCii = E = EKK(P(Pii XOR C XOR Ci-1i-1))
CC00 = IV = IV
Uses: bulk data encryption, authenticationUses: bulk data encryption, authentication
Cipher Cipher Block Block
Chaining Chaining (CBC)(CBC)
Cipher FeedBack (CFB)Cipher FeedBack (CFB)
Message is treated as a stream of bits Message is treated as a stream of bits Added to the output of the block cipher Added to the output of the block cipher Result is feed back for next stage (hence the name) Result is feed back for next stage (hence the name) Standard allows any number of bit (1,8, 64 or 128 Standard allows any number of bit (1,8, 64 or 128
etc) to be fed back etc) to be fed back Denoted CFB-1, CFB-8, CFB-64, CFB-128 etc Denoted CFB-1, CFB-8, CFB-64, CFB-128 etc
Most efficient to use all bits in block (64 or 128)Most efficient to use all bits in block (64 or 128)CCii = P = Pii XOR E XOR EKK(C(Ci-1i-1))
CC00 = IV = IV Uses: stream data encryption, authenticationUses: stream data encryption, authentication
s-bits-bitCipher Cipher
FeedBack FeedBack (CFB-s)(CFB-s)
Advantages and Limitations of Advantages and Limitations of CFBCFB
Appropriate when data arrives in bits/bytes Appropriate when data arrives in bits/bytes Most common stream mode Most common stream mode Limitation: need to stall while doing block Limitation: need to stall while doing block
encryption after every n-bits encryption after every n-bits Note that the block cipher is used in Note that the block cipher is used in
encryptionencryption mode at mode at bothboth ends ends Errors propagate for several blocks after Errors propagate for several blocks after
the error the error
Counter (CTR)Counter (CTR)
A “new” mode, though proposed early onA “new” mode, though proposed early on Similar to OFB but encrypts counter value Similar to OFB but encrypts counter value
rather than any feedback valuerather than any feedback value Must have a different key & counter value Must have a different key & counter value
for every plaintext block (never reused)for every plaintext block (never reused)OOii = E = EKK(i)(i)
CCii = P = Pii XOR O XOR Oii
Uses: high-speed network encryptionsUses: high-speed network encryptions
Counter Counter (CTR)(CTR)
Advantages and Limitations of Advantages and Limitations of CTRCTR
EfficiencyEfficiency Can do parallel encryptions in h/w or s/wCan do parallel encryptions in h/w or s/w Can preprocess in advance of needCan preprocess in advance of need Good for bursty high speed linksGood for bursty high speed links
Random access to encrypted data blocksRandom access to encrypted data blocks Provable security (good as other modes)Provable security (good as other modes) But must ensure never reuse key/counter But must ensure never reuse key/counter
values, otherwise could break (cf OFB)values, otherwise could break (cf OFB)
Output Feedback Mode (OFB)
Differences with CFBDifferences with CFB
The output of the encryption function is fed back to The output of the encryption function is fed back to the shift registerthe shift register Not the ciphertext unitNot the ciphertext unit
OFB mode operates on full blocks of plaintext and OFB mode operates on full blocks of plaintext and ciphertextciphertext Not on s-bit subsetsNot on s-bit subsets
Advantage:Advantage: Bit errors in transmission do not propagateBit errors in transmission do not propagate
DisadvantageDisadvantage More vulnerable to a message stream modification More vulnerable to a message stream modification
attack than is CFBattack than is CFB
Thanks for Your Attention!Thanks for Your Attention!