{"id":333,"date":"2005-07-18T13:52:00","date_gmt":"2005-07-18T13:52:00","guid":{"rendered":"http:\/\/journal.electric-rocket.com\/?p=333"},"modified":"2005-07-18T13:52:00","modified_gmt":"2005-07-18T13:52:00","slug":"decipher","status":"publish","type":"post","link":"https:\/\/journal.electric-rocket.com\/?p=333","title":{"rendered":"DeCipher"},"content":{"rendered":"<p>A while back&#8217;s post was an encrypted message.<\/p>\n<p>Entry tags:\tgzdq<br \/>\n<b>Thirteen<\/b><\/p>\n<pre>\r\nEZLZJ IQAFZ TQOCX QGMKC MYOSY DOYRX CGZDQ VYCXT QLCXY FCQQO\r\nGZORF MCJBM CYZOE LZJGM OOZVF QMDSL EQGFQ CKZEC E\r\nCZRQC XQFVQ VYBBF JBQCX QVZFB D\r\n<\/pre>\n<p><!--more Extreme Geekiness Under Cut--><\/p>\n<p>I had just finished a re-read of <u>Cryptonomicon<\/u> a while back, and there was an appendix written by Bruce Schneier about a cipher used in the book.  It mentioned he was the author of <u>Applied Cryptography<\/u>, which I noticed was on my co-worker&#8217;s shelf (we work in the secure payment industry, so this stuff comes up now and again).  I borrowed it and read through the first few chapters, which gave a very high level view of cryptography.  Fun stuff.<\/p>\n<p>Both <u>Cryptonomicon<\/u> and <u>Applied Cryptography<\/u> talk about techniques of cryptanalysis, the act of breaking encryption.  So I&#8217;ll pretend I don&#8217;t know the message and apply one.  (Actually, I don&#8217;t really remember the message anymore.)<\/p>\n<p>Assuming this is a substitution cypher of english &#8220;cleartext&#8221; (unencrypted text), we can apply a <a href=\"http:\/\/library.thinkquest.org\/28005\/flashed\/thelab\/cryptograms\/frequency.shtml\">letter frequency analysis<\/a>.  We also have a small burst of encrypted text where we know what the underlying word is, thanks to <lj user=travellight>:<\/p>\n<p><lj user=travellight>: If I guess it, is there a prize?<br \/>\n<lj user=electricrocket>: LQE<\/p>\n<p>As <lj user=galbinus_caeli> surmised, this is &#8220;YES&#8221;.  So L=Y, Q=E, E=S.<\/p>\n<p>Using a <a href=\"http:\/\/www.10ticks.co.uk\/s_codebreaker_letter.asp\">text analyzer tool<\/a>, the frequency of letters in my message is: <\/p>\n<p>Q -15<br \/>\nC -13<br \/>\nZ -11<br \/>\nF, O -8<br \/>\nY -7<br \/>\nM,X -6<br \/>\nB, E, G, V -5<br \/>\nD, J, L -4<br \/>\nR-3<br \/>\nS, T, K -2<br \/>\nI, A -1<br \/>\nN, P, H, U, W -0<\/p>\n<p>letter frequency in the english language: e t a o i n s r h l d c u m f p g w y b v k x j q z<\/p>\n<p>So Q=E makes sense.  If we also assume that C=T and Z=A and know L=Y &#038; E=S, the message looks like:<\/p>\n<p>Q=E, C=T, Z=A, L=Y, E=S<\/p>\n<pre>\r\nEZLZJ IQAFZ TQOCX QGMKC MYOSY DOYRX CGZDQ VYCXT QLCXY FCQQO\r\n<b>SAYA   E  A  E T  E   T             T A E   T   EYT    TEE<\/b>\r\nGZORF MCJBM CYZOE LZJGM OOZVF QMDSL EQGFQ CKZEC E\r\n<b> A     T    T A S YA      A   E   Y SE  E T AST S  <\/b>           \r\nCZRQC XQFVQ VYBBF JBQCX QVZFB D\r\n<b>TA ET E   E         ET  E A    <\/b>  \r\n<\/pre>\n<p>Doesn&#8217;t look like anything yet.<\/p>\n<p>So, on to digraphs  From <a href=\"http:\/\/library.thinkquest.org\/28005\/flashed\/thelab\/cryptograms\/frequency.shtml\">this site again<\/a>:<\/p>\n<p>These letters often go together. These are known as digraphs.<br \/>\nth, he, at, st, an, in, ea, nd, er, en, re, nt, to, es, on, ed, is, ti <\/p>\n<p>I know C=T, so I&#8217;ll attack those digraphs.<\/p>\n<p>These might be TH, TO or TI<br \/>\nCX 4<br \/>\nCM 1<br \/>\nCG 1<br \/>\nCQ 1 (TE)<br \/>\nCJ 1<br \/>\nCY 1<br \/>\nCK 1<br \/>\nCZ 1<\/p>\n<p>So, assume CX = TH, meaning X=H<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E  A E THE   T         HT A E  TH EYTH  TEE<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n <b>A    T   T A SYA     A  E   YSE  ET ASTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHE  E       ETHE A<\/b>     \r\n\r\nQ=E, C=T, Z=A, L=Y, E=S, X=H\r\n<\/pre>\n<p>We see some &#8220;THE&#8221;s!  That&#8217;s something.  Maybe.<\/p>\n<p>Now the other T Digraphs&#8230;<br \/>\nThese might be AT, ST, or NT<br \/>\nQC 3 (ET)<br \/>\nMC 2<br \/>\nEC 2 (ST)<br \/>\nOC 1<br \/>\nKC 1<br \/>\nXC 1<br \/>\nYC 1<br \/>\nLC 1 (YT)<br \/>\nFC 1<\/p>\n<p>M is common in the two digraphs (CM and MC).  Given the letter frequency of M, I&#8217;d say it&#8217;s either I, N, or R.  N seems to be the best first guess (because MC is frequent, and ST and AT are known), so I&#8217;ll try M=N.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E  A E THE N TN        HT A E  TH EYTH  TEE<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n <b>A   NT  NT A SYA  N  A  EN  YSE  ET ASTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHE  E       ETHE A<\/b>     \r\n\r\nQ=E, C=T, Z=A, L=Y, E=S, X=H, M=N\r\n<\/pre>\n<p>I also know that Q=E, so another batch of digraphs:<\/p>\n<p>These might be HE or RE<br \/>\nXQ 3 (HE)<br \/>\nTQ 2<br \/>\nFQ 2<br \/>\nIQ 1<br \/>\nDQ 1<br \/>\nCQ 1 (TE)<br \/>\nQQ 1 (EE)<br \/>\nEQ 1 (SE)<br \/>\nRQ 1<br \/>\nVQ 1<br \/>\nBQ 1<\/p>\n<p>Probably TQ or FQ is RE.  F has the closest letter frequency to R, so I&#8217;ll try F=R.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E RA E THE N TN        HT A E  TH EYTH RTEE<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n <b>A  RNT  NT A SYA  N  A REN  YSE RET ASTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHER E       ETHE AR<\/b>    \r\nQ=E, C=T, Z=A, L=Y, E=S, X=H, M=N, F=R\r\n<\/pre>\n<p>Ah-hah!  At the end of the first line, if Y=I and O=N, then that word is THIRTEEN, which was the subject of the message.  Except, we said M=N&#8230; let&#8217;s pull that out and try the different substitutions&#8230;<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E RA ENTHE   T IN I NI HT A E ITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n <b>AN R T   TIANSYA   NNA RE   YSE RET ASTS<\/b>            \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHER E I     ETHE AR<\/b>    \r\n\r\nQ=E, C=T, Z=A, L=Y, E=S, X=H, F=R, Y=I, O=N\r\n<\/pre>\n<p>More E digraphs:<\/p>\n<p>These might be EA, ER, EN, ES, or ED<\/p>\n<p>QC 3 (ET)<br \/>\nQV 3<br \/>\nQO 2 (EN)<br \/>\nQG 2<br \/>\nQL<br \/>\nQQ (EE)<br \/>\nQM<br \/>\nQF (ER)<br \/>\nQA<\/p>\n<p>Since we know EA, ER, EN, and ES, perhaps QV=ED.  The letter frequency looks good for that match.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E RA ENTHE   T IN I NI HT A EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n <b>AN R T   TIANSYA   NNADRE   YSE RET ASTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHERDEDI     ETHEDAR<\/b>    \r\nQ=E, C=T, Z=A, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D\r\n<\/pre>\n<p>Does nothing for me.<\/p>\n<p>Letters that are often doubled, as in sniff: ll, tt, ss, ee, pp, oo, rr, ff, cc, dd, nn<\/p>\n<p>Consider the BB in the last line.  Judging from the letter frequency (and eliminating the letters we know), it could be ll, cc, ff.  ll is most common, so we&#8217;ll try B=L.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E RA ENTHE   T IN I NI HT A EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n <b>AN R T L TIANSYA   NNADRE   YSE RET ASTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHERDEDILL  LETHEDAR<\/b>    \r\nQ=E, C=T, Z=A, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D, B=L\r\n<\/pre>\n<p>In the second line, towards the end, SE RET could be SECRET.  so we&#8217;ll try G=C.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SAYA  E RA ENTHEC  T IN I NI HTCA EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CAN R T L TIANSYA C NNADRE   YSECRET ASTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TA ETHERDEDILL  LETHEDAR<\/b>    \r\nQ=E, C=T, Z=A, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D, B=L, G=C\r\n<\/pre>\n<p>I&#8217;m getting a sense that there are mistakes in there.<\/p>\n<p>Let&#8217;s try some trigraphs.<\/p>\n<p>Trigraphs are much like digraphs, but for three letters. Here are the most often seen trigraphs:<br \/>\nthe, and, tha, hat, ent, ion, for, tio, has, edt, tis, ers, res, ter, con, ing, men, tho<\/p>\n<p>I feel confident about all the letters in THIRTEEN, so THE should be solved.  Perhaps AND?  We have all those letters, A &#038; D I don&#8217;t feel as solid about. If we look for three letter combinations with N in the middle, perhaps we&#8217;ll notice a different possibility for A or D.<\/p>\n<p>QOC (ENT)<br \/>\nYOS (INx)<br \/>\nDOY (xNI)<br \/>\nZOR (ANx)<br \/>\nZOE (ANS)<br \/>\nMOO (xNN)<br \/>\nOOZ (NNx)<\/p>\n<p>No duplicates, so not much to work with in terms of frequency.<\/p>\n<p>Perhaps THA?<\/p>\n<p>Keying off TH, which I have confidence in&#8230;<br \/>\nCXQ 3 (THE)<br \/>\nCXY 1 (THI)<br \/>\nCXT 1 (THx)<\/p>\n<p>T=A is more unlikely than Z=A, by letter frequency.<\/p>\n<p>If Z=A were wrong, it would be more likely that F, O or Y = A, because of letter frequency.  I&#8217;ve said F=R, O=N and Y=I, so something is probably wrong here.  I feel confident about F=R, O=N and Y=I (because of THIRTEEN).  M=A or X=A is possible.  What if we change Z=A to M=A?<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>S Y   E R  ENTHECA TAIN I NI HTC  EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>C N RAT LATI NSY  CANN DREA  YSECRET  STS<\/b>           \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>T  ETHERDEDILL  LETHED R<\/b>   \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D, B=L, G=C, M=A\r\n<\/pre>\n<p>What would Z decrypt to, then?  Z=O is the next possibility by letter frequency&#8230;<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SOYO  E RO ENTHECO TAIN I NI HTCO EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CON RAT LATIONSYO CANNODREA  YSECRET OSTS<\/b>           \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TO ETHERDEDILL  LETHEDOR<\/b>  \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D, B=L, G=C, M=A, Z=O\r\n<\/pre>\n<p>A-ha!  I see CONGRATULATIONS there, if R=G and J=U.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SOYOU E RO ENTHECA TAIN I NIGHTCO EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CONGRATULATIONSYOUCANNODREA  YSECRET OSTS<\/b>             \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TOGETHERDEDILL ULETHEDOR<\/b> \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D, B=L, G=C, M=A, Z=O, R=G, J=U\r\n<\/pre>\n<p>I just realized I missed an F=R at the bottom.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SOYOU E RO ENTHECA TAIN I NIGHTCO EDITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CONGRATULATIONSYOUCANNODREA  YSECRET OSTS<\/b>         \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TOGETHERDEDILLRULETHEDOR<\/b>  \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, V=D, B=L, G=C, M=A, Z=O, R=G, J=U\r\n<\/pre>\n<p>Given that the bottom line reads TOGETHER DE DILL RULE THE DOR__, I&#8217;m guessing V does not equal D, but rather W.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SOYOU E RO ENTHECA TAIN I NIGHTCO EWITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CONGRATULATIONSYOUCANNOWREA  YSECRET OSTS<\/b>            \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TOGETHERWEWILLRULETHEWOR<\/b> \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, B=L, G=C, M=A, Z=O, R=G, J=U, V=W \r\n<\/pre>\n<p>And WOR__ is obviosly WORLD, so B=L, D=D.  And, shoot, I already knew B=L, but missed it.  Crap.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SOYOU E RO ENTHECA TAIN IDNIGHTCODEWITH EYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CONGRATULATIONSYOUCANNOWREAD YSECRET OSTS<\/b>           \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TOGETHERWEWILLRULETHEWORLD<\/b>   \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, B=L, G=C, M=A, Z=O, R=G, J=U, V=W, D=D\r\n<\/pre>\n<p>Some guesswork leads to: I=V, A=B, T=K, S=M, K=P.<\/p>\n<pre>\r\nEZLZJIQAFZTQOCXQGMKCMYOSYDOYRXCGZDQVYCXTQLCXYFCQQO\r\n<b>SOYOUVEBROKENTHECAPTAINMIDNIGHTCODEWITHKEYTHIRTEEN<\/b>\r\nGZORFMCJBMCYZOELZJGMOOZVFQMDSLEQGFQCKZECE\r\n<b>CONGRATULATIONSYOUCANNOWREADMYSECRETPOSTS<\/b>            \r\nCZRQCXQFVQVYBBFJBQCXQVZFBD\r\n<b>TOGETHERWEWILLRULETHEWORLD<\/b>  \r\nQ=E, C=T, L=Y, E=S, X=H, F=R, Y=I, O=N, B=L, G=C, M=A, Z=O, R=G, J=U, V=W, D=D, I=V, A=B, T=K, S=M, K=P\r\n<\/pre>\n<p>The Rot, with key 13.<\/p>\n<pre>\r\n<b>PLAINTEXT  ABCDEFGHIJKLMNOPQRSTUVWXYZ<\/b>\r\nCYPHER     MAGDQ?RXY?TBSOZK?FECJIV?L?\r\n<\/pre>\n<p>We can assume that the codewheel was rotated 13 times, and can be thus unrotated to get the base position.<\/p>\n<p>The C code I came across on the web to do this automatically is <a href=\"http:\/\/www.crypto.com\/badge.c\">here<\/a>.  I modified it to spit out letters instead of numbers.<\/p>\n<p>What I didn&#8217;t know when I wrote the message was the real <a href=\"http:\/\/www-math.cudenver.edu\/~wcherowi\/clockar5.html\">Cap&#8217;n Midnight decoder ring<\/a> was actually alphabetical order, just shifted (&#8220;rot&#8221;).  The folks that wrote the Captain Midnight C code must have been too appalled at the simplicity to match that.<\/p>\n<p>Well, that was a pointless use of several lunch hours.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back&#8217;s post was an encrypted message. Entry tags: gzdq Thirteen EZLZJ IQAFZ TQOCX QGMKC MYOSY DOYRX CGZDQ VYCXT QLCXY FCQQO GZORF MCJBM CYZOE LZJGM OOZVF QMDSL EQGFQ CKZEC E CZRQC XQFVQ VYBBF JBQCX QVZFB D<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[53],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-cryptography"],"_links":{"self":[{"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333"}],"version-history":[{"count":0,"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions"}],"wp:attachment":[{"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/journal.electric-rocket.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}