EE817/IS893 CryptographyEngineeringand Cryptocurrency YongdaeKim - - PowerPoint PPT Presentation

ee817 is 893 cryptography engineering and cryptocurrency
SMART_READER_LITE
LIVE PREVIEW

EE817/IS893 CryptographyEngineeringand Cryptocurrency YongdaeKim - - PowerPoint PPT Presentation

EE817/IS893 CryptographyEngineeringand Cryptocurrency YongdaeKim Definition q A hashfunction isafunctionh compression


slide-1
SLIDE 1

EE817/IS893 CryptographyEngineeringand Cryptocurrency

YongdaeKim 한국과학기술원

slide-2
SLIDE 2

Definition

q Ahashfunctionisafunctionh

▹ compression—hmapsaninputxofarbitraryfinitebitlength,toan

  • utputh(x)offixedbitlengthn.

▹ easeofcomputation—h(x)iseasytocomputeforgivenxandh

q preimageresistance=one-way

▹ itiscomputationallyinfeasibletofindanyinputwhichhashestothatoutput

q 2nd-preimageresistance=weakcollisionresistance

▹ itiscomputationallyinfeasibletofindanysecondinputwhichhasthesameoutputas

anyspecifiedinput q collisionresistance=strongcollisionresistance

▹ itiscomputationallyinfeasibletofindanytwodistinctinputsx,x’whichhashtothe

sameoutput

slide-3
SLIDE 3

Merkle-Damgardscheme

q Themostpopularandstraightforward

methodforcombiningcompression functions

slide-4
SLIDE 4

StrengthenedMerkle-Damgard

slide-5
SLIDE 5

Collisionresistance

q Ifthecompressionfunctioniscollision

resistant,thenstrengthenedMerkle-Damgard hashfunctionisalsocollisionresistant

q Collisionofcompressionfunction:

f(s,x)=f(s’,x’)but(s,x)≠(s’,x’)

slide-6
SLIDE 6

Collisionresistance

q Ifh(,)iscollision

resistant,andif H(M)=H(N),then len(M)shouldbe len(N),andthelast blocksshouldcoincide

slide-7
SLIDE 7

Collisionresistance

slide-8
SLIDE 8

Collisionresistance

q Andthepenultimate

blocksshouldagree, and,

slide-9
SLIDE 9

Collisionresistance

q Andtheonesbefore

thepenultimate, too...

q SoinfactM=N

slide-10
SLIDE 10

Extensionproperty

q ForaMerkle-Damgardhashfunction,

H(x,y)=h(H(x),y)

▹ Evenifyoudon’tknowx,ifyouknowH(x),youcan

computeH(x,y)

▹ H(x,y)andH(x)arerelatedbytheformula ▹ WouldthisbepossibleifH()wasarandomfunction?

slide-11
SLIDE 11

FixingMerkle-Damgard

q Merkle-Damgard:historicallyimportant,still

relevant,butlikelywillnotbeusedinthefuture (likeinSHA-3)

q Clearlydistinguishablefromarandomoracle q Howtofixit?Simple:dosomethingcompletely

differentintheend

slide-12
SLIDE 12

SMD

slide-13
SLIDE 13

EMD

q IV1≠IV2

slide-14
SLIDE 14

MDP

q π:apermutationwithfewfixedpoints

▹ Forexample,π(x)=x⊕CforsomeC≠0

slide-15
SLIDE 15

HashChain

q h:Cryptographicallystronghashfunction q H0=x q Hn=h(Hn-1)=h(h(h(…h(x)))) q Randommappingstatistics

14

slide-16
SLIDE 16

Onetimepassword

q Setup

▹ UsergeneratesH0,H1,…Hn. ▹ UseràServer:Hn ▹ ServerstoresHnastheuser’spublicpassword.

q Authentication

▹ Attime0:UseràServer:Hn-1 ▹ Serververifiesh(Hn-1)=Hn ▹ ServerstoredHn-1astheuser’spublicpassword. ▹ Attime1:UseràServer:Hn-2 ▹ …

slide-17
SLIDE 17

HashTree

B1 H8 B2 H9 H4 B3 H10 B4 H11 H5 H2 B5 H12 B6 H13 H6 B7 H14 B8 H15 H7 H3 H1

Hi=h(H2i,H2i+1)

slide-18
SLIDE 18

MAC&AE

