Most Common Cryptography Mistakes 4/2/2014 #1: Dont Roll - - PowerPoint PPT Presentation

most common cryptography mistakes
SMART_READER_LITE
LIVE PREVIEW

Most Common Cryptography Mistakes 4/2/2014 #1: Dont Roll - - PowerPoint PPT Presentation

Most Common Cryptography Mistakes 4/2/2014 #1: Dont Roll Your Own Dont design your own crypto algorithm Use a Dme-honored, well-tested


slide-1
SLIDE 1

Most ¡Common ¡ Cryptography ¡Mistakes ¡

4/2/2014 ¡

slide-2
SLIDE 2

#1: ¡Don’t ¡Roll ¡Your ¡Own ¡

  • Don’t ¡design ¡your ¡own ¡crypto ¡algorithm ¡
  • Use ¡a ¡Dme-­‑honored, ¡well-­‑tested ¡system ¡

– e.g., ¡SSL, ¡PGP, ¡SSH ¡

slide-3
SLIDE 3

#2: ¡Don’t ¡Encrypt ¡without ¡Auth ¡

  • Common ¡mistake: ¡encrypt, ¡but ¡no ¡authenDcaDon ¡

– A ¡checksum ¡does ¡not ¡provide ¡authenDcaDon ¡

  • If ¡you’re ¡encrypDng, ¡you ¡probably ¡want ¡

authenDcated ¡encrypDon ¡

– Encrypt-­‑then-­‑authenDcate: ¡Ek1(M), ¡Fk2(Ek1(M)) ¡ – Or, ¡use ¡a ¡dedicated ¡AE ¡mode: ¡GCM, ¡EAX, ¡… ¡

slide-4
SLIDE 4

#3: ¡Be ¡Careful ¡with ¡Randomness ¡

  • Common ¡mistake: ¡use ¡predictable ¡random ¡

number ¡generator ¡(e.g., ¡to ¡generate ¡keys) ¡

  • SoluDon: ¡Use ¡a ¡crypto-­‑quality ¡PRNG. ¡

– /dev/urandom, ¡CryptGenRandom, ¡… ¡

slide-5
SLIDE 5

Netscape ¡Navigator ¡

char ¡chall[16], ¡k[16]; ¡ ¡ srand(getpid() ¡+ ¡time(NULL) ¡ ¡ ¡ ¡ ¡ ¡ ¡+ ¡getppid()); ¡ for ¡(int ¡i=0; ¡i<16; ¡i++) ¡ ¡ ¡chal[i] ¡= ¡rand(); ¡ for ¡(int ¡i=0; ¡i<16; ¡i++) ¡ ¡ ¡chal[i] ¡= ¡rand(); ¡ ¡

slide-6
SLIDE 6

Netscape ¡Navigator ¡1.1 ¡

R, ¡{K}KS ¡, ¡{M}K, ¡… ¡ certS ¡

Client ¡ Server ¡

where ¡(R, ¡K) ¡= ¡hash(microseconds, ¡x) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡x ¡= ¡seconds ¡+ ¡pid ¡+ ¡(ppid ¡<< ¡12) ¡

slide-7
SLIDE 7

Netscape ¡Navigator ¡1.1 ¡

R, ¡{K}KS ¡, ¡{M}K, ¡… ¡ certS ¡

Client ¡ Server ¡

where ¡(R, ¡K) ¡= ¡hash(microseconds, ¡x) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡x ¡= ¡seconds ¡+ ¡pid ¡+ ¡(ppid ¡<< ¡12) ¡

A"ack: ¡Eavesdropper ¡can ¡guess ¡x ¡(≈ ¡10 ¡bits) ¡and ¡ microseconds ¡(20 ¡bits), ¡and ¡use ¡R ¡to ¡check ¡guess. ¡

slide-8
SLIDE 8

