Summary From the Last Lecture

39
We spoke about defense challenges Crypto introduction o Secret key, public algorithms o Symmetric, asymmetric crypto, one-way hashes Attacks on cryptography o Cyphertext-only, known plaintext, chosen plaintext, MITM, brute-force Types of ciphers o Mix of substitution and transposition o Monoalphabetic, homophonic, polygram, polyalphabetic Summary From the Last Lecture

description

Summary From the Last Lecture. We spoke about defense challenges Crypto introduction Secret key, public algorithms Symmetric, asymmetric crypto, one-way hashes Attacks on cryptography Cyphertext -only, known plaintext, chosen plaintext, MITM, brute-force Types of ciphers - PowerPoint PPT Presentation

Transcript of Summary From the Last Lecture

Page 1: Summary  From the Last Lecture

We spoke about defense challengesCrypto introductionoSecret key, public algorithmsoSymmetric, asymmetric crypto, one-way hashes

Attacks on cryptographyoCyphertext-only, known plaintext, chosen

plaintext, MITM, brute-forceTypes of ciphersoMix of substitution and transpositionoMonoalphabetic, homophonic, polygram,

polyalphabetic

Summary From the Last Lecture

Page 2: Summary  From the Last Lecture

Bpqa kzgxbwozixpg ammua zmit miag. Em eivb uwzm!

Answer 1:o The call of death is a call of love. Death can be

sweet if we answer it in the affirmative, if we accept it as one of the great eternal forms of life and transformation.

o Broken by using frequency analysis

Can You Decrypt This?

Page 3: Summary  From the Last Lecture

Bpqa kzgxbwozixpg ammua zmit miag. Em eivb uwzm!

Answer 2:o This cryptography seems real easy. We want

more!o Ceasar cipher with offset 18, symmetrico Q: If we use offset 18 to encrypt and offset 8 to

decrypt how is this symmetric crypto?

Can You Decrypt This?

Page 4: Summary  From the Last Lecture

Polyalphabetic – many monoalphabetic ciphers are used sequentiallyoFirst mapping is used for the first letter,

second mapping for the second letter and so on

oXOR is a polyalphabetic cipher in binary domain

Substitution

Page 5: Summary  From the Last Lecture

Polyalphabetic cipher with infinite keyoCombine letters from the message with the

letters from an infinite key, randomly generated

oNever reuse the keyoKey needs to be generated using a very good

RNG (to avoid any patterns)This cipher cannot be brokenSender and receiver must be perfectly

synchronized

One-Time Pad

Page 6: Summary  From the Last Lecture

Stream ciphers: polyalphabeticoWork on message a bit or a byte at a timeoSame bit/byte will encrypt differently,

depending on the position of the key Block ciphers: polygramoWork on message block by blockoBlock size is usually the same as key sizeoSame plaintext block may encrypt

into the same ciphertext block, depending on the cipher mode

Assume XOR with the key

Symmetric Crypto Algorithms

Page 7: Summary  From the Last Lecture

Stream Cipher Example

plaintext

key

ciphertext

S A N T A C L A U S S A N T A C L A U S

S U P E R C A L I F R A G I L I S T I C

L V D Y S F M M D Y K B U C M L E U D V

Bonus question: What was the encryptionalgorithm I used here?

Page 8: Summary  From the Last Lecture

If Eve can get hold of plaintext/cyphertext pair she can retrieve the key

Keystream is generated continuously and is the function of the secret stored inside the RNG

Key should be pseudorandom – hard to break but easily reproduced for decryption

Security depends entirely on RNG generating the key

Stream Ciphers

Page 9: Summary  From the Last Lecture

Keystream GeneratorsRandom Number Generators

Block CiphersChaining

Page 10: Summary  From the Last Lecture

Internal State

Output Function

Next State

Function

Key

Keystream

Keystream Generator

Page 11: Summary  From the Last Lecture

Keystream is generated from the key KSender and receiver must be synchronizedOne-bit error in ciphertext produces one-

bit error in plaintextUpon loss of synchronization both sides

