310 likes | 710 Views
Vernam Cipher Project Preliminaries. CSC112 March 14, 2011 Oskars J. Rieksts Computer Science Department Kutztown University. Early/Simple Examples. Steganography Caesar cipher Substitution cipher Transposition cipher Vigenere cipher Vernam cipher. Steganography.
E N D
Vernam CipherProject Preliminaries CSC112 March 14, 2011 Oskars J. Rieksts Computer Science Department Kutztown University
Early/Simple Examples • Steganography • Caesar cipher • Substitution cipher • Transposition cipher • Vigenere cipher • Vernam cipher Kutztown University
Steganography • Merriam-Webster: The art or practice of concealing a message, image, or file within another message, image, or file • from Greek • steganos = covered • grafo = write • Histiaeus – tyrant of Miletus • shaved head of most trusted slave • tattooed a message • hair grew back covering message • Advantage – does not draw attention to • itself • messenger • recipient • Often combined with cryptography Kutztown University
Steganography Example You may have seen the TV show – In Plain Sight –which is based entirely on the federal witness protection program. The show is about people who have testified or will be testifying soon as witnesses in criminal cases but whose lives are in danger as a result. For their protection they are given new identities and are moved to a new community. Ergo they are all hidden “in plain sight”. And if you think this would not work, according to the U.S. Marshalls extant website, no program participant who follows security guidelines has ever been harmed while under the active protection of the Marshals Service. Kutztown University
Caesar Cipher • Example of a shift cipher • Encryption – forward shift by 3 • Decryption – backward shift by 3 • Shift ciphers • Private key • Symmetric key • Key = shift amount • Keyspace = 25 • Plain text – IHAVEASECRET • Cipher text – LKDYHDVHFUHW Kutztown University
Caesar Cipher – Example L KDYH D GUHDP WKDW RQH GDB WKLV QDWLRQ ZLOO ULVH XS DQG OLYH RXW WKH WUXH PHDQLQJ RI LWV FUHHG: "ZH KROG WKHVH WUXWKV WR EH VHOI-HYLGHQW: WKDW DOO PHQ DUH FUHDWHG HTXDO." L KDYH D GUHDP WKDW RQH GDB RQ WKH UHG KLOOV RI JHRUJLD WKH VRQV RI IRUPHU VODYHV DQG WKH VRQV RI IRUPHU VODYH RZQHUV ZLOO EH DEOH WR VLW GRZQ WRJHWKHU DW WKH WDEOH RI EURWKHUKRRG. L KDYH D GUHDP WKDW RQH GDB HYHQ WKH VWDWH RI PLVVLVVLSSL, D VWDWH VZHOWHULQJ ZLWK WKH KHDW RI LQMXVWLFH, VZHOWHULQJ ZLWK WKH KHDW RI RSSUHVVLRQ, ZLOO EH WUDQVIRUPHG LQWR DQ RDVLV RI IUHHGRP DQG MXVWLFH. L KDYH D GUHDP WKDW PB IRXU OLWWOH FKLOGUHQ ZLOO RQH GDB OLYH LQ D QDWLRQ ZKHUH WKHB ZLOO QRW EH MXGJHG EB WKH FRORU RI WKHLU VNLQ EXW EB WKH FRQWHQW RI WKHLU FKDUDFWHU. L KDYH D GUHDP WRGDB. Kutztown University
Substitution Cipher • Randomly generated substitution • Example • A F • B K • C D • D J • etc. • Characteristics • Private & symmetric key • Monoalphabetic • Key = alphabet of substitutions • Keyspace = 26! Kutztown University
Substitution Cipher – Analysis • Keyspace = 26! = 403291461126605635584000000 = 4.03 x 1026 • But other factors make it insecure • Letter frequency • N-grams • Strong elimination coefficient • With patience, can be decoded by hand • Plain text – BOOKKEEPINGROCKS • Cipher text – JXXTTZZDOYBEXATU Kutztown University
Substitution Cipher – Example HPFAIFJZIFYTPFTUVIJFBTPHWVFTHUVGHXXZHWIEMFVJXHAIUETTPITZEIYIFVHVNUCHTWDZIIJGIPUXJTPIWITZETPWTUKIWIXCIAHJIVTTPFTFXXYIVFZIDZIFTIJIOEFXHPFAIFJZIFYTPFTUVIJFBUVTPIZIJPHXXWUCNIUZNHFTPIWUVWUCCUZYIZWXFAIWFVJTPIWUVWUCCUZYIZWXFAIUGVIZWGHXXKIFKXITUWHTJUGVTUNITPIZFTTPITFKXIUCKZUTPIZPUUJHPFAIFJZIFYTPFTUVIJFBIAIVTPIWTFTIUCYHWWHWWHMMHFWTFTIWGIXTIZHVNGHTPTPIPIFTUCHVREWTHDIWGIXTIZHVNGHTPTPIPIFTUCUMMZIWWHUVGHXXKITZFVWCUZYIJHVTUFVUFWHWUCCZIIJUYFVJREWTHDIHPFAIFJZIFYTPFTYBCUEZXHTTXIDPHXJZIVGHXXUVIJFBXHAIHVFVFTHUVGPIZITPIBGHXXVUTKIREJNIJKBTPIDUXUZUCTPIHZWSHVKETKBTPIDUVTIVTUCTPIHZDPFZFDTIZHPFAIFJZIFYTUJFBHPFAIFJZIFYTPFTUVIJFBJUGVHVFXFKFYFGHTPHTWAHDHUEWZFDHWTWGHTPHTWNUAIZVUZPFAHVNPHWXHMWJZHMMHVNGHTPTPIGUZJWUCHVTIZMUWHTHUVFVJVEXXHCHDFTHUVUVIJFBZHNPTTPIZIHVFXFKFYFXHTTXIKXFDSKUBWFVJKXFDSNHZXWGHXXKIFKXITURUHVPFVJWGHTPXHTTXIGPHTIKUBWFVJGPHTINHZXWFWWHWTIZWFVJKZUTPIZWHPFAIFJZIFYTUJFBHPFAIFJZIFYTPFTU Kutztown University
Transposition Cipher • Generate permutation of n objects • Transpose letters • Permutation of 0 through 7 • 6 – 3 – 7 – 1 – 4 – 8 – 5 – 2 • Yields value transposition 1 6 2 3 3 7 4 1 5 4 6 8 7 5 8 2 Kutztown University
Transposition Cipher – Example • Cipher text TYTSNHOAGTGERLUSHATEUAGNTIHVLBEAURRYTHHAOHUUCGLGOATHYTNSUSGHTGREGNHLATUEEATAIHLVBEOTLUAHHNERDWTAANRODESUHIEVNETAAMINYNFENNOTORTSTIHFLAEAHAINSNTDEHBGAEVSYTREHEENFIHMNOIARSEPWDEEEEAUSRFPEALSYIBMMSAAIYTROINBNSYEOKNMECCOOLUEDRYADMECRSAOEAECSNEHEWFNTLHONRDISBAEYFOUOURTSSSPSTEOLFDHIFEELWEOHTIRETDHIWREAEIASNVVABKLRIEYMSHNEEEGANIRONPECLHFITNUFAAOIRNGHCRBKOTAEHEUCKRGNNLSDEIAIMNTAGKSSMICELSOOTOEFDLNTGHIIENNNIDMNNAAABSOYTETNNDEWOIRYOWWNHLSLDIEAGYNECSHOCMTNETOSHIMTIIEGNHLTOHFNETRINMSCBLUHLOSOWWSYOBSWULLWEATSRTWTOHDOEKLSNBLDRIARHEITMIGSBIEETRMTNHTGOAIEIAMNDREAGBIAOSNSFTYLEIOONTNGHTIOAIEDTIRESRWAYVAMDEBTFIALEAONNGRENSDTEHIONRCDLWOIANDRSWWUNRTCCHOALSHLRWIGDAEIPNAYMNOSOAETHRTEUSTALUGEGNGIALHVEATRBTTYHAHUCGULHORNRACDLIACRMCMUAOCHORYNOPCRONYNOO Kutztown University
Vigenere Cipher • Polyalphabetic substitution • Use n randomly generated substitutions • 1st letter is encoded by 1st substitution alphabet • 2nd letter is encoded by 2nd substitution alphabet • . . . • nth letter is encoded by nth substitution alphabet • n+1st letter is encoded by 1st substitution alphabet • etc. Kutztown University
Vigenere – Simple Example • Key = 3752 • Successive letters are shifted by 3, 7, 5, 2 • Plain text – BOOKKEEPINGROCKS • Cipher text – EVTMNLJRLULTRJPU • Eliminates double letters • Scatters N-grams Kutztown University
Vigenere Cipher • Advantages • Creates confusion • Same letter can be encoded n different ways • Pretty much eliminates n-grams • Keyspace > 26! Kutztown University
Vigenere Cipher • le chiffre indéchiffrable • Named for Blaise de Vigenère • Invented by Giovan Battista Bellaso ca. 1550 • Broken by • Charles Babbage in 1854 (unpublished) • Major Friedrich Kasiski in 1863 • Prussian infantry office Kutztown University
Vigenere Cipher – Example T KRCS L GILOX WYHH ZQV KOJ WYPG YDKPCY ZZSZ CLJL IA DEK ZTYV VIE WYL HCXV TSLQZUU ZI ZAG NUVLR: "HH YVZO WYLGP WIBHSV KV PP VVST-PYZKSYW: KOOE DCS APQ RYS NUVHHPG VXILO." Z OOGH R KFPDD AVLW FUS ODP VB EKV YSO KZSZD RW NSZUXPO EKV ZCYV FM TZUDLF DORCSD DEK HSH JVBD RW MCCPVY GWDML CHQVYG HLCS PP DSSS ER JPH ORNU HZJVAVPU RA HSH KHPWH FM PCRKOSCKFVR. T KRCS L GILOX WYHH ZQV KOJ HMLB EKV ZHLWV VT XLJZWDVZWDT, D JAOEH JDSWWVYWYJ NPHS WYL VPDK VT TQABGELTL, GHHCASCLEN KTWY AVP KVHH ZI FWDCHJZWZQ, NPZW EV AFLQJMCCPVK WYWF HB ZDJPG ZI WYSPGFT OYG ABGELTL. W SDML O OUVHA EKRA AJ IFBF WLKAZP FYPZOUVU KTOC VBP GRF ZTYV PB L QRAWZQ NOSCH KOSJ ZZSZ YRK IS UXUNSO EP AVP FFSCC RW AVPLI ZYTQ SBH MB KOS NREASYW FM HSHZY QSDIHQEHI. P VLYV H RCHRT HZGRF. W SDML O OUVHA EKRA CYH UHM, ORNU WY DCHPLPR, DWEK ZAG GLTPCFV IHQTVKZ, KTWY PHD JFCSCQFY VLYZUU SLJ SWAV UYWASZUU HLKO HSH NVFOV FM WYWVYDZVZAWZQ RUR YXCSWQLTHHTRE; VBP GRF FTJYA HSHIL WY DCHPLPR, SWEWCL PWDTR PZBJ HBO ECHQV JZYZD ZZSZ MH RIZP WF QCTQ YHBOV NPHS OZAHWH NOWEH SVMD DEK KSLKL UTUCZ OD VZZHPUJ HBO EIVHSHIZ. W SDML O OUVHA ERUHM. T KRCS L GILOX WYHH ZQV KOJ HMLFJ YRSZPB JOOWO SL SIDCASO, HMLFJ KZSZ LQU TCFQKHWY VYHZW EV TOOH Kutztown University
Vigenere Cipher – Example Analysis TKRCSLGILOXWYHHZQVKOJWYPGYDKPCYZZSZCLJLIADEKZTYVVI EWYLHCXVTSLQZUUZIZAGNUVLRHHYVZOWYLGPWIBHSVKVPPVVST PYZKSYWKOOEDCSAPQRYSNUVHHPGVXILOZOOGHRKFPDDAVLWFUS ODPVBEKVYSOKZSZDRWNSZUXPOEKVZCYVFMTZUDLFDORCSDDEKH SHJVBDRWMCCPVYGWDMLCHQVYGHLCSPPDSSSERJPHORNUHZJVAV PURAHSHKHPWHFMPCRKOSCKFVRTKRCSLGILOXWYHHZQVKOJHMLB EKVZHLWVVTXLJZWDVZWDTDJAOEHJDSWWVYWYJNPHSWYLVPDKVT TQABGELTLGHHCASCLENKTWYAVPKVHHZIFWDCHJZWZQNPZWEVAF LQJMCCPVKWYWFHBZDJPGZIWYSPGFTOYGABGELTLWSDMLOOUVHA EKRAAJIFBFWLKAZPFYPZOUVUKTOCVBPGRFZTYVPBLQRAWZQNOS CHKOSJZZSZYRKISUXUNSOEPAVPFFSCCRWAVPLIZYTQSBHMBKOS NREASYWFMHSHZYQSDIHQEHIPVLYVHRCHRTHZGRFWSDMLOOUVHA EKRACYHUHMORNUWYDCHPLPRDWEKZAGGLTPCFVIHQTVKZKTWYPH DJFCSCQFYVLYZUUSLJSWAVUYWASZUUHLKOHSHNVFOVFMWYWVYD ZVZAWZQRURYXCSWQLTHHTREVBPGRFFTJYAHSHILWYDCHPLPRSW EWCLPWDTRPZBJHBOECHQVJZYZDZZSZMHRIZPWFQCTQYHBOVNPH SOZAHWHNOWEHSVMDDEKKSLKLUTUCZODVZZHPUJHBOEIVHSHIZW SDMLOOUVHAERUHMTKRCSLGILOXWYHHZQVKOJHMLFJYRSZPBJOO WOSLSIDCASOHMLFJKZSZLQUTCFQKHWYVYHZWEVTOOHCVKEKVYC FJYWZLFVZKTOCISXDULDWDZUOYGKOSNUFVYPGGSONHJDWWOSLA LGVZHCDZNVEDEKHSHXSCCBFMHSHCVFOVYHZWEVYSGHRSSODEKO Kutztown University
Vigenere Cipher – Example Analysis TKRCSLGILO XWYHHZQVKO JWYPGYDKPC YZZSZCLJLI ADEKZTYVVI EWYLHCXVTS LQZUUZIZAG NUVLRHHYVZ OWYLGPWIBH SVKVPPVVST PYZKSYWKOO EDCSAPQRYS NUVHHPGVXI LOZOOGHRKF PDDAVLWFUS ODPVBEKVYS OKZSZDRWNS ZUXPOEKVZC YVFMTZUDLF DORCSDDEKH SHJVBDRWMC CPVYGWDMLC HQVYGHLCSP PDSSSERJPH ORNUHZJVAV PURAHSHKHP WHFMPCRKOS CKFVRTKRCS LGILOXWYHH ZQVKOJHMLB EKVZHLWVVT XLJZWDVZWD TDJAOEHJDS WWVYWYJNPH SWYLVPDKVT TQABGELTLG Kutztown University
Vigenere Cipher – Example Analysis HHCASCLENK TWYAVPKVHH ZIFWDCHJZW ZQNPZWEVAF LQJMCCPVKW YWFHBZDJPG ZIWYSPGFTO YGABGELTLW SDMLOOUVHA EKRAAJIFBF WLKAZPFYPZ OUVUKTOCVB PGRFZTYVPB LQRAWZQNOS CHKOSJZZSZ YRKISUXUNS OEPAVPFFSC CRWAVPLIZY TQSBHMBKOS NREASYWFMH SHZYQSDIHQ EHIPVLYVHR CHRTHZGRFW SDMLOOUVHA Kutztown University
Deciphering Vigenere • Determine the number of alphabets • Compute distances between matching sequences • Compute GCD of distances • Treat cipher text as n separate texts • For each separate text & each of 25 possible shifts • Compute Index of Coincidence • based on frequencies found in cipher text • using table of frequencies of letters in English • Index of Coincidence formula • fee = S {relFreqTab(k, ciphLet) * charFreq(ciphLet)} Kutztown University
Frequency Table – English A 0.08; B 0.015; C 0.03; D 0.04; E 0.13; F 0.02; G 0.015; H 0.06; I 0.065; J 0.005 K 0.005; L 0.035; M 0.03; N 0.07; O 0.08 P 0.02; Q 0.002; R 0.065; S 0.06; T 0.09 U 0.03; V 0.01; W 0.015; X 0.005; Y 0.02 Z 0.002 Kutztown University
Vigenere – Final Step • Produce possible plain texts • using combination of • highest ranking fee table values • Choose best plain text • This step can be automated • Rate each possible plain text • using n-gram information • or list of 5 letter words in English Kutztown University
Vernam Cipher • Gilbert SandfordVernam – inventor • Also known as one-time pad • Invented ca. 1919 • Proven unbreakable by Claude Shannon • Communication Theory of Secrecy Systems • 1949 • Unbreakable if and only if • Key is same length as plain text • Key is never re-used Kutztown University
Vernam Cipher • Basic operation – bitwise XOR • XOR table • 0 xor 0 = 0 • 0 xor 1 = 1 • 1 xor 0 = 1 • 1 xor 1 = 0 • Plain text is represented as bit stream • Key is random bit stream of same length • Cipher text is produced via bitwise XOR of plain bit stream and key bit stream. Kutztown University
Vernam Cipher – Example • Plain text :: Grade = A – Great! • Plain text in ASCII • 71 114 97 100 101 32 61 32 65 32 45 32 71 114 101 97 116 33 • Plain text as bit stream 01000111 01110010 01100001 01100100 01100101 00100000 00111101 00100000 01000110 00100000 10010110 00100000 01010011 01101111 01110010 01110010 01111001 00100001 Kutztown University
Vernam Cipher – Example • Key as bit stream 11000001 01110000 11011110 10111001 01100001 10001000 01101100 11111010 00110011 01001110 01111001 00011110 00001000 10010001 10100100 01000000 10000000 01000010 • Cipher text as bit stream 10000110 00000010 10111111 11011101 00000100 10101000 01010001 11011010 01110010 01101110 01010100 00111110 01001111 11100011 11000001 00100001 11110100 01100011 Kutztown University
Vernam Cipher – Why Unbreakable • Try attack by exhaustive search • Among possible keys 11000001 01110000 11011110 10111001 01100001 10001000 01101100 11111010 00110100 01001110 01111001 00011110 00011100 10001100 10110011 01010011 10001101 01000010 • Produces this recovered plain text: • Grade = F – Sorry! Kutztown University
Vernam Cipher – Why Unbreakable • Exhaustive search will produce every possible combination of 18 characters. • And there is no way to distinguish between them • Among the possible recovered texts: • Tickle me Elmo now • Jabberwocky Rocks! • Attack tomorrow am • Attack tomorrow pm • Grade = C++ & Java Kutztown University
Vernam Cipher – Why Look Elsewhere? • Key distribution problem • Every sender/recipient must have same pad • N sender recipient pairs require O(N2) pads • Pad distribution is security risk • Key coordination problem • Sheets on pad must match exactly • Messages must arrive in order sent • Key generation problem • High quality random numbers hard to generate • Bottom line – has some limited use Kutztown University