Bad ¡PRNGs ¡= ¡broken ¡crypto ¡

  • Netscape ¡server’s ¡private ¡keys ¡(≈ ¡32 ¡bits) ¡
  • Kerberos ¡v4’s ¡session ¡keys ¡(≈ ¡20 ¡bits) ¡
  • X11 ¡MIT-­‑MAGIC-­‑COOKIE1 ¡(8 ¡bits) ¡
  • Linux ¡vtun ¡(≈ ¡1 ¡bit) ¡
  • PlanetPoker ¡site ¡(≈ ¡18 ¡bits) ¡
  • CryptoAG ¡– ¡NSA ¡spiked ¡their ¡PRNG ¡
slide-9
SLIDE 9

#4: ¡Passphrases ¡Make ¡Poor ¡Keys ¡

  • Common ¡mistake: ¡Generate ¡crypto ¡key ¡as ¡

Hash(passphrase) ¡

  • Problem: ¡≈ ¡20 ¡bits ¡of ¡entropy; ¡even ¡with ¡a ¡slow ¡

hash, ¡this ¡is ¡not ¡nearly ¡enough. ¡ ¡Human-­‑ generated ¡secrets ¡just ¡don’t ¡have ¡enough ¡

  • entropy. ¡
  • SoluDon: ¡Crypto ¡keys ¡should ¡be ¡random. ¡
slide-10
SLIDE 10

#5: ¡Be ¡Secure ¡By ¡Default ¡

  • Common ¡mistake: ¡Security ¡is ¡opDonal, ¡or ¡

configurable, ¡or ¡negoDable ¡

  • Fix: ¡There ¡is ¡one ¡mode ¡of ¡operaDon, ¡and ¡it ¡is ¡
  • secure. ¡ ¡No ¡human ¡configuraDon ¡needed. ¡

– e.g., ¡Skype ¡

slide-11
SLIDE 11
slide-12
SLIDE 12

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

If ¡both ¡endpoints ¡support ¡128-­‑bit ¡crypto: ¡

where ¡K ¡= ¡hash(password ¡|| ¡R) ¡

slide-13
SLIDE 13

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

If ¡both ¡endpoints ¡support ¡128-­‑bit ¡crypto: ¡

where ¡K ¡= ¡hash(password ¡|| ¡R) ¡

A"ack ¡1: ¡Eavesdropper ¡can ¡try ¡dicBonary ¡search ¡

  • n ¡password, ¡given ¡some ¡known ¡plaintext. ¡
slide-14
SLIDE 14

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

If ¡both ¡endpoints ¡support ¡128-­‑bit ¡crypto: ¡

where ¡K ¡= ¡hash(password ¡|| ¡R) ¡

A"ack ¡2: ¡AcBve ¡a"acker ¡can ¡tamper ¡with ¡packets ¡ by ¡flipping ¡bits, ¡since ¡there ¡is ¡no ¡MAC. ¡

slide-15
SLIDE 15

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

Client ¡ Server ¡

where ¡K ¡= ¡hash(password ¡|| ¡R) ¡

A"ack ¡3: ¡Bad ¡guy ¡can ¡replay ¡a ¡prior ¡session, ¡since ¡ client ¡doesn’t ¡contribute ¡a ¡nonce. ¡

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

Client ¡ Bad ¡Guy ¡

slide-16
SLIDE 16

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

Client ¡ Server ¡

where ¡K ¡= ¡hash(password ¡|| ¡R) ¡

A"ack ¡4: ¡Bad ¡guy ¡can ¡replay ¡and ¡reverse ¡message ¡ direcBon, ¡since ¡same ¡key ¡used ¡in ¡both ¡direcBons. ¡

M ¡⊕ ¡RC4(K) ¡ So ¡do ¡I. ¡ ¡Here’s ¡a ¡nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡crypto ¡

Client ¡ Bad ¡Guy ¡

slide-17
SLIDE 17

M ¡⊕ ¡RC4(K) ¡ I ¡don’t. ¡ ¡Use ¡40-­‑bit ¡crypto ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

If ¡one ¡endpoint ¡doesn’t ¡support ¡128-­‑bit ¡crypto: ¡

where ¡K ¡= ¡hash(uppercase(password)) ¡

slide-18
SLIDE 18

M ¡⊕ ¡RC4(K) ¡ I ¡don’t. ¡ ¡Use ¡40-­‑bit ¡crypto ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

If ¡one ¡endpoint ¡doesn’t ¡support ¡128-­‑bit ¡crypto: ¡

