Upgrade to Pro — share decks privately, control downloads, hide ads and more …

No More Crypto Fails

Inndy
March 18, 2017

No More Crypto Fails

2017/03/18 at SITCON 2017

Inndy

March 18, 2017
Tweet

More Decks by Inndy

Other Decks in Technology

Transcript

  1. /P.PSF$SZQUP'BJMT
    植➿㺙焺㷸ⰅꟌ
    *OOEZ!4*5$0/

    View full-size slide

  2. "CPVU.F
    ˙ *OOEZBLB加啄
    ˙ $5'1MBZFS
    ˙ 1ZUIPOHVZ
    ˙ "NBUFVSTFDVSJUZSFTFBSDIFS
    ˙ 'PPMTUBDLFOHJOFFSBU4IBSFMJLF

    View full-size slide

  3. 㖈鸏㜥怵闍⚥
    ˙ ➝稲管焺꧹廔⸈㺙僽➊랃
    ˙ 雊㣐㹻㼩倴植➿㺙焺㷸涸䥰欽剤♧㹁玑䏞涸澗鍑
    ˙ 䌢鋅涸㺙焺㷸ꐫ铐莅㉏겗

    View full-size slide

  4. 㥶卓⡹濼麥
    ˙ #BTF
    ˙ 3BJOCPX5BCMF
    ˙ 1#,%' TDSZQU CDSZQU BSHPOⰦ⚥⛓♧
    ˙ #MPDL$JQIFS
    ˙ 13/(
    ˙ 1BEEJOH0SBDMF

    View full-size slide

  5. 须俲㋲⡙
    ˙ ♧⦐✳鹎⡙侸㶶珖⡲♧⦐⡙⯋ CJU

    ˙
    ˙ Ⰽ⦐⼧Ⱉ鹎⡙侸㶶珖⡲♧⦐⡙⯋穉 CZUF

    ˙ _Y_Y''
    5

    View full-size slide

  6. 9PS
    ˙ 9PS僽♧珏齅鱀麌皿
    ˙ ?
    ˙ ?
    ˙ ?
    ˙ ?
    ˙ 湱ず捀湱殯捀
    6

    View full-size slide

  7. 9PS
    ˙ Ⰽ⦐侸㶶⨞YPS麌皿儘
    ˙ ⟃✳鹎⡙⢵溏鷷⦐CJU⨞麌皿
    ˙ 玑䒭⚥䌢欽?痘贫侸㷸♳䌢欽ͩ
    ˙ ?

    ?




    7

    View full-size slide

  8. 俒㶶6OJDPEF管焺
    㺙 Y#$ &"'
    㶶 6OJDPEF 65'管焺


    8

    View full-size slide

  9. ➊랃♶僽⸈㺙
    ˙ ♶僽雊匌銯溏饱⢵♶♧垺㽠僽⸈㺙 &ODSZQU

    ˙ Ⰽ珏⫹僽⸈㺙涸匌銯
    ˙ 管焺 &ODPEF

    ˙ ꧹廔 )BTI

    9

    View full-size slide

  10. 管焺 &ODPEF

    ˙ ⫄鱒麕玑〫⯈鏪暶㹁涸㶶⯋꧌ $IBSTFU

    ˙ ⢿㥶傍劍涸&NBJM〫⯈鏪秫"4$**
    ˙ &NBJM酭꬗剤㕬晚䧴Ⱖ➮꣡⟝䙦랃鳵
    ˙ 䪾须俲欽厥珏倰䒭管焺䧭"4$**㶶⯋꧌
    10

    View full-size slide

  11. 管焺 &ODPEF

    ˙ )FY⼧Ⱉ鹎⡙管焺
    ˙ "#$̔FF
    ˙ CBTF
    ˙ "#$̔26+%.5*[/"
    ˙ Ⱖ➮刿㢵涸管焺锞溏笞㛇涰猰
    11

    View full-size slide

  12. #BTF
    ˙ ⟃CZUFT"4$**⢵邍爚CZUFT须俲
    ˙ 䨾⟃须俲넓琎剚隶㣐⦔
    ˙ 嫦⦐CBTF㶶⯋⺫わCJUT涸须俲
    ˙ 籏Ⱏ剤⦐"4$**㶶⯋"; B[ 
    ˙ 㥶卓须俲♶僽涸⦔侸⵱꨾銴⢪欽㞅⯏
    12

    View full-size slide

  13. 管焺 &ODPEF

    ˙ 䭭⢵չ⸈㺙պ僈滚➃♧溏㽠濼麥
    ˙ 㺙焺涸㉏겗䧮⦛瘞瘞ⱄ锓
    13

    View full-size slide

  14. ꧹廔 )BTI

    ˙ 䪾⟤䠑Ꟁ䏞涸须俲㠺簮䧭㔿㹁Ꟁ䏞涸须俲
    ˙ 鱒ⴀ须俲➿邍鱒Ⰵ涸䶰銴EJHFTU
    ˙ ず垺涸鱒Ⰵ剚䖤ⵌ♧垺涸穡卓
    ˙ ♶ず涸IBTI⧩邍爚鱒Ⰵ须俲♶ず
    14

    View full-size slide

  15. ꧹廔 )BTI

    # Python
    def my_hash(data):
    return sum(bytearray(data.encode())) % 256
    // C
    int my_hash(char *data, size_t len) {
    int i, H = 0;
    for(i = 0; i < len; i++)
    H = (H + data[i]) % 256;
    return H;
    }
    15

    View full-size slide

  16. ꧹廔 )BTI

    • my_hash("Hash") == 132
    • my_hash("Inndy") == 2
    • my_hash("SITCON") == 208
    • my_hash("SITCON2017") == 154
    16

    View full-size slide

  17. ꧹廔涸欽鸁
    ˙ ꧹廔邍 )BTI5BCMF
    须俲穡圓
    ˙ 焷⥃须俲㸤侮䚍
    ˙ ♴鯺㣐墂呪增叆IBTI⢵焷㹁墂呪尝剤䴦㡏
    ˙ 侸⡙砞畎
    ˙ 笪畀盘椚㆞ㄤ㹐剪鿪濼麥⡹涸㺙焺
    ˙ ⥃㶸⢪欽罏涸㺙焺儘䥰鑪⥃㶸㺙焺涸꧹廔⧩
    17

    View full-size slide

  18. 䌢鋅涸꧹廔
    ˙ $3$
    ˙ .%
    ˙ 4)"
    ˙ 4)"
    18

    View full-size slide

  19. ꧹廔莅㸞
    ˙ ꧹廔焥中
    ˙ 侸⡙砞畎
    ˙ 㺙焺⥃㶸
    ˙ Ꟁ䏞䒂㾝余乹 -FOHUI&YUFOTJPO"UUBDL

    19

    View full-size slide

  20. ꧹廔焥中
    ˙ ⢵闍♧럊齅鱀
    ˙ 蕰1⵱2
    ˙ 蕰ꬌ2⵱ꬌ1
    ˙ 蕰ꬌ1⵱ꬌ2̒鸏♶䧭用
    ˙ 蕰2⵱1̒鸏⛳♶䧭用
    20

    View full-size slide

  21. ꧹廔焥中
    ˙ 1徍宐2尝鳵岁ㄎ
    ˙ 㥶卓䧮徍宐䧮㽠尝鳵岁ㄎ
    ˙ 㥶卓䧮〳⟃ㄎ䧮㽠尝剤徍宐
    ˙ 㥶卓䧮尝鳵岁ㄎ䧮㽠徍宐
    ˙ 铞♶㹁䧮뢙㝱ザ
    21

    View full-size slide

  22. ꧹廔焥中
    ˙ 1㺙焺鱒Ⰵ姻焷
    ˙ 2) JOQVU
    瘞倴
    ˙ 㥶卓㺙焺鱒Ⰵ姻焷⵱) JOQVU
    瘞倴
    ˙ 㥶卓) JOQVU
    ♶瘞倴⵱㺙焺鱒Ⰵꐫ铐
    ˙ 㥶卓) JOQVU
    瘞倴⵱㺙焺鱒Ⰵ姻焷
    ˙ ꧹廔焥中 )BTI$PMMJTJPO

    22

    View full-size slide

  23. ꧹廔焥中
    ˙ 鱒ⰅꟀ䏞♶ꣳ⡎僽鱒ⴀ穡卓剤ꣳ
    ˙ 籏僽〳⟃䪪ⵌⰍ⦐鱒Ⰵ欴欰♧垺涸꧹廔⧩
    23

    View full-size slide

  24. ꧹廔焥中
    • my_hash("cActo4ri5Hm3OZzB") == 123
    • my_hash("ABCDEFGHIJKLMN9Y") == 123
    • my_hash("0123456789fkcecr") == 123
    • my_hash("Collision_Yhpvah") == 123
    • my_hash("I am Inndy_5pRRz") == 123
    • my_hash("SITCON 2017_N4hx") == 123
    24

    View full-size slide

  25. ꧹廔焥中
    ˙ 곏搭䧮ⶍⶍ涮僈涸NZ@IBTI湱殹腛䓳
    ˙ /PODSZQUPHSBQIJDIBTIGVODUJPO
    ˙ 殹䪪ⵌ佪桧넞倴凐⸂灶鍑涸焥中倰岁
    ˙ 䧮⦛㽠铞鸏⦐꧹廔倰岁鄄չ灶鍑պ✫
    ˙ .%欽⦐➃ꨶ舡〳⟃㸤䧭
    ˙ 4IBUUFSFE 4)"DPMMJTJPO
    CZ(PPHMFBOE$8*
    25

    View full-size slide

  26. 侸⡙砞畎
    ˙ 焷⥃鎝䜂尝剤鄄睕佖罜⚂♶僽⩝鸤涸
    ˙ 䧮ㄤ⡹Ⱏ剤♧䪾㺙ꚤ尝剤痧♲⦐➃濼麥
    ˙ $*"/4"ㄤ(PPHMF⛳♶濼麥
    ˙ ⫄鷑鎝䜂⟃⿻)BTI 鎝䜂Ⱏ❧㺙ꚤ

    ˙ 䱺佐鎝䜂涸儘⦬增叆)BTI 鎝䜂Ⱏ❧㺙ꚤ

    ˙ 欽)."$䖕꬗剚䲿ⵌ
    26

    View full-size slide

  27. 㺙焺⥃㶸
    ˙ 剪⹡䲿⣘罏䙦랃⥃㶸⢪欽罏㺙焺
    ˙ ⥃㶸㺙焺涸꧹廔⧩
    ˙ 盘椚㆞ㄤ㹐剪㽠♶濼麥⡹涸㺙焺✫
    27

    View full-size slide

  28. 㺙焺⥃㶸
    ˙ 笪畀鄄Ⰵ⡹涸㺙焺鼩僽尝剤➃濼麥㌨
    ˙ 凐⸂灶鍑#SVUFGPSDF(16⸈鸠
    ˙ 䕙赙邍3BJOCPX5BCMF
    ˙ 갸⯓鎙皿僈俒莅꧹廔⧩
    ˙ 㶶Ⱙ余乹
    ˙ 欽䌢鋅涸㋲㶶欴欰〳腋涸穉ざ㺙焺
    28

    View full-size slide

  29. 㺙焺⥃㶸
    ˙ )."$锅㄂⸈뛥,FZFE)BTI 4BMUFE)BTI
    ˙ IBTI 㺙焺TBMU

    ˙ )."$僽겳⡂涸嚌䙂⡎僽剤暶㹁涸㻜⡲倰䒭
    ˙ 湬䱺⢪欽㼠Ꟍ捀㺙焺鏤鎙涸꧹廔倰岁
    ˙ "SHPO 1#,%' TDSZQU CDSZQU
    29

    View full-size slide

  30. Ꟁ䏞䒂㾝余乹
    ˙ 䊺濼) LFZEBUB
    ⟃⿻EBUB⡎♶濼麥LFZ
    ˙ 〳⟃皿ⴀ) LFZEBUBQBEEJOHFWJM

    ˙ 〳⟃㖈剤IBTI增叆涸朜屣♴幑⸈겙㢫须俲
    ˙ .% 4)" 4)" 4)"鿪「ⵌ䕧갠
    ˙ 䊨ⰨIBTIQVNQ
    ˙ ⢪欽)."$⽰〳鼚⯝
    30

    View full-size slide

  31. ➊랃僽⸈㺙
    ˙ 麕玑꨾銴㺙ꚤ ,FZ

    ˙ ♶濼麥㺙ꚤ㽠尝鳵岁鍑㺙
    ˙ ⸈㺙怵皿岁ⰗꟚ⛳♶剚鸤䧭㺙俒鄄灶陼
    ˙ ♶搭㽠僽鸏⦐怵皿岁剤緄ꤴ䧴僽䖕Ꟍ
    31

    View full-size slide

  32. 锓⸈㺙⛓⵹
    ˙ 㔔捀⸈㺙꨾銴㺙ꚤ鸒䌢僽չꦑ堥欴欰պ
    ˙ 㣐鿈ⴕ玑䒭铃鎊䲿⣘涸✥侸僽չ⩝ꦑ堥侸պ
    ˙ ⢪欽⩝ꦑ堥侸⢵欴欰㺙ꚤ僽剤괐ꦖ涸
    32

    View full-size slide

  33. ⩝ꦑ堥侸欴欰㐼 13/(

    ˙ ⯓歋♧⦐珏㶩 TFFE
    ⴲ㨥⻋✥侸朜䢀 TUBUF

    ˙ ⱄ竤歋暶㹁涸怵皿䌢欰ꦑ堥侸
    ˙ 製꧌㣁㢵涸✥侸䖕〳⟃凐⸂灶鍑䧴僽皿ⴀTFFE
    ˙ 䘎鎹ⴲ㨥⻋㽠Ꟛ㨥欽⵱剚欴欰ⴀ♧垺涸ꦑ堥侸
    ˙ 㣐㢵侸➃剚欽儘꟦⢵殹⡲ⴲ㨥⻋⿮侸
    33

    View full-size slide

  34. ⩝ꦑ堥侸欴欰㐼 13/(

    ˙ HMJCD傍劍涸㻜⡲箁䚍ず긅 -$(

    ˙ SFUVSOTUBUF TUBUFYDFE


    YG
    ˙ 濼麥♧⦐✥侸㽠〳⟃湬䱺皿ⴀ⛓䖕涸䨾剤✥侸
    ˙ ⛳㽠僽〳⟃갸庠劢⢵涸✥侸
    ˙ 歋倴TUBUF剤ꣳ䨾⟃✥侸剚鹋劍䚍涸ꅾ醳
    34

    View full-size slide

  35. 㺙ꚤ欴欰莅13/(
    ˙ TSBOE UJNF /6--

    $
    ˙ 䧮㥶卓濼麥⡹欽涸僽➊랃13/(
    ˙ ⿶濼麥㺙ꚤ欴欰涸儘꟦㣐嚌僽➊랃儘⦬
    35

    View full-size slide

  36. 㺙ꚤ欴欰
    ˙ 欴欰⸈㺙㺙ꚤ涸儘⦬銴⢪欽04䲿⣘涸㸞✥侸
    ˙ 䖰炽넓製꧌涸须鎝✥䏞 FOUSPQZ
    嫲鯱넞
    ˙ 㼩倴㸞銴宠溫涸䖎넞欩荛剚⢪欽㼠Ꟍ涸炽넓
    ˙ 製꧌㢫歲涸暟椚꧹鎝⟃㟞⸈✥䏞
    ˙ EFWVSBOEPNGPS6/*9
    ˙ $SZQU(FO3BOEPNGPS8JOEPXT
    36

    View full-size slide

  37. ⸈㺙禺窡ⴕ겳
    ˙ 呏亙⸈㺙禺窡涸麌⡲倰䒭ⴕ䧭♲珏
    ˙ 㼩珖䒭
    ˙ ⴕ穉⸈㺙 #MPDL$JQIFS

    ˙ ⚮崩⸈㺙 4USFBN$JQIFS

    ˙ ꬌ㼩珖
    ˙ ⰗꟚꆄꚤ禺窡 1VCMJD,FZ&ODSZQUJPO

    37

    View full-size slide

  38. ⚮崩⸈㺙
    ˙ 㛇倴YPS涸⸈㺙倰䒭
    ˙ 1YPS,$ $YPS,1
    ˙ 䪾LFZ깐鹎⿡⛓䖕皿ⴀLFZTUSFBN
    ˙ 僈俒㺙俒YPSLFZTUSFBN㽠㸤䧭⸈鍑㺙
    ˙ 㛇劥♳㽠僽⦐13/(♶麕䗳갭銴⨞ⵌꨈ⟃갸庠
    38

    View full-size slide

  39. ⚮崩⸈㺙
    ˙ 㺙ꚤ♶〳⟃ꅾ醳⢪欽
    ˙ & 9 ,
    邍爚⟃㺙ꚤ,⸈㺙须俲9
    ˙ & 9 ,
    9?13/( ,

    ˙ & " ,
    ?& # ,
    "?L
    ? #?L
    "?#
    ˙ 㼩倴僈俒剤㣁㢵涸澗鍑㽠〳⟃灶㺙
    39

    View full-size slide

  40. ⚮崩⸈㺙
    ˙ 㔔捀劥颶♳僽13/(䨾⟃TUSFBNLFZ剚䗅橇
    ˙ ⸈㺙须俲Ꟁ䏞馄麕TUSFBNLFZ涸鹋劍銴㼭䗱
    ˙ 䊺濼僈俒涸鑨〳⟃睕佖须俲
    ˙ TUSFBN@LFZ㺙俒?僈俒
    ˙ ꨾銴)."$⢵焷⥃须俲㸤侮䚍
    40

    View full-size slide

  41. ⴕ穉⸈㺙
    ˙ 㛇劥穡圓僽♧⦐〳鷠ⴅ侸
    ˙ 剤ꣳ涸㹁纏㚖ㄤ剤ꣳ涸⧩㚖
    ˙ 鱒Ⰵㄤ鱒ⴀ涸须俲Ꟁ䏞㔿㹁
    ˙ ⢿㥶嫦妄㼟CZUFT僈俒⸈㺙䧭CZUFT㺙俒
    ˙ $& 1 ,
    % $ ,
    1
    ˙ 1僈俒$㺙俒,㺙ꚤ&⸈㺙%鍑㺙
    41

    View full-size slide

  42. ⴕ穉⸈㺙
    ˙ 㥶卓僈俒馄麕♧⦐CMPDL涸㣐㼭
    ˙ ꨾銴䪾麕Ꟁ涸僈俒㺙俒ⴕ䧭㢵㝆ⴕ妄贖椚
    ˙ 㥶卓僈俒♶ⵌ♧⦐CMPDL涸㣐㼭
    ˙ ꨾銴㞅⯏ QBEEJOH
    䪾Ꟁ䏞酢駈
    ˙ 1,$41,$4
    42

    View full-size slide

  43. 1,$4㞅⯏
    ˙ ず垺涸僈俒莅㺙ꚤ⸈㺙ⴀ⢵剚䖤ⵌ湱ず涸穡卓
    ˙ 䧮⦛䒸Ⰵ✫ⴲ㨥ぢꆀ *7
    堥ⵖ⢵贖椚鸏⦐㉏겗
    • n = BLK_SZ - (len(data) % BLK_SZ)
    • padding = byte(n) * n
    • "0123456789AB\x05\x05\x05\x05\x05"
    ˙ 瘞瘞䧮⦛剚㔐⢵溏1,$4鸤䧭涸㉏겗
    43

    View full-size slide

  44. ⴕ穉⸈㺙
    ˙ 䱰欽&$#垸䒭尝剤*7嫦⦐CMPDLぐ荈⸈㺙
    ˙ 湱ず僈俒⸈㺙穡卓♧垺㸪錚⢵溏
    44

    View full-size slide

  45. ⴕ穉⸈㺙䊨⡲垸䒭
    ˙ 㥶卓嫦⦐CMPDL鿪剤荈䊹涸*7须俲剚䧭ꟀⰍ⦔
    ˙ ⵹♧⦐CMPDL涸须俲㽠〳⟃䬄ⴀ⢵殹⡲*7欽
    ˙ 剤ぐ珏♶ず涸幋ざ倰䒭
    ˙ $#$ 0'# $'# $53
    ˙ 鸏酭䧮⦛ꆚ㼩$#$⨞铞僈
    ˙ Ⱖ➮倰䒭㖈笞㛇涰猰剤湱ず涸㕬鍑
    45

    View full-size slide

  46. $#$垸䒭⸈㺙
    Cipher Block Chaining (CBC) mode encryption
    block cipher
    encryption
    Key
    Ciphertext
    Plaintext
    block cipher
    encryption
    Key
    Ciphertext
    Plaintext
    block cipher
    encryption
    Key
    Ciphertext
    Plaintext
    Initialization Vector (IV)
    9PS
    *7<>
    *7<> *7<>
    46

    View full-size slide

  47. $#$垸䒭⸈㺙
    ˙ ♴⴪匌銯剚对㹁植㖈鸏㝆㺙俒涸Ⰹ㺂
    ˙ 鸏♧㝆僈俒
    ˙ 㺙ꚤ
    ˙ ♳♧㝆涸㺙俒䧴僽*7
    ˙ $<>*7
    ˙ $& $?1 ,

    47

    View full-size slide

  48. Cipher Block Chaining (CBC) mode decryption
    block cipher
    decryption
    Key
    Plaintext
    Ciphertext
    Initialization Vector (IV)
    block cipher
    decryption
    Key
    Plaintext
    Ciphertext
    block cipher
    decryption
    Key
    Plaintext
    Ciphertext
    $#$垸䒭鍑㺙
    *7<>
    *7<>
    *7<>
    48

    View full-size slide

  49. $#$垸䒭鍑㺙
    ˙ ♴⴪匌銯剚对㹁植㖈鸏㝆僈俒鍑ⴀ⢵涸Ⰹ㺂
    ˙ 鸏♧㝆㺙俒
    ˙ 㺙ꚤ
    ˙ ♳♧㝆涸㺙俒䧴僽*7
    ˙ $<>*7
    ˙ 1$?% $ ,

    49

    View full-size slide

  50. 1BEEJOH0SBDMF"UUBDL
    ˙ 䎃痧♧妄鄄䲿ⴀ⢵
    ˙ 3BJMT "41/&5 +BWB瘞㣐ꆀ笪畀「ⵌ䕧갠
    ˙ $#$垸䒭⸈♳1,$4㞅⯏倰䒭
    ˙ 㥶卓䧮⥜佖✫㺙俒灶㡏✫㞅⯏⧩
    ˙ ⡹欽涸⸈㺙玑䒭䏨〳腋剚UISPXFSSPS
    ˙ 尝剤DBUDI涸鑨⢪欽罏剚溏ⵌ
    ˙ 㼬荞〳⟃㖈劢濼㺙ꚤ涸䞕屣♴鍑㺙⥜佖Ⰹ㺂
    50

    View full-size slide

  51. ˙ ➊랃⯋稇剚䕧갠僈俒
    ˙ $JQIFSUFYU
    ˙ ,FZ
    ˙ *7䧴♳♧㝆㺙俒
    ˙ 䖰齡酭♴䩛嫲鯱㺂僒
    ˙ 齡䎙⦐僽䧮⦛濼麥罜⚂〳⟃䱾ⵖ涸
    1BEEJOH0SBDMF"UUBDL
    Cipher Block Chain
    block cipher
    decryption
    Key
    Plaintext
    Ciphertext
    Initialization Vector (IV)
    Key
    51

    View full-size slide

  52. 1BEEJOH0SBDMF"UUBDL
    ˙ 余乹㜥兞
    ˙ 笪畀䪾须俲⸈㺙䖕㶸㖈$PPLJF酭꬗
    ˙ ⡹濼麥*7ㄤ㺙俒尝剤,FZㄤ僈俒
    ˙ ⡹〳⟃⥜佖$PPLJF
    52

    View full-size slide

  53. 1BEEJOH0SBDMF"UUBDL
    ˙ 灶㡏*7
    ˙ 鑑衽⥜佖*7剓䖕♧⦐CZUF欴欰ⴀ穡㽵涸㞅⯏
    ˙ 鸏儘⦬䧮⦛㽠〳⟃皿ⴀ剓䖕♧⦐CZUF涸僈俒
    ˙ 䱺衽欴欰㽠〳⟃皿ⴀ剓䖕CZUFT僈俒
    ˙ ⟃姽겳䲀㽠〳⟃䗂⾲侮㝆僈俒
    53

    View full-size slide

  54. 1BEEJOH0SBDMF"UUBDL
    • Plain = "AESXX"
    • Key = "??!@#$!@#$"
    • P = 41 45 53 58 58
    • IV = c8 76 30 94 87
    • C = aa bb cc dd ee
    • c = 89 33 63 cc df
    54
    Cipher Block Chainin
    block cipher
    decryption
    Key
    Plaintext
    Ciphertext
    Initialization Vector (IV)
    Key
    $
    1
    *
    랱盳

    View full-size slide

  55. 1BEEJOH0SBDMF"UUBDL
    • IV = c8 76 30 94 87
    • c = 89 33 63 cc df
    • iv = 00 00 00 00 00
    • iv = 00 00 00 00 01
    • ...
    • iv = 00 00 00 00 de
    • 0xde ^ 0xdf = 0x01
    • p = 89 33 63 cc 01 // 正確的填充
    55
    Cipher Block Chainin
    block cipher
    decryption
    Key
    Plaintext
    Ciphertext
    Initialization Vector (IV)
    Key
    D
    1
    *
    랱盳

    View full-size slide

  56. 1BEEJOH0SBDMF"UUBDL
    • IV = c8 76 30 94 87
    • P = 41 45 53 58 58
    • c = 89 33 63 cc df
    • iv = 00 00 00 00 de
    • p = 89 33 63 cc 01 填充正確解密成功!
    • last byte: 0xde ^ 0x01 ^ 0x87 = 0x58
    • 接下來來做 02 02 結尾,解開倒數第⼆二 byte
    56

    View full-size slide

  57. 1BEEJOH0SBDMF"UUBDL
    ˙ 灶鍑䧭劥䖰CMPDL@TJ[F隶䧭CMPDL@TJ[F
    ˙ CJUT$JQIFS隶䧭
    ˙ 1BEEJOH0SBDMF涸䗳銴哭⟝
    ˙ 1,$4㞅⯏
    ˙ $#$垸䒭
    ˙ 1BEEJOH&SSPS鄄⢪欽罏溏ⵌ
    57

    View full-size slide

  58. 1BEEJOH0SBDMF"UUBDL
    ˙ 鍑对倰䒭
    ˙ &ODSZQUUIFO."$
    ˙ ♧傉Ⰹ㺂鄄睕佖㽠䬩穪鍑㺙
    ˙ ꦡ询1BEEJOH&SSPS鎝䜂
    ˙ ⡎僽〳腋剤Ⱖ➮倰䒭䖤濼 &Y5JNJOH"UUBDL

    ˙ ♶銴欽$#$.PEF
    58

    View full-size slide

  59. ⴕ穉⸈㺙籏穡
    ˙ *7涸欽䠑僽雊湱ず僈俒嫦妄⸈㺙涸穡卓♶ず
    ˙ ⹡䗳⢪欽㸞✥侸⚛⚂嫦妄ꅾ倞欴欰
    ˙ 〳⟃莅㺙俒♧饱㶸佞
    ˙ 䌢䌢佞㖈㺙俒涸痧♧⦐CMPDL
    ˙ 澗鍑ぐ珏ⴕ穉⸈㺙涸䊨⡲垸䒭
    ˙ 鼚⯝悴㖈涸괐ꦖ
    59

    View full-size slide

  60. ꬌ㼩珖⸈㺙
    ˙ 植➿㺙焺㷸剓ꅾ銴涸涮僈⛓♧
    ˙ 34"剓䌢鋅⛳剓䌢⢪欽
    ˙ 堬㕩刼箁㺙焺 &$$

    ˙ 欴欰LFZ剚欴ⴀ♧㼩Ⱇꚤ莅猙ꚤ
    ˙ Ⱇꚤ〳⟃ⰗꟚ窍Ⱖ➮➃
    ˙ 猙ꚤ〫剤⡹荈䊹䭰剤
    60

    View full-size slide

  61. ꬌ㼩珖⸈㺙
    ˙ Ⱇꚤ⸈㺙〫腋欽猙ꚤ鍑㺙
    ˙ 猙ꚤ⸈㺙〫腋欽Ⱇꚤ鍑㺙
    ˙ ⢪欽倰岁
    ˙ 〳⟃焷⥃须俲僽歋厥⦐➃⫄鷑涸
    ˙ 〳⟃焷⥃须俲〫剤厥⦐➃〳⟃隡《
    61

    View full-size slide

  62. ꬌ㼩珖⸈㺙
    ˙ 歋倴Ⱇꚤ禺窡涸麌皿鸠䏞鸒䌢嫲㼩珖⸈㺙䢩
    ˙ 䌢欽涸倰岁僽⯓⟃㼩珖䒭涸倰岁⸈㺙须俲
    ˙ ⱄ欽Ⱇꚤ禺窡⸈㺙㼩珖㺙焺涸㺙ꚤ
    ˙ 侸⡙砞畎⵱僽⯓IBTI须俲ⱄ⟃Ⱇꚤ⸈㺙IBTI
    ˙ 44-5-4)5514㽠僽㛇倴鸏珏倰岁䒊用涸
    62

    View full-size slide

  63. 穡锸
    ˙ )BTI
    ˙ ⮭㶸㺙焺欽BSHPO QCLEG TDSZQU CDSZQU
    ˙ 鼚⯝须俲鄄睕佖)BTI )."$
    ˙ 㼭䗱-FOHUI&YUFOTJPO"UUBDL
    ˙ .% 4)"♶銴欽
    63

    View full-size slide

  64. 穡锸
    ˙ 㼩珖⸈㺙
    ˙ ♶銴欽&$#.PEF
    ˙ $#$.PEF1,$4剚1BEEJOH0SBDMF
    ˙ 3$♶銴欽
    ˙ ꬌ㼩珖⸈㺙
    ˙ 34"꨾銴3BOEPN1BEEJOH
    64

    View full-size slide

  65. 2"
    =䧴僽㣐㹻〳⟃鍑侕㉻

    View full-size slide