start afresh with a new keyAny deletions and insertions will cause loss

of synchronization Mallory can toggle/change bits

Synchronous Stream Cipher

Page 12: Summary  From the Last Lecture

Self-Synchronizing Stream CipherInternal State

Output FunctionKey

+Pi Ci

Page 13: Summary  From the Last Lecture

Internal state is the function only of the previous n ciphertext bits and depends on the key K

Decryption keystream generator will completely synchronize with encryption generator after receiving n bits

Advantage:oRecovery from loss of bits after n bits

Drawback: oError extension – one-bit error in ciphertext

produces n errors in plaintextoMallory can replay messages

Self-Synchronizing Stream Cipher

Page 14: Summary  From the Last Lecture

We need to generate a sequence that looks random but is reproducible

There shouldn’t be any obvious regularities, otherwise Eve can learn the pattern after seeing several numbers, and guess the next ones

We would like to cover the whole range of numbers (e.g. 2n if the number has n bits)

Generating Random Numbers

Page 15: Summary  From the Last Lecture

Generators of the form

oA period of a generator is number of steps before it repeats the sequence

o If a, b and m are properly chosen, this generator will be maximal period generator and have period of m

o It has been proven that any polynomial congruential generator can be broken

Linear Congruential Generators

mbaXX nn mod)( 1 += −

Page 16: Summary  From the Last Lecture

Used for cryptography today A shift register is transformed in every

step through feedback functionoContents are shifted one bit to the right, the bit

that “falls out” is the outputoNew leftmost bit is XOR of some bits in the shift

register - tap sequenceo If we choose a proper tap sequence period will be

2n-1

Linear Feedback Shift Registers

Page 17: Summary  From the Last Lecture

Linear Feedback Shift Registers

1111

144 XXX ⊕=

0111 11011 10101 11010 11101 0

0110 10011 01001 10100 10010 00001 0

1000 11100 01110 01111 0

Page 18: Summary  From the Last Lecture

Proper tap sequences are those where a polynomial from a tap sequence + 1 is a primitive polynomial in GF(2)

There are tables of primitive polynomials LFSR is fast in hardware but slow in

software LFSR are not themselves secure but they

are used as building blocks in encryption algorithms

Linear Feedback Shift Registers

Page 19: Summary  From the Last Lecture

Block Cipher Example

plaintext

key

S A N T A C L A U S S A N T A C L A U S

S U P E R

Page 20: Summary  From the Last Lecture

Block Cipher Example

plaintext

key

ciphertext

S A N T A C L A U S S A N T A C L A U S

S U P E R

L V D Y S

Page 21: Summary  From the Last Lecture

Block Cipher Example

plaintext

key

ciphertext

S A N T A C L A U S S A N T A C L A U S

L V D Y S V G Q Z K

S U P E R

Page 22: Summary  From the Last Lecture

Block Cipher Example

plaintext

key

ciphertext

S A N T A C L A U S S A N T A C L A U S

L V D Y S V G Q Z K

S U P E R

L V D Y S

Page 23: Summary  From the Last Lecture

Block Cipher Example

plaintext

key

ciphertext

S U P E R

S A N T A C L A U S S A N T A C L A U S

L V D Y S V G Q Z K L V D Y S V G Q Z K

Page 24: Summary  From the Last Lecture

Block Encryption In Rounds

S S S S S S S Sround

substitution

permutation

Page 25: Summary  From the Last Lecture

Electronic Code Book (ECB)Cipher Block Chaining (CBC)k-bit Cipher Feedback Mode (CFB)k-bit Output Feedback Mode (OFB)Things to consider:oCan we encrypt/decrypt efficiently

(as soon as bits arrive)oHow hard it is to break encryptionoWhat if a bit is flipped on the channeloWhat if we lose a bit on the channel

Encrypting A Large Message

Page 26: Summary  From the Last Lecture

Store mapping for every possible blockoFast encryption/decryption – just a table lookupoAbility to process text in any order and in paralleloTable size could be enormous so we need to make the

mapping depend on the keyEve can detect which blocks map to other blocks, by

seeing several plaintext and corresponding ciphertext messages

Due to language redundancy even partial decryption might provide enough information

Bit error invalidates one blockBit loss/addition is not recoverable

Electronic Code Book (ECB)

Page 27: Summary  From the Last Lecture

Block Replay

Bank A Bank BEK(M) DK(C)

MalloryTransfer $100 to my account in Bank B

12B7 7783 38AC CDC7

Mallory does this couple of times, looks for similar block sequences.

She can now replay 12B7 7783 38AC CDC7 at will

Page 28: Summary  From the Last Lecture

Block Replay

Bank A Bank BEK(M) DK(C)

MalloryTransfer $100 to my account in Bank B

3231 12B7 7783 38AC CDC7

Bank adds timestampsMallory picks specific blocks of message carrying his

name and account number and replaces those in other messages between Bank A and Bank B

Page 29: Summary  From the Last Lecture

Cipher Block Chaining (CBC)Problem with ECB is that Mallory can

replace, add or drop blocks at willChaining prevents this by adding feedback

o Each ciphertext block depends on all previous blocks

Also, with CBC, same plaintext blocks will encrypt to different ciphertext blocks thus obscuring patterns in plaintext

Page 30: Summary  From the Last Lecture

Cipher Block Chaining (CBC)

+

plaintext

key

ciphertext

+ +IVInitialization vector (IV) is just a block of random numbers, to ensure that no messages have the same beginning.Both the sender and the receiver must use thesame IV.

Encryption

Page 31: Summary  From the Last Lecture

Cipher Block Chaining (CBC)

key

ciphertext

Decryptionplaintext

+ +

Page 32: Summary  From the Last Lecture

Error RecoveryAn error in plaintext affects the rest of the

message but is easily spotted and removed after decryption

An error in ciphertext affects one block and several bits of plaintext

key

ciphertext

plaintext

+ +

Error extension

Page 33: Summary  From the Last Lecture

Potential Problems With CBCMallory can:

o Add blockso Drop blockso Introduce bit errors

Bit loss/addition is not recoverable

Page 34: Summary  From the Last Lecture

Cipher-Feedback Mode (CFB)input queue

+

key

output block

plaintext

1Ciphertext unit(k bits) is added to the right to input queue, and next plaintext unit is processed

ciphertext2

Page 35: Summary  From the Last Lecture

IV must be unique, otherwise it opens a vulnerability

If a k-bit unit is lost or added, next n/k-1 units will be garbled but then the algorithm will recover from error

One-bit error in ciphertext produces one-bit error in plaintext and n/k-1 subsequent plaintext units are garbled (n is the block size, k is the unit size)

Cipher-Feedback Mode (CFB)

Page 36: Summary  From the Last Lecture

Similar to CFB but unit is taken from the output queue, not from the ciphertext

Output-Feedback Mode (OFB)

input queue

+

key

ciphertextplaintext

1

IV is placed in input queue and encrypted, leftmost unit is XOR-ed with one plaintext unit and sent

output block

Page 37: Summary  From the Last Lecture

Output-Feedback Mode (OFB)

input queue

+

key

output block

plaintext

2

1 Leftmost unit from the output blockis added to the right to input queue, and next plaintext unit is processed

ciphertext

Page 38: Summary  From the Last Lecture

Output block generation can be done offline, plaintext is then just XOR-ed when it arrives

One-bit error in ciphertext produces one-bit error in plaintext

Bit loss/addition is not recoverable

Output-Feedback Mode (OFB)

Page 39: Summary  From the Last Lecture

Stream ciphers can be analysed mathematically and can be efficiently implemented in hardware

Block ciphers are more general and can be efficiently implemented in software

ECB is easiest and fastest but also weakest. Can be used for encrypting random data, such as other keys.

CBC is good for encrypting files, no danger of lack of synchronization

CFB is good for encrypting streams of characters

OFB is good if error propagation cannot be tolerated

Which Cipher Is The Best?