where ¡K ¡= ¡hash(uppercase(password)) ¡

A"ack ¡1: ¡Eavesdropper ¡can ¡try ¡dicBonary ¡search ¡

  • n ¡password, ¡given ¡some ¡known ¡plaintext. ¡
slide-19
SLIDE 19

M ¡⊕ ¡RC4(K) ¡ I ¡don’t. ¡ ¡Use ¡40-­‑bit ¡crypto ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

If ¡one ¡endpoint ¡doesn’t ¡support ¡128-­‑bit ¡crypto: ¡

where ¡K ¡= ¡hash(uppercase(password)) ¡

A"ack ¡2: ¡DicBonary ¡search ¡can ¡be ¡sped ¡up ¡with ¡ precomputed ¡table ¡(given ¡known ¡plaintext). ¡

slide-20
SLIDE 20

M ¡⊕ ¡RC4(K) ¡ I ¡don’t. ¡ ¡Use ¡40-­‑bit ¡crypto ¡ I ¡support ¡128-­‑bit ¡crypto ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡

where ¡K ¡= ¡hash(uppercase(password)) ¡

A"ack ¡3: ¡Imposter ¡server ¡can ¡downgrade ¡client ¡to ¡ 40-­‑bit ¡crypto, ¡then ¡crack ¡password. ¡

Bad ¡Guy ¡

slide-21
SLIDE 21

M ¡⊕ ¡RC4(K) ¡ I ¡don’t. ¡ ¡Use ¡40-­‑bit ¡ I ¡support ¡128-­‑bit ¡

MS ¡Point-­‑to-­‑Point ¡EncrypDon ¡(MPPE) ¡

Client ¡ Server ¡

where ¡K ¡ ¡= ¡hash(uppercase(password)), ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡K’ ¡= ¡hash(password ¡|| ¡R) ¡

A"ack ¡4: ¡Man-­‑in-­‑the-­‑middle ¡can ¡downgrade ¡ crypto ¡strength ¡even ¡if ¡both ¡client ¡+ ¡server ¡ support ¡128-­‑bit ¡crypto, ¡then ¡crack ¡password. ¡

Bad ¡ Guy ¡ M’ ¡⊕ ¡RC4(K’) ¡ So ¡do ¡I. ¡ ¡Nonce: ¡R ¡ I ¡support ¡128-­‑bit ¡

slide-22
SLIDE 22

#6: ¡Careful ¡with ¡ConcatenaDon ¡

  • Common ¡mistake: ¡Hash(S||T) ¡

– “builDn” ¡|| ¡“securely” ¡= ¡“built” ¡|| ¡“insecurely” ¡

slide-23
SLIDE 23

Amazon ¡Web ¡Services ¡

hpp://amazon.com/set?u=daw&n=David&t=U&m=… ¡ MAC(K,”udawnDavidtU”) ¡

slide-24
SLIDE 24

Amazon ¡Web ¡Services ¡

hpp://amazon.com/set?u=daw&n=DavidtAq&t=U&m=… ¡ MAC(K,”udawnDavidtAqtU”) ¡ hpp://amazon.com/set?u=daw&n=David&t=A&qt=U&m=… ¡

slide-25
SLIDE 25

#6: ¡Careful ¡with ¡ConcatenaDon ¡

  • Common ¡mistake: ¡Hash(S||T) ¡

– “builDn” ¡|| ¡“securely” ¡= ¡“built” ¡|| ¡“insecurely” ¡

  • Fix: ¡Hash(len(S) ¡|| ¡S ¡|| ¡T) ¡
  • Make ¡sure ¡inputs ¡to ¡hash/MAC ¡are ¡uniquely ¡

decodable ¡

slide-26
SLIDE 26

#7: ¡Don’t ¡re-­‑use ¡nonces/IVs ¡

  • Re-­‑using ¡a ¡nonce ¡or ¡IV ¡leads ¡to ¡catastrophic ¡

security ¡failure. ¡

slide-27
SLIDE 27

Credit ¡card ¡numbers ¡in ¡a ¡database ¡

slide-28
SLIDE 28

Auer ¡Base64 ¡decoding ¡