slide-19
SLIDE 19

MAC

q MessageAuthenticationCode q ‘keyedhashfunction’Hk(x)

▹ k:secretkey,x:messageofanylength,

Hk(x):fixedlength(say,128bits)

▹ deterministic

q Purpose:to‘prove’tosomeonewhohasthesecret

keyk,thatxiswrittenbysomeonewhoalsohas thesecretkeyk

18

slide-20
SLIDE 20

Howtouse?

q A&Bshareasecretkeyk q AsendsthemessagexandtheMACM←Hk(x) q BreceivesxandMfromA q BcomputesHk(x)withreceivedM q BchecksifM=Hk(x)

slide-21
SLIDE 21

Attackscenario

q Emayeavesdropmanycommunications(x,M)

betweenA&B

q Ethentries(possiblymanytimes)to‘forge’(x’,

M’)sothatBaccepts:M’=Hk(x’)

q Question:whatifE‘replays’oldtransmission(x,

M)?Isthisasuccessfulforgery?

slide-22
SLIDE 22

Capabilitiesofattackers

q Known-textattack

▹ Simpleeavesdropping

q Chosen-textattack

▹ AttackerinfluencesAlice’smessages

q Adaptivechosen-textattack

▹ AttackeradaptivelyinfluencesAlice

slide-23
SLIDE 23

Typesofforgery

q Universalforgery:attackercanforgeaMACfor

anymessage

q Selectiveforgery:attackercanforgeaMACfora

messagechosenbeforetheattack

q Existentialforgery:attackercanforgesome

messagexbutingeneralcannotchoosexashe wishes

slide-24
SLIDE 24

SecurityofMAC

q Shouldbesecureagainstadaptivelychosen-

messageexistentialforger

▹ Attackermaywatchmanypairs(x,Hk(x)) ▹ Mayeventryxofhischoice ▹ Maytrymanyverificationattempts(x,M) ▹ Stillshouldn’tbeabletoforgeanewmessageatall

slide-25
SLIDE 25

Twoeasyattacks

q Exhaustivekeysearch

▹ Givenonepair(x,M),trydifferentkeysuntil

M=Hk(x)

▹ Lesson:keysizeshouldbelargeenough

q Pureguessing:trymanydifferentMwithafixed

messagex

▹ Lesson:MAClengthshouldbealsolarge

q Question:whichoneismoreserious?

24

slide-26
SLIDE 26

RandomfunctionasMAC

q SupposeAandBsharearandomfunctionR(x),

whichassignsrandom128-bitvaluetoitsinputx

q EvenifEseesmanymessagesofform(x,R(x)),

foranewy,R(y)canbeanyof2128strings

q Successfulforgeryprob.≤2-128

slide-27
SLIDE 27

RandomfunctionasMAC

q ItisaperfectMAC,butthe‘keysize’istoo

large:howmanyfunctionsofform R:{0,1}m→{0,1}n?Answer:2^(n2m)

q Buttherearekeyedfunctionswhichare

‘indistinguishable’fromrandomfunctions:called PRFs(PseudoRandomFunctions)

q DesigningasecurePRFisagoodwaytodesigna

secureMAC

slide-28
SLIDE 28

TruncationofMAC

q Hk(x)isasecureMACwith256-bitoutput q H’k(x)=thefirst128bitsofHk(x) q Question:isH’k(x)asecureMAC?

27

  • Answer:notingeneral,butsecureifHk(x)isasecurePRF
slide-29
SLIDE 29

Practicalconstructions

q BlockcipherbasedMACs

▹ CBC-MAC ▹ CMAC

q HashfunctionbasedMACs

▹ secretprefix,secretsuffix,envelop ▹ HMAC

slide-30
SLIDE 30

CBC-MAC

q CBC,withsomefixedIV.Last‘ciphertext’istheMAC q BlockciphersarealreadyPRFs.CBC-MACisjustawaytocombine

them

q SecureasPRF,ifmessagelengthisfixed

slide-31
SLIDE 31

CBC-MAC

q SecureasPRF,ifmessagelengthisfixed q Completelyinsecureifthelengthisvariable!!!

slide-32
SLIDE 32

CBC-MAC

q ‘Extensionproperty’oncemore! q Howtofixit? ▹ Again,dosomethingdifferentattheend

tobreakthechain

slide-33
SLIDE 33

Modification1

▹ Useadifferentkeyattheend ▹ Good:thissolvestheproblem ▹ Bad:switchingblockcipherkeyisbad

slide-34
SLIDE 34

Modification2

▹ XORingadifferentkeyattheinputis

indistinguishablefromswitchingtheblockcipher key

slide-35
SLIDE 35

CMAC

q NISTstandard(2005) q SolvestwoshortcomingsofCBC-MAC

▹ variablelengthsupport ▹ messagelengthdoesn’thavetobemultipleofthe

blockciphersize

slide-36
SLIDE 36

SomeHash-basedMACs

q Secretprefixmethod:Hk(x)=H(k,x) q Secretsuffixmethod:Hk(x)=H(x,k) q Envelopemethodwithpadding:

Hk(x)=H(k,p,x,k)

slide-37
SLIDE 37

Secretprefixmethod

q Secretprefixmethod:Hk(x)=H(k,x)

▹ SecureifHisarandomfunction ▹ InsecureifHisaMerkle-Damgardhashfunction

» Hk(x,y)=h(H(k,x),y)=h(Hk(x),y)

slide-38
SLIDE 38

Secretsuffixmethod

q Secretsuffixmethod:Hk(x)=H(x,k)

▹ Muchsecurerthansecretprefix,evenifHis

Merkle-Damgard

▹ Anattackofcomplexity2n/2exists:

» AssumethatHisMerkle-Damgard » FindhashcollisionH(x)=H(y) » Hk(x)=h(H(x),k)=h(H(y),k)=Hk(y) » off-line!

37

slide-39
SLIDE 39

Envelopemethod

q Envelopemethodwithpadding:

Hk(x)=H(k,p,x,k)

▹ Forsomepaddingptomakek||patleastoneblock

q Preventsbothattacks

slide-40
SLIDE 40

HMAC

q NISTstandard(2002) q HMACk(x)=H(K⊕opad||H(K⊕ipad||x)) q ProvensecureasPRF,ifthecompression

functionhofHsatisfiessomeproperties

39

M

1

HMAC Hash

F

M

t

F F

KI KO

IV K ipad

F

IV K

  • pad

F

slide-41
SLIDE 41

MACvsSignature

q secretkeyvs.publickey q privateverificationvs.publicverification q MACdoesn’tprovidenon-repudiation

▹ BobclaimsthatAlicesends(x,M),showingthat

M=Hk(x).Whoelsecanwritethismessage?

slide-42
SLIDE 42

Confidentiality&integrity

q Twosymmetrickeyprimitives

▹ Encryptionscheme:protectsconfidentiality ▹ MAC:protectsintegrity

q Usually,whatwewantistoprotectboth

41

slide-43
SLIDE 43

Encryptionnotenough?

q ‘It’sencryptedsonobodycanalterit!’ q C=Ek(P) q Ifanystringisavalidciphertext(e.g.,a

blockcipher),modifyingCtoC’willalteryourP (toP’,perhapsagarbage)

▹ Question:isthisaproblem?

slide-44
SLIDE 44

Givingredundancy

q Solution:notallstringsarevalidciphertext

▹ Formatplaintextwithsomeredundancy ▹ Onlycorrectlyformattedplaintextistobeaccepted ▹ Example,C=Ek(P||P),orC=Ek(P||H(P)) ▹ Becareful:whatifEk()isastreamcipher?

slide-45
SLIDE 45

Genericcomposition

q Insteadofusinganad-hocmethod, q Combineasecureencryptionscheme(say,CBC,

CTR)andasecureMAC(say,CMAC,HMAC)

▹ Twokeysareneeded ▹ Howtocombinetwo? ▹ ‘Generic’heremeans‘black-box’

slide-46
SLIDE 46

Genericcomposition

q MAC-and-Encrypt:Eke(P)||Mkm(P) q MAC-then-Encrypt:Eke(P||Mkm(P)) q Encrypt-then-MAC:Eke(P)||Mkm(Eke(P))

slide-47
SLIDE 47

Questions?

q YongdaeKim

▹ email: yongdaek@kaist.ac.kr ▹ Home: http://syssec.kaist.ac.kr/~yongdaek ▹ Facebook: https://www.facebook.com/y0ngdaek ▹ Twitter: https://twitter.com/yongdaek ▹ Google “Yongdae Kim”

46