<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DEYBRnc-cSp7ImA9WxBbEUQ.&quot;"><id>tag:blogger.com,1999:blog-6800934446457898793</id><updated>2010-03-09T23:42:37.959-05:00</updated><title>Moserware</title><subtitle type="html">Jeff Moser's software development adventures.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.moserware.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.moserware.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default?start-index=4&amp;max-results=3&amp;redirect=false&amp;v=2" /><author><name>Jeff Moser</name><uri>http://www.blogger.com/profile/16074905903060665396</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>3</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Moserware" /><feedburner:info uri="moserware" /><geo:lat>39.95645</geo:lat><geo:long>-86.008729</geo:long><feedburner:emailServiceId>Moserware</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;DUAAQHY4fSp7ImA9WxBQEEg.&quot;"><id>tag:blogger.com,1999:blog-6800934446457898793.post-3391668541957239551</id><published>2009-09-22T08:12:00.013-04:00</published><updated>2010-01-09T12:22:21.835-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-09T12:22:21.835-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="aes" /><title>A Stick Figure Guide to the Advanced Encryption Standard (AES)</title><content type="html">&lt;p&gt;&lt;strong&gt;(A play in 4 acts. Please feel free to exit along with the stage character that best represents you. Take intermissions as you see fit. Click on the stage if you have a hard time seeing it. If you get bored, you can &lt;a href="http://github.com/moserware/AES-Illustrated"&gt;jump to the code&lt;/a&gt;. Most importantly, enjoy the show!)&lt;/strong&gt;&lt;/p&gt;&lt;h4&gt;Act 1: Once Upon a Time...&lt;/h4&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SreSw8cwljI/AAAAAAAABh8/6T7C6TTD23k/s1600-h/aes_act_1_scene_01_intro_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid" id="BLOGGER_PHOTO_ID_5383933249102845490" title="I handle petabytes of data every day. From encrypting juicy Top Secret intelligence to boring packets bound for your WiFi router, I do it all!" alt="intro" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SreS30GKZdI/AAAAAAAABiE/mSpYbOwJdYI/s576/aes_act_1_scene_01_intro_576.png" width="576" height="452" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SreXYmXZLaI/AAAAAAAABiU/9MDEFDxuy0c/s1600-h/aes_act_1_scene_02_sad_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 2px solid; BORDER-LEFT: 2px solid; MARGIN: 5px; BORDER-TOP: 2px solid; BORDER-RIGHT: 2px solid" id="BLOGGER_PHOTO_ID_5383938328416038306" title="...and still no one seems to care about me or my story." alt="sad" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SreXTuW_GRI/AAAAAAAABiM/G12QhPMZ-sA/s576/aes_act_1_scene_02_sad_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SreaC72AzpI/AAAAAAAABic/HV22hMCw1Xk/s1600-h/aes_act_1_scene_03_cinderella_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383941254759370386" title="I've got a better-than-Cinderella story as I made my way to become king of the block cipher world." alt="aes act 1 scene 03 cinderella" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SreaGzm7SzI/AAAAAAAABik/y61pDCtEc14/s576/aes_act_1_scene_03_cinderella_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SreaMsUYC-I/AAAAAAAABis/4mM-xbLIB4A/s1600-h/aes_act_1_scene_04_started_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383941422390447074" title="Whoah! You're still there. You want to hear it? Well let's get started..." alt="aes act 1 scene 04 started" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SreaP3IJd9I/AAAAAAAABi0/8KsDJBsVsHY/s576/aes_act_1_scene_04_started_576.png" width="576" height="452" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrebavzxZHI/AAAAAAAABi8/KJhKmQTtqi4/s1600-h/aes_act_1_scene_05_judge_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383942763357234290" title="Once upon a time, there was no good way for people outside secret agencies to judge good crypto." alt="aes act 1 scene 05 judge" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Srebd8FiQTI/AAAAAAAABjE/ko_6ZVc0VCE/s576/aes_act_1_scene_05_judge_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sreh0fsDjRI/AAAAAAAABjM/bNXFrxuBY8Y/s1600-h/aes_act_1_scene_06_nbs_decree_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383949802776268050" title="A decree went throughout the land to find a good, secure, algorithm." alt="aes act 1 scene 06 nbs decree" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sreh3pxeGEI/AAAAAAAABjU/x9pSOij_v0g/s576/aes_act_1_scene_06_nbs_decree_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrektFJi7oI/AAAAAAAABjc/wp0BKrW50h0/s1600-h/aes_act_1_scene_07_lucifer_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383952973928001154" title="One worth competitor named Lucifer came forward." alt="aes act 1 scene 07 lucifer" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrekwCKLfiI/AAAAAAAABjk/YkvZ6MJM8m4/s576/aes_act_1_scene_07_lucifer_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SremXGo1_9I/AAAAAAAABjs/iaUL3R8V0AQ/s1600-h/aes_act_1_scene_08_anoint_des_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383954795393843154" title="After being modified by the National Security Agency (NSA), he was anointed as the Data Encryption Standard (DES)." alt="aes act 1 scene 08 anoint des" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Srema9SorhI/AAAAAAAABj0/iW5CoFAljm4/s576/aes_act_1_scene_08_anoint_des_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SreoBBfhLJI/AAAAAAAABj8/bg2juCimsl0/s1600-h/aes_act_1_scene_09_des_ruled_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383956615078685842" title="DES ruled in the land for over 20 years. Academics studied him intently. For the first time, there was something specific to look at. The modern field of cryptography was born." alt="aes act 1 scene 09 des ruled" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SreoEVHylOI/AAAAAAAABkE/D3BlZJplBs0/s576/aes_act_1_scene_09_des_ruled_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SreoJQaJCmI/AAAAAAAABkM/g3HmEDLRJws/s1600-h/aes_act_1_scene_10_des_defeated_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383956756521618018" title="Over the years, many attackers challenged DES. He was defeated in several battles." alt="aes act 1 scene 10 des defeated" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SreoosgwcwI/AAAAAAAABkk/OORabbgG05I/s576/aes_act_1_scene_10_des_defeated_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SreojET_QBI/AAAAAAAABkc/knYwS6AsM04/s1600-h/aes_act_1_scene_11_triple_des_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383957199951183890" title="The only way to stop the attacks was to use DES 3 times in a row to form Triple-DES. This worked, but it was awfully slow." alt="aes act 1 scene 11 triple des" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SreoM07nHpI/AAAAAAAABkU/cmHIixESoNU/s576/aes_act_1_scene_11_triple_des_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sreqlu0gkOI/AAAAAAAABks/TFPgQMW2KJI/s1600-h/aes_act_1_scene_12_nist_decree_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383959444744868066" title="Another decree went out..." alt="aes act 1 scene 12 nist decree" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SreqpMKl22I/AAAAAAAABk0/JlrAPzZ-Fpk/s576/aes_act_1_scene_12_nist_decree_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SreqryYxgTI/AAAAAAAABk8/gkd3ibNVQyc/s1600-h/aes_act_1_scene_13_rallied_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383959548781494578" title="This call rallied the crypto wizards to develop something better." alt="aes act 1 scene 13 rallied" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SreqvBB6jOI/AAAAAAAABlE/HoDrD09dNcE/s576/aes_act_1_scene_13_rallied_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrezP7Vek8I/AAAAAAAABlM/vY8BCz_xZ_M/s1600-h/aes_act_1_scene_14_rijndael_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383968965751903170" title="My creators, Vincent Rijmen and Joan Daemen, were among these crypto wizards. They combined their last names to give me my birth name: Rijndael." alt="aes act 1 scene 14 rijndael" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrezSe1jN_I/AAAAAAAABlU/zmex1ObPq_0/s576/aes_act_1_scene_14_rijndael_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrezVYrKN3I/AAAAAAAABlc/QV7SKeqbjYw/s1600-h/aes_act_1_scene_15_vote_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383969059526817650" title="Everyone got together to vote and..." alt="aes act 1 scene 15 vote" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrezYYaiEqI/AAAAAAAABlk/EnnaS0_dByk/s576/aes_act_1_scene_15_vote_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrezjnfyXnI/AAAAAAAABls/cq-87oH48Tg/s1600-h/aes_act_1_scene_16_won_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383969304023817842" title="I won!!" alt="aes act 1 scene 16 won" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrezmZC_RaI/AAAAAAAABl0/eZom1yqlqyk/s576/aes_act_1_scene_16_won_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrezpTQzCZI/AAAAAAAABl8/vLXzCa29fbk/s1600-h/aes_act_1_scene_17_intel_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383969401671453074" title="...and now I'm the new king of the crypto world. You can find me everywhere. Intel is even putting native instructions for me in their next chip to make me smokin' fast!" alt="aes act 1 scene 17 intel" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrezsnkniJI/AAAAAAAABmE/FiEq39lvg4A/s576/aes_act_1_scene_17_intel_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrezvgPsZPI/AAAAAAAABmM/Di0qeLpgzN0/s1600-h/aes_act_1_scene_18_crypto_question_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383969508235699442" title="AES: Any questions? Audience guy: Nice story and all, but how does crypto work?" alt="aes act 1 scene 18 crypto question" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Srezy1AWA4I/AAAAAAAABmU/7v0_FToHszM/s576/aes_act_1_scene_18_crypto_question_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;h4&gt;Act 2: Crypto Basics&lt;/h4&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Srez-RG1xYI/AAAAAAAABmc/5P3Sv4i4_-Y/s1600-h/aes_act_2_scene_01_three_big_ideas_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383969761870071170" title="Great question! You only need to know 3 big ideas to understand crypto." alt="aes act 2 scene 01 three big ideas" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sre0BdetXbI/AAAAAAAABmk/4_E39WHoZsg/s576/aes_act_2_scene_01_three_big_ideas_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sre0EOHgkDI/AAAAAAAABms/zSZ1XbA1VsQ/s1600-h/aes_act_2_scene_02_confusion_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383969864146784306" title="Big Idea #1: Confusion - It's a good idea to obscure the relationship between your real message and your encrypted message. An example of this confusion is the trusty ol' Caesar Cipher." alt="aes act 2 scene 02 confusion" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Sre0HxR0naI/AAAAAAAABm0/UUFLdLSoG-4/s576/aes_act_2_scene_02_confusion_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Sre0O-cq9bI/AAAAAAAABm8/A-LklM2NcaE/s1600-h/aes_act_2_scene_03_diffusion_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383970048919139762" title="Big Idea #2: Diffusion - It's also a good idea to spread out the message. An example of this diffusion is a simple column transposition." alt="aes act 2 scene 03 diffusion" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Sre0RCS7xmI/AAAAAAAABnE/Yc89z95EcUc/s576/aes_act_2_scene_03_diffusion_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sre0TwXbu3I/AAAAAAAABnM/aQaV1plxGLc/s1600-h/aes_act_2_scene_04_key_secrecy_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383970131038419826" title="Big Idea #3: Secrecy Only in the Key - After thousands of years, we learned that it's a bad idea to assume that no one knows how your method works. Someone will eventually find that out." alt="aes act 2 scene 04 key secrecy" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Sre0Wr9lsOI/AAAAAAAABnU/znXvOAQzq5s/s576/aes_act_2_scene_04_key_secrecy_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Sre0d0HMFdI/AAAAAAAABnc/UruwdeuJ9dQ/s1600-h/aes_act_2_scene_05_aes_details_question_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383970303842719186" title="AES: Does that answer your question? Some audience guy: That helps, but was too general. How do *you* work?" alt="aes act 2 scene 05 aes details question" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Sre0glnhckI/AAAAAAAABnk/iwQQLLDCFGg/s576/aes_act_2_scene_05_aes_details_question_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;h4&gt;Act 3: Details&lt;/h4&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sre5EW2PL9I/AAAAAAAABns/t0Ij3L_3_WE/s1600-h/aes_act_3_scene_01_sign_this_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383975364048400338" title="AES: I'd be happy to tell you how I work, but you have to sign this first. Some audience guy: Uh... what's that?" alt="aes act 3 scene 01 sign this" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Sre5G6jmPiI/AAAAAAAABn0/42lBdxsNIgQ/s576/aes_act_3_scene_01_sign_this_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sre5JqBKZyI/AAAAAAAABn8/Op-n-e0JVaA/s1600-h/aes_act_3_scene_02_agreement_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383975455093843746" title="Foot-Shooting Prevention Agreement: I, (your name), promise that once I see how simple AES really is, I will *not* implement it in production code even though it would be really fun. This agreement shall be in effect until the undersigned creates a meaningful interpretive dance that compares and contrasts cache-based, timing, and other side channel attacks and their countermeasures. (Signature) (Date)" alt="aes act 3 scene 02 agreement" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sre5MXZdxnI/AAAAAAAABoE/KzWFtoYJbKU/s576/aes_act_3_scene_02_agreement_576.png" width="576" height="735" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sre5R1EZ6rI/AAAAAAAABoM/lCULPyge7s0/s1600-h/aes_act_3_scene_03_state_matrix_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383975595499186866" title="I take your data and load it into this 4x4 square." alt="aes act 3 scene 03 state matrix" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sre5UDRyYjI/AAAAAAAABoU/80Y_v-1wtaE/s576/aes_act_3_scene_03_state_matrix_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Sre5XUQitTI/AAAAAAAABoc/cHg1Js96QOM/s1600-h/aes_act_3_scene_04_initial_round_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383975689770939698" title="The initial round has me xor each input byte with the corresponding byte of the first round key." alt="aes act 3 scene 04 initial round" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sre5bKfgxDI/AAAAAAAABok/L1y5soBDwzs/s576/aes_act_3_scene_04_initial_round_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Sre-FxdOh9I/AAAAAAAABos/oJTOPzQJ3uY/s1600-h/aes_act_3_scene_05_xor_tribute_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383980885929265106" title="A Tribute to XOR: There's a simple reason why I use xor to apply the key and in other spots: it's fast and cheap - a quick bit flipper. It uses minimal hardware and can be done in parallel since no pesky carry bits are needed." alt="aes act 3 scene 05 xor tribute" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sre-JbSxGnI/AAAAAAAABo0/ZA-urw9iKc4/s576/aes_act_3_scene_05_xor_tribute_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sre-OTUh6KI/AAAAAAAABo8/SCuODQhdNEk/s1600-h/aes_act_3_scene_06_key_expansion_part_1_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383981032458545314" title="Key Expansion: Part 1 - I need lots of keys for use in later rounds. I derive all of them from the initial key using a simple mixing technique that's really fast. Despite its critics, it's good enough." alt="aes act 3 scene 06 key expansion part 1" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Sre-Q4FGxMI/AAAAAAAABpE/0rzg2OB8130/s576/aes_act_3_scene_06_key_expansion_part_1_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfCCTI1ZPI/AAAAAAAABpM/MG0cyNuft_Q/s1600-h/aes_act_3_scene_07_key_expansion_part_2a_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985224297571570" title="Key Expansion: Part 2a - 1. I take the last column of the previous round key and move the top byte to the bottom. 2. Next, I run each byte through a substitution box that will map it to something else." alt="aes act 3 scene 07 key expansion part 2a" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfCEuX65LI/AAAAAAAABpU/c-e6crEOfdQ/s576/aes_act_3_scene_07_key_expansion_part_2a_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfCHbNRXeI/AAAAAAAABpc/uCSy-XDw6eI/s1600-h/aes_act_3_scene_08_key_expansion_part_2b_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985312363011554" title="Key Expansion: Part 2b - 3. I then xor the column with a round constant that is different for each round. 4. Finally, I xor it with the first column of the previous round key." alt="aes act 3 scene 08 key expansion part 2b" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfCJnH9RPI/AAAAAAAABpk/bXs6-41QZpg/s576/aes_act_3_scene_08_key_expansion_part_2b_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfCOWZulEI/AAAAAAAABps/nE7uxkd35wE/s1600-h/aes_act_3_scene_09_key_expansion_part_3_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985431332164674" title="Key Expansion: Part 3 - The other columns are super-easy, I just xor the previous column with the same column of the previous round." alt="aes act 3 scene 09 key expansion part 3" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfCRa-aFJI/AAAAAAAABp0/nrZUPp_oGUM/s576/aes_act_3_scene_09_key_expansion_part_3_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfCanLmV2I/AAAAAAAABp8/-Md5ppw1lnw/s1600-h/aes_act_3_scene_10_intermediate_round_start_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985641994737506" title="Next, I start the intermediate rounds. A round is just a series of steps that I repeat several times. The number of repetitions depends on the size of the key." alt="aes act 3 scene 10 intermediate round start" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfCcv-rksI/AAAAAAAABqE/HvKXl-YbTX4/s576/aes_act_3_scene_10_intermediate_round_start_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfCftmCrvI/AAAAAAAABqM/67jfKKB5UIU/s1600-h/aes_act_3_scene_11_substitute_bytes_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985729615605490" title="Applying Confusion: Substitute Bytes - I use confusion (Big Idea #1) to obscure the relationship of each byte. I put each byte into a substitution box (sbox), which will map it to a different byte." alt="aes act 3 scene 11 substitute bytes" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfCjTtVEEI/AAAAAAAABqU/xrEhBOiIyrk/s576/aes_act_3_scene_11_substitute_bytes_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfCpcC15jI/AAAAAAAABqc/fWSo9eEKTSo/s1600-h/aes_act_3_scene_12_shift_rows_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985896703256114" title="Applying Diffusion: Part 1 (Shift Rows) - Next, I shift the rows to the left and then wrap them around the other side." alt="aes act 3 scene 12 shift rows" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfCrikRPeI/AAAAAAAABqk/M9GTsaUYrPM/s576/aes_act_3_scene_12_shift_rows_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfCucdB19I/AAAAAAAABqs/kDCFrHHwLXk/s1600-h/aes_act_3_scene_13_mix_columns_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383985982712436690" title="Applying Diffusion: Part 2 (Mix Columns) - I take each column and mix up the bits in it." alt="aes act 3 scene 13 mix columns" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfCx9bJnvI/AAAAAAAABq0/8fVV6pOJciI/s576/aes_act_3_scene_13_mix_columns_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfC20zUn-I/AAAAAAAABq8/Z47NA5jOb5w/s1600-h/aes_act_3_scene_14_add_round_key_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383986126687346658" title="Applying Key Secrecy: Add Round Key - At the end of each round, I apply the next round key with an xor." alt="aes act 3 scene 14 add round key" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfC5M1RzOI/AAAAAAAABrE/J8GoUwxgTOM/s576/aes_act_3_scene_14_add_round_key_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfC7ybrZcI/AAAAAAAABrM/KkNgTXnicHM/s1600-h/aes_act_3_scene_15_final_round_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383986211950650818" title="In the final round, I skip the Mix Columns step since it wouldn't increase security and would just slow things down." alt="aes act 3 scene 15 final round" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfC-0BETiI/AAAAAAAABrU/ZikFpise1gg/s576/aes_act_3_scene_15_final_round_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfDC-OT0PI/AAAAAAAABrc/c5_Cp8qy2LA/s1600-h/aes_act_3_scene_16_more_rounds_the_merrier_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383986335374889202" title="...and that's it. Each round I do makes the bits more confused and diffused. It also has the key impact them. The more rounds, the merrier!" alt="aes act 3 scene 16 more rounds the merrier" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfDFIjncvI/AAAAAAAABrk/h2ddv2pLcqY/s576/aes_act_3_scene_16_more_rounds_the_merrier_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfDIoT2nFI/AAAAAAAABrs/1ATJ5tFovMs/s1600-h/aes_act_3_scene_17_tradeoffs_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383986432571776082" title="Determining the number of rounds always involves several tradeoffs." alt="aes act 3 scene 17 tradeoffs" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfDLWMYKGI/AAAAAAAABr0/7FDu8_OK2-c/s576/aes_act_3_scene_17_tradeoffs_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfDT1v99rI/AAAAAAAABr8/70P70ZSE4zc/s1600-h/aes_act_3_scene_18_security_margin_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383986625157920434" title="When I was being developed, a clever guy was able to find a shortcut path through 6 rounds. That's not good! If you look carefully, you'll see that each bit of a round's output depends on every bit from two rounds ago. To increase this diffusion avalanche, I added 4 extra rounds. This is my security margin." alt="aes act 3 scene 18 security margin" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfDWsNlCtI/AAAAAAAABsE/oi_3g-uiYMY/s576/aes_act_3_scene_18_security_margin_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfDab99iPI/AAAAAAAABsM/X-Ve9W4DDwQ/s1600-h/aes_act_3_scene_19_in_pictures_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383986738496375026" title="So in pictures, we have this..." alt="aes act 3 scene 19 in pictures" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfDc-kkJQI/AAAAAAAABsU/lzHi4uWMayE/s576/aes_act_3_scene_19_in_pictures_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfIvJzF0eI/AAAAAAAABsc/atByZ6jpEaE/s1600-h/aes_act_3_scene_20_decrypting_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383992591954334178" title="Decrypting means doing everything in reverse." alt="aes act 3 scene 20 decrypting" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfIxngPl_I/AAAAAAAABsk/WnNB9qjPGnU/s576/aes_act_3_scene_20_decrypting_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfI0ckVcMI/AAAAAAAABss/wUh6hWmtNaU/s1600-h/aes_act_3_scene_21_modes_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383992682892062914" title="One last tidbit: I shouldn't be used as-is, but rather as a building block to a decent mode." alt="aes act 3 scene 21 modes" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfI216SVCI/AAAAAAAABs0/Hp2aSZZZykY/s576/aes_act_3_scene_21_modes_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrfI75-UmZI/AAAAAAAABs8/PdvB4lfYzy8/s1600-h/aes_act_3_scene_22_questions_what_really_happens_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383992811044772242" title="AES: Make sense? Did that answer your question? Some audience guy: Almost... except you just waved your hands and used weird analogies. What really happens?" alt="aes act 3 scene 22 questions what really happens" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrfI-O25w4I/AAAAAAAABtE/8AutQXFozNE/s576/aes_act_3_scene_22_questions_what_really_happens_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrfJGGLGGhI/AAAAAAAABtM/keDeLk_NuGM/s1600-h/aes_act_3_scene_23_math_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5383992986118265362" title="AES: Another great question! It's not hard, but... it involves a little... math. Some audience guy: I'm game. Bring it on!!" alt="aes act 3 scene 23 math" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrfJIYZ3lgI/AAAAAAAABtU/4gUZSF9p7eI/s576/aes_act_3_scene_23_math_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;h4&gt;Act 4: Math!&lt;/h4&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgcTY6rAqI/AAAAAAAABtc/1JEpZVwJTiw/s1600-h/aes_act_4_scene_01_algebra_class_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384084473953059490" title="Let's go back to your algebra class..." alt="aes act 4 scene 01 algebra class" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgcWsoSgKI/AAAAAAAABtk/iOD9KYTgKRc/s576/aes_act_4_scene_01_algebra_class_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrgccKsiY2I/AAAAAAAABts/p4H9f5jeqow/s1600-h/aes_act_4_scene_02_reviewing_the_basics_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384084624754500450" title="Reviewing the Basics" alt="aes act 4 scene 02 reviewing the basics" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgcgJf8rSI/AAAAAAAABt0/5xOREZg9l68/s576/aes_act_4_scene_02_reviewing_the_basics_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Srgcj5Vw2nI/AAAAAAAABt8/BOqxuAIqw-Q/s1600-h/aes_act_4_scene_03_algebra_coefficients_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384084757534530162" title="We'll change things slightly. In the old way, coefficients could get as big as we wanted. In the new way, they can only be 0 or 1." alt="aes act 4 scene 03 algebra coefficients" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgcotxyLaI/AAAAAAAABuE/6729JCg2ezY/s576/aes_act_4_scene_03_algebra_coefficients_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Srr27IBbEZI/AAAAAAAABzc/YFjDaybzmiM/s1600-h/aes_act_4_scene_04_remember_multiplication_growth_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384887800101015954" title="Remember how multiplication could make things grow fast?" alt="aes act 4 scene 04 remember multiplication growth" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Srr3ASzlnlI/AAAAAAAABzk/SK6u8tyjLHY/s576/aes_act_4_scene_04_remember_multiplication_growth_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Srgc85_-M9I/AAAAAAAABuc/wlnxNpLFa-0/s1600-h/aes_act_4_scene_05_cant_go_bigger_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384085187208295378" title="With the new addition, things are simpler, but the x^13 is still too big. Let's make it so we can't go bigger than x^7. How can we do that?" alt="aes act 4 scene 05 cant go bigger" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgdBUUugHI/AAAAAAAABuk/iGpyZ3_qjR8/s576/aes_act_4_scene_05_cant_go_bigger_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Srr6j-lA9lI/AAAAAAAABz8/QnQdTjgMHAw/s1600-h/aes_act_4_scene_06_clock_math_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384891800475465298" title="We use our friend, clock math, to do this. Just add things up and do long division. Keep a close watch on the remainder." alt="aes act 4 scene 06 clock math" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Srr6oWjBrxI/AAAAAAAAB0E/cqPyUXLK7hE/s576/aes_act_4_scene_06_clock_math_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgdO2S9ezI/AAAAAAAABu8/NTvJ6W3Ttyo/s1600-h/aes_act_4_scene_07_clock_math_polynomials_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384085495451843378" title="We can do clock math with polynomials. Instead of dividing by 12, my creators told me to use m(x) = x^8 + x^4 + x^3 + x + 1. Let's say we wanted to multiply x * b(x) where b(x) has coefficients b7...b0" alt="aes act 4 scene 07 clock math polynomials" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrgdSOPue7I/AAAAAAAABvE/Knwpu8jMajw/s576/aes_act_4_scene_07_clock_math_polynomials_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Srr5mPmhbvI/AAAAAAAABzs/qbYbdkjJEZU/s1600-h/aes_act_4_scene_08_divide_by_mx_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384890739893300978" title="We divide it by m(x) = x^8 + x^4 + x^3 + x + 1 and take the remainder" alt="aes act 4 scene 08 divide by mx" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Srr5rOC7dxI/AAAAAAAABz0/VU_wdtbUWuo/s576/aes_act_4_scene_08_divide_by_mx_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Srg9gSf9D7I/AAAAAAAABys/l-v8dtaVbrY/s1600-h/aes_act_4_scene_09_logarithms_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384120979452399538" title="Now we're ready for the hardest blast from the past: logarithms. After logarithms, everything else is cake! Logarithms let us turn multiplication into addition." alt="aes act 4 scene 09 logarithms" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Srg9kguwKdI/AAAAAAAABy0/Zi2vui_6I9w/s576/aes_act_4_scene_09_logarithms_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Srjob_UFyNI/AAAAAAAABzM/aZdfUe41BtI/s1600-h/aes_act_4_scene_10_using_logarithms_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384308922071238866" title="We can use logarithms in our new world. Instead of using 10 as the base, we can use the simple polynomial of x + 1 and watch the magic unravel." alt="aes act 4 scene 10 using logarithms" src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrjoeXzYo1I/AAAAAAAABzU/s1b4N1kMX1Q/s576/aes_act_4_scene_10_using_logarithms_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrghyNJha6I/AAAAAAAABv8/Q90wAUc_z5c/s1600-h/aes_act_4_scene_11_polynomial_as_byte_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384090500928203682" title="Why bother with all of this math? Encryption deals with bits and bytes, right? Well, there's one last connection: a 7th degree polynomial can be represented in exactly 1 byte since the new way uses only 0 or 1 for coefficients." alt="aes act 4 scene 11 polynomial as byte" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Srgh1u3gBdI/AAAAAAAABwE/fTzDj74ADcU/s576/aes_act_4_scene_11_polynomial_as_byte_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sr7EzhjhXeI/AAAAAAAAB1I/eecUCdvhhSI/s1600-h/aes_act_4_scene_12_byte_operations_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5385958593841421794" title="With bytes, polynomial addition becomes a simple xor. We can use our logarithm skills to make a table for speedy multiplication." alt="aes act 4 scene 12 byte operations" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Sr7E4ccI_OI/AAAAAAAAB1Q/G5k6u-g6a8A/s576/aes_act_4_scene_12_byte_operations_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgiAWNe7JI/AAAAAAAABwc/-gjCySVEVA4/s1600-h/aes_act_4_scene_13_byte_inverses_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384090743878904978" title="Since we know how to multiply, we can find the inverse polynomial byte for each byte. This is the byte that will undo/invert the polynomial back to 1. There are only 255 of them, so we can use brute force to find them." alt="aes act 4 scene 13 byte inverses" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgiDxfQ4bI/AAAAAAAABwk/o2AwweKVfcQ/s576/aes_act_4_scene_13_byte_inverses_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgiIqvWd0I/AAAAAAAABws/QN3Bx_ArLLQ/s1600-h/aes_act_4_scene_14_sbox_math_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384090886828619586" title="Now we can understand the mysterious s-box. It takes a byte 'a' and applies two functions. The first is 'g' which just finds the byte inverse. The second is 'f' which intentionally makes the math uglier to foil attackers." alt="aes act 4 scene 14 sbox math" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgiMyVIM1I/AAAAAAAABw0/iPWlbSiLxPo/s576/aes_act_4_scene_14_sbox_math_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrgiT00Da5I/AAAAAAAABw8/la2sQrWATB0/s1600-h/aes_act_4_scene_15_round_constants_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384091078511258514" title="We can also understand those crazy round constants in the key expansion. I get them by starting with 1 and then keep multiplying by 'x'" alt="aes act 4 scene 15 round constants" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SrgiXTMpmDI/AAAAAAAABxE/cnbny2O6HtI/s576/aes_act_4_scene_15_round_constants_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/S0i6PslImYI/AAAAAAAAKRY/J_w8KGadDuc/s1600-h/aes_act_4_scene_16_mix_columns_math_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5424791135957824738" title="Mix Columns is the hardest. I treat each column as a polynomial. I then use our new multiply method to multiply it by a specially crafted polynomial and then take the remainder after dividing by x^4 + 1. This all simplifies to a matrix multiply." alt="aes act 4 scene 16 mix columns math" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/S0i6y990NOI/AAAAAAAAKRg/Efy-iyr1-z8/s576/aes_act_4_scene_16_mix_columns_math_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Srr9Yi-qWbI/AAAAAAAAB0M/5L2fifTwybc/s1600-h/aes_act_4_scene_17_crib_sheet_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384894902623164850" title="AES Crib Sheet (Handy for Memorizing)" alt="aes act 4 scene 17 crib sheet" src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Srr9dcoXz7I/AAAAAAAAB0U/CHSggep44Oc/s576/aes_act_4_scene_17_crib_sheet_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgiwUzy5zI/AAAAAAAABxs/upfnKWL2G1A/s1600-h/aes_act_4_scene_18_got_it_now_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384091568136447794" title="Only audience guy left: Whoa... I think I get it now. It's relatively simple once you grok the pieces. Thanks for explaining it. I gotta go now.  AES: My pleasure. Come back anytime!" alt="aes act 4 scene 18 got it now" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgizsJeKKI/AAAAAAAABx0/PnlnLSEpE9E/s576/aes_act_4_scene_18_got_it_now_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Srgi6WaipTI/AAAAAAAABx8/yRSwy8KKjgg/s1600-h/aes_act_4_scene_19_so_much_more_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384091740366087474" title="But there's so much more to talk about: my resistance to linear and differential cryptanalysis, my Wide Trail Strategy, impractical related-key attacks, and... so much more... but no one is left." alt="aes act 4 scene 19 so much more" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Srgi9cWSxRI/AAAAAAAAByE/ap2FHb5h8TA/s576/aes_act_4_scene_19_so_much_more_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SrgjAYxgH7I/AAAAAAAAByM/bctl-zwRLAk/s1600-h/aes_act_4_scene_20_gotta_go_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384091844078477234" title="Oh well... there's some boring router traffic that needs to be encrypted. Gotta go!" alt="aes act 4 scene 20 gotta go" src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SrgjDaCrY9I/AAAAAAAAByU/zkLp3PfMzfA/s576/aes_act_4_scene_20_gotta_go_576.png" width="576" height="451" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgjGKa_LWI/AAAAAAAAByc/ZdzGbF9CeLk/s1600-h/aes_act_4_scene_21_the_end_1100.png"&gt;&lt;img style="BORDER-BOTTOM: 3px solid; BORDER-LEFT: 3px solid; MARGIN: 5px; BORDER-TOP: 3px solid; BORDER-RIGHT: 3px solid;" id="BLOGGER_PHOTO_ID_5384091943305162082" title="The End" alt="aes act 4 scene 21 the end" src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SrgjIoZVOWI/AAAAAAAAByk/X6EhgucPxkk/s576/aes_act_4_scene_21_the_end_576.png" width="576" height="450" /&gt;&lt;/a&gt;&lt;h4&gt;Epilogue&lt;/h4&gt;&lt;p&gt;I created a heavily-commented AES/Rijndael implementation to go along with this post and &lt;a href="http://github.com/moserware/AES-Illustrated"&gt;put it on GitHub&lt;/a&gt;. In keeping with the Foot-Shooting Prevention Agreement, it shouldn't be used for production code, but it should be helpful in seeing exactly where all the numbers came from in this play. Several resources were useful in creating this: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.amazon.com/gp/product/3540425802?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=3540425802"&gt;&lt;img align="right" src="http://ecx.images-amazon.com/images/I/41pByNMNOqL._SL160_.jpg" style="MARGIN: 3px;"/&gt;The Design of Rijndael&lt;/a&gt; is &lt;em&gt;the&lt;/em&gt; book on the subject, written by the Rijndael creators. It was helpful in understanding specifics, especially the math (although some parts were beyond me). It's also where I got the math notation and graphical representation in the left and right corners of the scenes describing the layers (&lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard#The_SubBytes_step"&gt;SubBytes&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard#The_ShiftRows_step"&gt;ShiftRows&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard#The_MixColumns_step"&gt;MixColumns&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard#The_AddRoundKey_step"&gt;AddRoundKey&lt;/a&gt;).&lt;/li&gt;&lt;li&gt;The &lt;a href="http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf"&gt;FIPS-197&lt;/a&gt; specification formally defines AES and provides a good overview.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.amazon.com/gp/product/0140067485?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0140067485"&gt;The Puzzle Palace&lt;/a&gt;, especially &lt;a href="http://cryptome.org/nsa-v-all.htm"&gt;chapter 9&lt;/a&gt;, was helpful while creating Act 1. For more on how the NSA modified DES, see &lt;a href="http://catless.ncl.ac.uk/Risks/6.01.html#subj4"&gt;this&lt;/a&gt;. &lt;/li&gt;&lt;li&gt;More on Intel's (and now AMD) inclusion of native AES instructions can be found &lt;a href="http://en.wikipedia.org/wiki/AES_instruction_set"&gt;here&lt;/a&gt; and in detail &lt;a href="http://software.intel.com/en-us/articles/advanced-encryption-standard-aes-instructions-set/"&gt;here&lt;/a&gt;. &lt;/li&gt;&lt;li&gt;Other helpful resources include &lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard"&gt;Wikipedia&lt;/a&gt;, &lt;a href="http://www.samiam.org/rijndael.html"&gt;Sam Trenholme's AES math series&lt;/a&gt;, and &lt;a href="http://www.cs.bc.edu/~straubin/cs381-05/blockciphers/rijndael_ingles2004.swf"&gt;this animation&lt;/a&gt;. &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Please leave a comment if you notice something that can be better explained.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Update #1&lt;/strong&gt;: Several scenes were updated to fix some errors mentioned in the comments.&lt;br/&gt;&lt;strong&gt;Update #2&lt;/strong&gt;: By request, I've created a slide show presentation of this play in both &lt;a href="http://dl.getdropbox.com/u/1083108/Moserware/AES/A%20Stick%20Figure%20Guide%20to%20the%20Advanced%20Encryption%20Standard%20%28AES%29.pptx"&gt;PowerPoint&lt;/a&gt; and &lt;a href="http://dl.getdropbox.com/u/1083108/Moserware/AES/A%20Stick%20Figure%20Guide%20to%20the%20Advanced%20Encryption%20Standard%20%28AES%29.pdf"&gt;PDF&lt;/a&gt; formats. I've licensed them under the &lt;a href="http://creativecommons.org/licenses/by/3.0/"&gt;Creative Commons Attribution License&lt;/a&gt; so that you can use them as you see fit. If you're teaching a class, consider giving extra credit to any student giving a worthy interpretive dance rendition in accordance with the Foot-Shooting Prevention Agreement.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6800934446457898793-3391668541957239551?l=www.moserware.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=4_66Ce3xvmU:kJTWhvXY31s:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=4_66Ce3xvmU:kJTWhvXY31s:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=4_66Ce3xvmU:kJTWhvXY31s:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=4_66Ce3xvmU:kJTWhvXY31s:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=4_66Ce3xvmU:kJTWhvXY31s:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=4_66Ce3xvmU:kJTWhvXY31s:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=4_66Ce3xvmU:kJTWhvXY31s:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=4_66Ce3xvmU:kJTWhvXY31s:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=4_66Ce3xvmU:kJTWhvXY31s:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=4_66Ce3xvmU:kJTWhvXY31s:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Moserware/~4/4_66Ce3xvmU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.moserware.com/feeds/3391668541957239551/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=6800934446457898793&amp;postID=3391668541957239551" title="192 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default/3391668541957239551?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default/3391668541957239551?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Moserware/~3/4_66Ce3xvmU/stick-figure-guide-to-advanced.html" title="A Stick Figure Guide to the Advanced Encryption Standard (AES)" /><author><name>Jeff Moser</name><uri>http://www.blogger.com/profile/16074905903060665396</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08376966494433799517" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_Zfbv3mHcYrc/SreS30GKZdI/AAAAAAAABiE/mSpYbOwJdYI/s72-c/aes_act_1_scene_01_intro_576.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">192</thr:total><feedburner:origLink>http://www.moserware.com/2009/09/stick-figure-guide-to-advanced.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8NSHw7cCp7ImA9WxJbEU4.&quot;"><id>tag:blogger.com,1999:blog-6800934446457898793.post-3330061764648564469</id><published>2009-07-20T08:00:00.003-04:00</published><updated>2009-07-20T19:01:39.208-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-20T19:01:39.208-04:00</app:edited><title>Just Enough MBA to Be a Programmer</title><content type="html">&lt;p&gt;There's that awkward moment in your software development life when you realize that most of the people in your company &lt;i&gt;aren't&lt;/i&gt; programmers. Scanning your address book reveals Marketing, Sales, Accounting, Human Resources, and yes, the "business people" with their Masters of Business Administration (MBAs).&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/0060799072?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0060799072"&gt;&lt;img style="margin: 0px 0px 0px 10px;" src="http://ecx.images-amazon.com/images/I/51SXTGSSDDL._SL160_.jpg" align="right" /&gt;&lt;/a&gt;I've always been curious about what MBAs really do. In my weaker moments, I've even thought that the only reason people got an MBA was to demand a higher salary or to "move up the corporate ladder" into some management job. What did these MBA ninjas actually learn in school? Would having an MBA help me better understand how I affected my company's bottom line? Although I had the curiosity, I never acted on it. This changed when &lt;a title="Chad Fowler" href="http://chadfowler.com/"&gt;another programmer&lt;/a&gt; &lt;a title="see page 53 of The Passionate Programmer" href="http://www.amazon.com/gp/product/1934356344?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1934356344"&gt;recommended&lt;/a&gt; that I read &lt;a title="The Ten-Day MBA" href="http://www.amazon.com/gp/product/0060799072?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0060799072"&gt;The Ten-Day MBA&lt;/a&gt; by &lt;a href="http://www.harpercollins.com/authors/18530/Steven_A_Silbiger/index.aspx"&gt;Steven Silbiger&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Sure, I knew that no one would anoint me with a real MBA at the end of the book any more than watching &lt;a id="n.bd" title="MIT's Open Courseware" href="http://ocw.mit.edu/OcwWeb/web/home/home/index.htm"&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;MIT&lt;/span&gt;&lt;/a&gt; lectures online would make me an MIT grad. Besides, going to a &lt;a title="... like the Harvard Business School" href="http://www.hbs.edu/mba/"&gt;nice&lt;/a&gt; &lt;a title="or Wharton" href="http://www.wharton.upenn.edu/mba/"&gt;MBA&lt;/a&gt; &lt;a title="... or Stanford" href="http://www.gsb.stanford.edu/mba/"&gt;school&lt;/a&gt; is more about being around other motivated people and professors. The real value in having an MBA is in applying the concepts, not the concepts themselves. &lt;/p&gt;&lt;p&gt;Disclaimers aside, I was determined to read the book and take notes on what a programmer should know about an MBA.&lt;/p&gt;&lt;h4&gt;Day 1 - Marketing&lt;/h4&gt;&lt;p&gt;Every developer painfully learns that technology doesn't win on its own. At best, it just &lt;span style="color: rgb(128, 0, 128);"&gt;&lt;a title="Fast forward to 2:50 to hear Seth talk about this" href="http://video.google.com/videoplay?docid=-6909078385965257294"&gt;gives you a shot at marketing&lt;/a&gt;&lt;/span&gt;. Marketing is proof that software doesn't sell itself, &lt;a title="Good programmers don't need no marketing by Alain Raynaud" href="http://blog.fairsoftware.net/2009/07/09/good-programmers-dont-need-no-marketing/"&gt;no matter how good it is&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;A software company might have a &lt;a href="http://www.birds-eye.net/definition/m/mrd-market_requirements_document.shtml"&gt;Marketing Requirements Document&lt;/a&gt; (MRD) that outlines what the next version will contain. This usually is the result of a standard marketing analysis that the book outlined: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Consumer Analysis - Who are they? What do they want? How many different segments of people do you have? Is the buyer of your product different than the user? (The book gives the example that women buy the majority of men's socks and underwear, thus it's good to market appropriately).&lt;/li&gt;&lt;li&gt;Market Analysis - How big is your target market? Is it new? Is it growing? Where is the product in the life cycle?&lt;/li&gt;&lt;li&gt;Competitive Analysis - How do your &lt;a href="http://en.wikipedia.org/wiki/SWOT_analysis"&gt;Strengths, Weaknesses, Opportunities, and Threats&lt;/a&gt; (SWOTs) compare to your competition? &lt;/li&gt;&lt;li&gt;Distribution Analysis - What "channels" does your company use to reach your customer? Who are the intermediate players (e.g. the Apple Store, Amazon.com, etc)? What cuts do they take? What are their motivations?&lt;/li&gt;&lt;li&gt;Plan the Marketing Mix - How will you differentiate your products? How will you place it, promote it, and price it?&lt;/li&gt;&lt;li&gt;Determine the Economics - How long will it take before you break even? What are your fixed costs vs. margin costs? (Thankfully software has a low marginal cost)&lt;/li&gt;&lt;li&gt;Revise - Tweak and repeat as needed. &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;One big marketing theme is to "own a word in the consumer's mind":&lt;/p&gt;&lt;blockquote id="s3hx"&gt;If you establish one benefit in the consumer's mind, the consumer may attribute other positives as well to your product. FedEx means "overnight delivery." Only one company can own a word and it is tough to change it once it's established... The easiest way to own a word is to be first. Consumers tend to stick with products that work for them. Kleenex cleans runny noses. p.26&lt;/blockquote&gt;&lt;p&gt;This explains why your family still uses &lt;a id="yvuv" title="MapQuest" href="http://www.mapquest.com/"&gt;MapQuest&lt;/a&gt; despite your repeated attempts to show them how much better &lt;a id="zkkz" title="Google Maps" href="http://maps.google.com/"&gt;Google Maps&lt;/a&gt; is. It's also helpful if your product name matches what it does. "&lt;a href="http://www.drano.com/"&gt;Drano&lt;/a&gt;" is easier to remember than a "Web 2.0" name like &lt;a href="http://www.qoop.com/"&gt;Qoop&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;I was surprised to learn that the popular online advertising term &lt;a href="http://en.wikipedia.org/wiki/Cost_per_impression"&gt;Cost per Thousand&lt;/a&gt; (CPM), is a relatively old term that has long existed in print media. In general, the more targeted a group is, the higher the CPM is. This explains why a programming ad on &lt;a href="http://stackoverflow.com/"&gt;Stack Overflow&lt;/a&gt; can probably fetch a better CPM than the same ad on a site like &lt;a href="http://www.pandora.com/"&gt;Pandora&lt;/a&gt;, even though programmers use both. &lt;/p&gt;&lt;p&gt;Marketing people typically have their reasons for doing things that frustrate us. For example, if your software will take a long time to get through a distribution channel or marketing foresees a long customer buying process, they might begin to "market" your code long before a beta is available with the belief that it'll hopefully be read by the time the customer is ready to buy.&lt;/p&gt;&lt;p&gt;Sometimes marketing has to make an extreme choice. When GTE faced rebuilding its tarnished brand in the 1990's, it was probably a clever marketing person who suggested that they &lt;a id="s4-7" title="gave up on fixing their brand" href="http://blip.tv/file/319044/"&gt;give up on fixing their brand name&lt;/a&gt; and re-brand themselves as &lt;a href="http://en.wikipedia.org/wiki/Verizon_Communications"&gt;Verizon&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Despite all the good advice, I was disappointed by the book's lack of coverage of the Apple/BMW style of "marketing" &lt;a title="Watch at 20:27" href="http://video.google.com/videoplay?docid=-6909078385965257294&amp;amp;ei=P5NiSvPbFIb2qAL9jLS-DA&amp;amp;q=seth+godin"&gt;the engineering department can do&lt;/a&gt; by creating a remarkable product. Creating a product that allows users to quickly jump over the "&lt;a href="http://headrush.typepad.com/creating_passionate_users/2006/03/how_to_be_an_ex.html"&gt;suck threshold&lt;/a&gt;" is just one example where a programmer can make a tremendous "marketing" contribution.&lt;/p&gt;&lt;h4&gt;Day 2 - Ethics&lt;/h4&gt;&lt;p&gt;Ethics seems easy to understand: "&lt;a id="i7rk" title="Do to others as you would have them do to you" href="http://www.biblegateway.com/passage/?search=Luke%206:31"&gt;Do to others as you would have them do to you&lt;/a&gt;." The hard part is realizing how the "others" are affected by your actions. Others include customers, executives, shareholders, suppliers, employees (and their families), the government, the planet, and the "future generations." &lt;/p&gt;&lt;p&gt;Unfortunately, when simplicity is lost, &lt;a id="d4a3" title="Sarbanes-Oxley Act" href="http://en.wikipedia.org/wiki/Sarbanes-Oxley_Act"&gt;Sarbanes-Oxley Act&lt;/a&gt;s are found.&lt;/p&gt;&lt;h4&gt;Day 3 - Accounting&lt;/h4&gt;&lt;p&gt;In theory, accounting is simple. Just answer these questions about your &lt;a id="d3fl" title="entity" href="http://www.answers.com/topic/accounting-entity"&gt;entity&lt;/a&gt;/business: &lt;/p&gt;&lt;blockquote id="tdpx"&gt;&lt;ul&gt;&lt;li&gt;What does a company own? &lt;/li&gt;&lt;li&gt;How much does a company owe others? &lt;/li&gt;&lt;li&gt;How well did a company's operations perform? &lt;/li&gt;&lt;li&gt;How does the company get the cash to fund itself? - p.72 &lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;&lt;p&gt;If you get nothing else out of accounting, know how to read a balance sheet. Although Microsoft CEO &lt;a id="cnhl" title="Steve Ballmer" href="http://en.wikipedia.org/wiki/Steve_Ballmer"&gt;Steve Ballmer&lt;/a&gt; dropped out of Stanford's MBA program to become employee #24, he &lt;a id="pk2-" title="The quote begins around 10:50" href="http://ecorner.stanford.edu/authorMaterialInfo.html?mid=2242"&gt;knew balance sheets were important&lt;/a&gt;:&lt;/p&gt;&lt;blockquote id="v580"&gt;In 1980, I came in to "be a business person" whatever that meant. Didn't know much. Frankly all I'd ever really done is interview for jobs and market brownie mix. I wasn't exactly well credentialed. I'd taken the first year at Stanford Business School so &lt;i&gt;I can read a balance sheet -- that was pretty important&lt;/i&gt;. We didn't have that much money back then so there wasn't much to read. But anyway those lessons were important.&lt;/blockquote&gt;&lt;p&gt;Balance sheets are simple to follow:&lt;/p&gt;&lt;blockquote id="kkr6"&gt;As the name implies, the balance sheet is a "balance" sheet. The fundamental equation that rules over accounting balance is:&lt;br /&gt;&lt;p&gt;Assets (A) = Liabilities (L) + Owners' Equity (OE) &lt;/p&gt;&lt;p&gt;What you own (assets) equals the total of what you borrowed (liabilities) and what you have invested (equity) to pay for it. This equation or "identity" explains &lt;i&gt;everything&lt;/i&gt; that happens in the accounting records of a company over time. Remember it! - p.83&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;For example, your work computer is a company asset (which explains the "asset" tag on it). Your company created an equal liability to pay for it. When your company started, the founders gave up some of their money to increase the new company's cash assets (left side) in exchange for stock in the company (right side). &lt;/p&gt;&lt;p&gt;For example, we can read &lt;a href="http://www.google.com/finance?q=NASDAQ:GOOG&amp;amp;fstype=ii"&gt;Google's balance sheet&lt;/a&gt; for the first quarter of 2009 and see:&lt;/p&gt;&lt;p&gt;Assets = $33.51 Billion&lt;br /&gt;Liabilities = $3.66 Billion&lt;br /&gt;Owner Equity = $29.85 Billion (which includes $14.98 Billion in "retained earnings" that Google is keeping for growth rather than giving it back to the owners of its 315.75 million shares)&lt;/p&gt;&lt;p&gt;Sure enough, everything "balances":&lt;/p&gt;&lt;div style="text-align: left;" id="ptq0"&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SmKJ_BwtVCI/AAAAAAAABfU/BAq3TOcY2UI/s1600-h/GoogleBalances.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SmKJ_BwtVCI/AAAAAAAABfU/BAq3TOcY2UI/s400/GoogleBalances.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;From basic data, we can derive a bunch of helpful ratios to see how healthy Google is: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Liquidity/Current Ratio = (Current Assets / Current Liabilities) = 33.51 / 3.66 = 9.14 (Greater than 1 means there's room to pay for liabilities)&lt;/li&gt;&lt;li&gt;Financial Leverage = (Total Liabilities + Owners' Equity) / OE = (3.66 + 29.85) / 29.85 = 1.12 (Greater than 2 indicates a company is using a lot of debt to operate)&lt;/li&gt;&lt;li&gt;&lt;a id="ufzr" title="Return on Equity" href="http://en.wikipedia.org/wiki/Return_on_equity"&gt;Return on Equity&lt;/a&gt; = (Net Income / Owners' Equity) = 1.42 / 29.85 = 4.77% (Which indicates how efficiently the company is using shareholder equity)&lt;/li&gt;&lt;li&gt;... and &lt;a id="wcrh" title="many more" href="http://www.reuters.com/finance/stocks/ratios?symbol=GOOG.O&amp;amp;rpc=66"&gt;many more&lt;/a&gt; ...&lt;/li&gt;&lt;/ol&gt;&lt;h4&gt;Day 4 - Organizational Behavior&lt;/h4&gt;&lt;p&gt;The whole purpose of Organizational Behavior (OB) is to get you to think before you act around people. You want to motivate people? OB has an equation for that: &lt;/p&gt;&lt;blockquote id="v8oz"&gt;Motivation = Expectation of Work will lead to Performance * Expectation Performance will lead to Reward * Value of Reward. &lt;/blockquote&gt;&lt;p&gt;Feel free to tweak the variables as you see fit. You can &lt;a href="http://en.wikipedia.org/wiki/Management_by_objectives"&gt;Manage by Objective&lt;/a&gt; (MBO) where you set goals and then get out of the way or you can &lt;a href="http://www.futurecents.com/mainmbwa.htm"&gt;Manage by Walking Around&lt;/a&gt; (MBWA) where you play a more active role in day-to-day execution. The best choice depends on your environment and culture. You might need to mix the two. Remember that we humans are delicate creatures with our own wants and desires. Be careful.&lt;/p&gt;&lt;h4&gt;Day 5 - Quantitative Analysis&lt;/h4&gt;&lt;p&gt;Quantitative Analysis (QA) explains why Excel has so many functions that I'd never heard of. A core idea is that "a dollar today is worth more than a dollar received in the future." (p.173). &lt;/p&gt;&lt;p&gt;Imagine that someone promises to pay you a dollar in a year if you give them money now. What is that worth to you today? Obviously, it matters on how much you trust them to pay you back. The more you trust them, the more you're willing to give them now. Similarly, the less you trust them, the more you might "discount" that dollar in the future because they're tying up money that could be used for better investments. This is called the "discount" or "hurdle" rate. Having a 10% discount rate means that the dollar in the future has a &lt;a href="http://en.wikipedia.org/wiki/Net_present_value"&gt;net present value&lt;/a&gt; of $0.91 today: &lt;/p&gt;&lt;blockquote id="zlcz"&gt;$1 * (1 + 10%)&lt;sup&gt;-1&lt;/sup&gt; = $0.91&lt;/blockquote&gt;&lt;p&gt;This simple idea has lots of consequences. For example, let's oversimplify things and say that you can spend $2,000 today to buy and maintain a server that will last for 3 years or you can lock in a price with Amazon for that same server for $800 a year for the same 3 years. A naïve person would just see that $2000 is less than $2400, but a QA person that assigns a 10% discount rate would see:&lt;/p&gt;&lt;p&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SmKMldPXhhI/AAAAAAAABfc/P2aBR0G4E2M/s1600-h/AmazonServerCost.png"&gt;&lt;img src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/SmKMldPXhhI/AAAAAAAABfc/P2aBR0G4E2M/s400/AmazonServerCost.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;... and come to the conclusion that it's about $10 cheaper, &lt;i&gt;in today's dollars&lt;/i&gt;, to have Amazon maintain the server.&lt;/p&gt;&lt;p&gt;You can also do the inverse calculation. Assume you're Amazon and that server costs you $1800 today and you can get someone to pay you $800 a year for it for 3 years. What is your &lt;a href="http://en.wikipedia.org/wiki/Internal_rate_of_return"&gt;internal rate of return&lt;/a&gt; for this investment?&lt;/p&gt;&lt;p&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SmKNk33IACI/AAAAAAAABfk/19rEcxVvJC4/s1600-h/IRR.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SmKNk33IACI/AAAAAAAABfk/19rEcxVvJC4/s400/IRR.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Here we see an internal rate of return of about 16% on the server.&lt;/p&gt;&lt;p&gt;We could also use the time value of money to include valuing users. Early adopters of eBay and Twitter were worth more per user than late adopters because the early ones were more likely to tell their friends who hadn't used the service and thus attract more new people. &lt;/p&gt;&lt;h4&gt;Day 6 - Finance&lt;/h4&gt;&lt;p&gt;&lt;a id="ex0m" title="Finance" href="http://en.wikipedia.org/wiki/Finance"&gt;Finance&lt;/a&gt; blends time, money, and risk. &lt;/p&gt;&lt;p&gt;To start, a business needs a structure that gives it some capital. Popular options include:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a id="pk97" title="Sole Proprietorships" href="http://en.wikipedia.org/wiki/Sole_proprietorship"&gt;Sole Proprietorships&lt;/a&gt; - An individual or a married couple. You are effectively your business. All earnings are treated as personal income and taxed appropriately. You take in all the profits but also have unlimited liability. You can't divide the company up. It's simple, but the downside is that it makes it hard to raise money. &lt;/li&gt;&lt;li&gt;&lt;a id="urnx" title="Partnerships" href="http://en.wikipedia.org/wiki/Partnership"&gt;Partnerships&lt;/a&gt; - Involves more people than a proprietorship. Several people come together and can be &lt;a id="xt93" title="general partners" href="http://en.wikipedia.org/wiki/General_partnership"&gt;general partners&lt;/a&gt; (each having unlimited liability) or &lt;a id="sjm:" title="limited partners" href="http://en.wikipedia.org/wiki/Limited_partnership"&gt;limited partners&lt;/a&gt; (liable up to the investment). As a partner, you pay taxes on your percentage of the business's income on your personal taxes. &lt;/li&gt;&lt;li&gt;&lt;a id="yztz" title="Corporations" href="http://en.wikipedia.org/wiki/Corporation"&gt;Corporations&lt;/a&gt; - Effectively you give birth to a new legal entity that is distinct from the &lt;a id="xyzn" title="shareholders" href="http://en.wikipedia.org/wiki/Shareholder"&gt;shareholders&lt;/a&gt;. Most large companies are "&lt;a id="r1xw" title="C Corporations" href="http://en.wikipedia.org/wiki/C_Corporation"&gt;C Corporations&lt;/a&gt;" and have a &lt;a id="lifg" title="double taxation" href="http://en.wikipedia.org/wiki/Double_taxation"&gt;double taxation&lt;/a&gt; issue where the corporation's income &lt;a id="i78p" title="is taxed" href="http://en.wikipedia.org/wiki/Corporate_tax"&gt;is taxed&lt;/a&gt; and the dividends it issues to shareholders &lt;a id="rxpn" title="are taxed" href="http://en.wikipedia.org/wiki/Dividend_tax"&gt;are taxed&lt;/a&gt; as well. If you have a smaller company with fewer than 100 shareholders, you may qualify for "&lt;a id="h::m" title="S Corporation" href="http://en.wikipedia.org/wiki/S_corp"&gt;S Corporation&lt;/a&gt;" status. S Corporations usually don't pay income tax and instead rely on shareholders to pay the associated tax on their percentage of the income. This tends to give S Corporations the legal liability benefit of corporation status and the single taxation benefit of partnerships. &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Corporations issue stock to raise money. Stock entitles the holder to a &lt;a id="fzru" title="residual" href="http://en.wikipedia.org/wiki/Residual"&gt;residual&lt;/a&gt; claim on earnings and assets after other debt obligations have been met. One obvious question is "what's a good stock price?" This has a lot of factors, such as a company's growth potential and the company's earnings. Popular metrics include a company's ratio of its stock price divided by its earnings (&lt;a id="pv50" title="P/E ratio" href="http://en.wikipedia.org/wiki/P/E_ratio"&gt;P/E ratio&lt;/a&gt;). Higher P/E ratios tend to indicate that shareholders have higher expectations the company will grow and eventually make more money in the future. Some examples:&lt;/p&gt;&lt;p&gt;&lt;table id="ob:4" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0" width="193"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="113"&gt;&lt;b&gt;Company&lt;/b&gt;&lt;/td&gt;&lt;td width="78"&gt;&lt;b&gt;P/E Ratio&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width="115"&gt;&lt;a id="tlgy" title="Google" href="http://www.google.com/finance?q=GOOG"&gt;Google&lt;/a&gt;&lt;/td&gt;&lt;td width="78"&gt;31.47&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width="117"&gt;&lt;a id="u7pc" title="Microsoft" href="http://www.google.com/finance?q=MSFT"&gt;Microsoft&lt;/a&gt;&lt;/td&gt;&lt;td width="78"&gt;13.98&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width="118"&gt;&lt;a id="d-xj" title="Amazon.com" href="http://www.google.com/finance?q=NASDAQ%3AAMZN"&gt;Amazon.com&lt;/a&gt;&lt;/td&gt;&lt;td width="78"&gt;54.98&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;After you raised some capital, you should carefully think how you'll spend it. There are many ways to do this. The &lt;a id="d328" title="Payback Period Method" href="http://en.wikipedia.org/wiki/Payback_period"&gt;Payback Period Method&lt;/a&gt; has you calculate how long it'll take to recover your investment. The shorter the payback period, the less risky the investment is. For example, adding RAM is so cheap that the productivity boost has a short payback period. In contrast, completely rewriting a huge codebase might have &lt;a title="put your company out of business" href="http://www.joelonsoftware.com/articles/fog0000000069.html"&gt;put your company out of business&lt;/a&gt; before you get your money back.&lt;/p&gt;&lt;p&gt;Another approach is to use the &lt;a id="pdpm" title="Net Present Value Method" href="http://www.answers.com/topic/net-present-value-method"&gt;Net Present Value Method&lt;/a&gt; to see how much the investment will return over its lifetime in terms of today's dollars. Once you determine the discount factor to reflect the risk, you only consider investments that have a positive Net Present Value.&lt;/p&gt;&lt;h4&gt;Day 7 - Operations&lt;/h4&gt;&lt;p&gt;Operations is about making stuff. Popular operations guys include &lt;a id="x6xv" title="Frederick Taylor" href="http://en.wikipedia.org/wiki/Frederick_Winslow_Taylor"&gt;Frederick Taylor&lt;/a&gt; from the late 1800's who is famous for breaking up tasks into small pieces and walking around factories with a stopwatch to find the "one right way" of doing them. &lt;a id="f3bd" title="Elton Mayo" href="http://en.wikipedia.org/wiki/Elton_Mayo"&gt;Elton Mayo&lt;/a&gt;'s bold claim was that caring about your employees mattered. You could even &lt;a title="make terrible working conditions" href="http://en.wikipedia.org/wiki/Hawthorne_effect"&gt;make terrible working conditions&lt;/a&gt; if the employees were otherwise treated well and felt important. &lt;/p&gt;&lt;p&gt;Although some MBAs might use some programming techniques like optimizing flow-charts to improve operations, it's more likely to see factory techniques used when managing programmers. Oversimplifying things, software development is a factory that turns &lt;a id="bzo6" title="capital into code" href="http://www.joelonsoftware.com/articles/fog0000000074.html"&gt;capital into code&lt;/a&gt;. To this end, you'll often see popular manufacturing processes like Toyota's &lt;a id="pmh5" title="Kanban" href="http://en.wikipedia.org/wiki/Kanban"&gt;Kanban&lt;/a&gt; method of using visual cards to control workflow &lt;a id="pbge" title="sneaking into our offices" href="http://www.infoq.com/articles/hiranabe-lean-agile-kanban"&gt;making their way&lt;/a&gt; into our world as "new" or "agile" software methodologies.&lt;/p&gt;&lt;h4&gt;Day 8 - Economics&lt;/h4&gt;&lt;p&gt;Economics is the magic that allows me to write software in exchange for steak burritos. As &lt;a id="gjfk" title="Adam Smith" href="http://en.wikipedia.org/wiki/Adam_Smith"&gt;Adam Smith&lt;/a&gt; &lt;a id="k3k4" title="realized" href="http://en.wikipedia.org/wiki/The_Wealth_of_Nations"&gt;realized&lt;/a&gt;, society as a whole becomes "wealthier" when we seek division of labor to specialize and do something well rather than trying to do everything ourselves poorly.&lt;/p&gt;&lt;p&gt;At a &lt;a id="rui0" title="micro level" href="http://en.wikipedia.org/wiki/Microeconomics"&gt;micro level&lt;/a&gt;, economics is a simple matter of supply equals demand. When you look at the larger/&lt;a id="lqz3" title="macro economies" href="http://en.wikipedia.org/wiki/Macroeconomics"&gt;macro economies&lt;/a&gt;, more complicated equations pop up like &lt;a id="ibn5" title="this one" href="http://en.wikipedia.org/wiki/Equation_of_exchange"&gt;this one&lt;/a&gt;: &lt;/p&gt;&lt;blockquote id="vsxg"&gt;&lt;a id="bzha" title="Money" href="http://en.wikipedia.org/wiki/Money_supply"&gt;Money&lt;/a&gt; * &lt;a id="zjn6" title="Velocity" href="http://en.wikipedia.org/wiki/Velocity_of_money"&gt;Velocity&lt;/a&gt; = &lt;a id="qxwn" title="Price Level" href="http://en.wikipedia.org/wiki/Price_level"&gt;Price Level&lt;/a&gt; * &lt;a id="e_-." title="Real Gross National Product" href="http://en.wikipedia.org/wiki/Measures_of_national_income_and_output"&gt;Real Gross National Product&lt;/a&gt;&lt;/blockquote&gt;&lt;p&gt;This equation shows that it's important that money is moving around (e.g. isn't hidden under your mattress) and that prices are stable or have reasonable growth.&lt;/p&gt;&lt;p&gt;One of the best things about the economics of software is that it has really low marginal costs (e.g. the cost to copy it). With processors, bandwidth, and storage all roughly following &lt;a id="u-75" title="Moore's Law" href="http://en.wikipedia.org/wiki/Moore%27s_Law"&gt;Moore's Law&lt;/a&gt; exponential curves, the capacity is doubling every 18 - 24 months which implies that the cost for a fixed amount is falling by half over the same period. &lt;/p&gt;&lt;p&gt;As Chris Anderson points out in his book &lt;a id="kd5-" title="Free" href="http://www.scribd.com/doc/17135767/FREE-full-book-by-Chris-Anderson"&gt;Free&lt;/a&gt;, it can sometimes makes sense to round these increasingly lower marginal costs down to zero and make money in different ways such as advertising or selling complements. It's hard to find other industries that have as many economic freedoms as software.&lt;/p&gt;&lt;h4&gt;Day 9 - Strategy&lt;/h4&gt;&lt;p&gt;Strategy should be simple: have a &lt;a id="r43r" title="remarkable product" href="http://www.ted.com/talks/seth_godin_on_sliced_bread.html"&gt;remarkable product&lt;/a&gt; &lt;a id="b0zl" title="that people want" href="http://www.paulgraham.com/startuplessons.html"&gt;that people want&lt;/a&gt;. &lt;a id="o03m" title="Bad things happen" href="http://www.amazon.com/gp/product/1590597214?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1590597214"&gt;Bad things happen&lt;/a&gt; if you don't do this. It's especially helpful if you have a &lt;a id="q4-u" title="cash cow" href="http://en.wikipedia.org/wiki/Cash_cow"&gt;cash cow&lt;/a&gt; you can milk for lots of money to fund new initiatives. For example, Google makes so much money &lt;a id="xv4_" title="AdSense" href="http://en.wikipedia.org/wiki/AdSense"&gt;from ads&lt;/a&gt; that it can have &lt;a id="s6ok" title="this" href="http://news.ycombinator.com/item?id=699460"&gt;this&lt;/a&gt; &lt;a id="sdm_" title="strategy" href="http://mashable.com/2009/07/11/google-equation/"&gt;strategy&lt;/a&gt;: &lt;/p&gt;&lt;blockquote id="ug2c"&gt;Revenue = Amount of Web Pages Viewed&lt;/blockquote&gt;&lt;p&gt;Google's strategy of getting you to view lots of pages (which conveniently have Google ads on them) explains a lot of what it does. From wanting to &lt;a id="o6.l" title="speed up the web" href="http://googleblog.blogspot.com/2009/06/lets-make-web-faster.html"&gt;speed up the web&lt;/a&gt;, to making a free &lt;a id="hy3i" title="phone os" href="http://en.wikipedia.org/wiki/Android_%28operating_system%29"&gt;phone OS&lt;/a&gt;, to creating a ton of &lt;a id="atyt" title="free services" href="http://en.wikipedia.org/wiki/List_of_Google_products"&gt;free services to keep you hooked on the web&lt;/a&gt;. Google really doesn't &lt;i&gt;care&lt;/i&gt; what you do so long as you enjoy it and take in the targeted ads.&lt;/p&gt;&lt;p&gt;The book tended to focus on more traditional forms of strategy such as "cost leadership", "differentiation", and "focus on the customer" as well as applying &lt;a id="r7rh" title="game theory" href="http://oyc.yale.edu/economics/game-theory/"&gt;lessons&lt;/a&gt; from the famous &lt;a title="prisoner's dilemma" href="http://en.wikipedia.org/wiki/Prisoner%27s_dilemma"&gt;prisoner's dilemma&lt;/a&gt;. I acknowledge that these are important as well, but I think that at its core, strategy can be simple.&lt;/p&gt;&lt;h4&gt;Day 10 - Minicourses&lt;/h4&gt;&lt;p&gt;The book ended with "minicourses" in areas relevant to business such as:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Property (&lt;a id="wn-y" title="real estate" href="http://en.wikipedia.org/wiki/Real_estate"&gt;real estate&lt;/a&gt;, &lt;a id="fh.s" title="patents" href="http://en.wikipedia.org/wiki/Patent"&gt;patents&lt;/a&gt;, &lt;a id="n60z" title="copyright" href="http://en.wikipedia.org/wiki/Copyright"&gt;copyright&lt;/a&gt;, etc)&lt;/li&gt;&lt;li&gt;Leadership (e.g. schools want to create 'leaders' because they'll be better future donors).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Although those were interesting, the section I enjoyed the most was on business law. &lt;/p&gt;&lt;p&gt;In our jobs, we often bump into legal matters. We face &lt;a id="vixg" title="End User License Agreements" href="http://en.wikipedia.org/wiki/Software_license_agreement"&gt;End User License Agreements&lt;/a&gt; (EULAs) and &lt;a id="i4d8" title="Non-Disclosure Agreements" href="http://en.wikipedia.org/wiki/Non-disclosure_agreement"&gt;Non-Disclosure Agreements&lt;/a&gt; (NDAs) that we rarely read and often don't fully understand. It was interesting to see any proper &lt;a id="ycgp" title="contract" href="http://en.wikipedia.org/wiki/Contract"&gt;contract&lt;/a&gt; requires the following four conditions to be valid:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Capacity of Parties - Parties must have legal authorization and be mentally capable to enter into the agreement.&lt;/li&gt;&lt;li&gt;Mutual Agreement (Assent) or Meeting of the Minds - There must be a valid offer and an acceptance.&lt;/li&gt;&lt;li&gt;Consideration Given - Value must be given for the promise to be enforceable.&lt;/li&gt;&lt;li&gt;Legality - You can't enforce a contract dealing with illegal goods or actions.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;When bad things happen, it can sometimes escalate to a "legal action" which has a &lt;a id="evo2" title="standard procedure" href="http://en.wikipedia.org/wiki/Template:Civil_procedure_%28United_States%29"&gt;standard procedure&lt;/a&gt; involving steps you sometimes hear in the news:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Jurisdiction - For a court to hear a case, it must have "jurisdiction" to hear the case and power to bind the parties the decision. &lt;/li&gt;&lt;li&gt;Pleadings - The paperwork to start the trial process. The plaintiff (p) files a complaint asserting that the defendant (?) has done something wrong and requests a punishment or remedy.&lt;/li&gt;&lt;li&gt;Discovery - Lawyers gather witnesses and evidence before a trial. Each side is allowed to see the evidence held by the other side.&lt;/li&gt;&lt;li&gt;Pretrial Conference - The lawyers and judge try to focus the case on the most important issues. This is also good time for out-of-court settlements if possible.&lt;/li&gt;&lt;li&gt;Trial - Occurs before the court. The jury decides the factual disputes. The case can be thrown out by the judge with a "summary judgment" if it has no merit.&lt;/li&gt;&lt;li&gt;Jury Instruction by the Judge and the Verdict - The judge instructs the jury about the relevant law involved and the jury makes its decision about the facts and penalty within its authority.&lt;/li&gt;&lt;li&gt;Posttrial Motions - Options include asking for a retrial if an error of law or procedure occurred (e.g. jury misconduct).&lt;/li&gt;&lt;li&gt;Appeal - Each party in a lawsuit is entitled to one appeal at an appellate court where they can file a written brief with arguments for a new trial.&lt;/li&gt;&lt;li&gt;Secure or Enforce the Judgment - Send the person to jail and/or collect money.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;While the short overview was intriguing, it enforced my belief that it's important to have &lt;a id="syvu" title="an attorney or a lawyer" href="http://wiki.answers.com/Q/What_is_the_difference_between_a_lawyer_and_an_attorney"&gt;an attorney or a lawyer&lt;/a&gt; when it comes to the legal matters. At the very least, they usually have malpractice insurance if things go really bad.&lt;/p&gt;&lt;h4&gt;Conclusion&lt;/h4&gt;&lt;p&gt;The &lt;a href="http://www.amazon.com/gp/product/0060799072?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0060799072"&gt;Ten Day MBA&lt;/a&gt; helped me move from being &lt;a id="pmyp" title="unconscious incompetence" href="http://en.wikipedia.org/wiki/Four_stages_of_competence"&gt;unconsciously incompetent&lt;/a&gt; about business administration to becoming consciously incompetent in just a few days. I think that alone made it worth the time. I don't have aspirations to get a real MBA, but I now have more respect for those that do.&lt;/p&gt;&lt;p&gt;And now, back to programming...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6800934446457898793-3330061764648564469?l=www.moserware.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=Elx-AJC9xek:GySGs5KYGDs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=Elx-AJC9xek:GySGs5KYGDs:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=Elx-AJC9xek:GySGs5KYGDs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=Elx-AJC9xek:GySGs5KYGDs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=Elx-AJC9xek:GySGs5KYGDs:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=Elx-AJC9xek:GySGs5KYGDs:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=Elx-AJC9xek:GySGs5KYGDs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=Elx-AJC9xek:GySGs5KYGDs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=Elx-AJC9xek:GySGs5KYGDs:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=Elx-AJC9xek:GySGs5KYGDs:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Moserware/~4/Elx-AJC9xek" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.moserware.com/feeds/3330061764648564469/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=6800934446457898793&amp;postID=3330061764648564469" title="28 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default/3330061764648564469?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default/3330061764648564469?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Moserware/~3/Elx-AJC9xek/just-enough-mba-to-be-programmer.html" title="Just Enough MBA to Be a Programmer" /><author><name>Jeff Moser</name><uri>http://www.blogger.com/profile/16074905903060665396</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08376966494433799517" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_Zfbv3mHcYrc/SmKJ_BwtVCI/AAAAAAAABfU/BAq3TOcY2UI/s72-c/GoogleBalances.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">28</thr:total><feedburner:origLink>http://www.moserware.com/2009/07/just-enough-mba-to-be-programmer.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcMR3cyeip7ImA9WxJbEEQ.&quot;"><id>tag:blogger.com,1999:blog-6800934446457898793.post-680453867994856278</id><published>2009-06-10T08:57:00.011-04:00</published><updated>2009-07-20T08:14:46.992-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-20T08:14:46.992-04:00</app:edited><title>The First Few Milliseconds of an HTTPS Connection</title><content type="html">&lt;p&gt;Convinced from spending hours reading &lt;a href="http://www.amazon.com/Tuscan-Whole-Milk-Gallon-128/product-reviews/B00032G1S0/ref=dp_top_cm_cr_acr_txt?ie=UTF8&amp;amp;showViewpoints=1"&gt;rave reviews&lt;/a&gt;, Bob eagerly clicked "Proceed to Checkout" for his gallon of &lt;a href="http://www.amazon.com/gp/product/B00032G1S0?ie=UTF8&amp;amp;tag=moserware-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00032G1S0"&gt;Tuscan Whole Milk&lt;/a&gt; and...&lt;/p&gt;&lt;p&gt;Whoa! What just happened?&lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/ShgnOU1MihI/AAAAAAAABNI/BAF-YQdhkJU/s1600-h/securitysymbols.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/ShgnOU1MihI/AAAAAAAABNI/BAF-YQdhkJU/s400/securitysymbols.png" /&gt;&lt;/a&gt; &lt;p&gt;In the 220 milliseconds that flew by, a lot of interesting stuff happened to make Firefox change the address bar color and put a lock in the lower right corner. With the help of &lt;a href="http://www.wireshark.org/"&gt;Wireshark&lt;/a&gt;, my favorite network tool, and a slightly modified debug build of Firefox, we can see &lt;i&gt;exactly&lt;/i&gt; what's going on.&lt;/p&gt;&lt;p&gt;By agreement of &lt;a href="http://tools.ietf.org/html/rfc2818"&gt;RFC 2818&lt;/a&gt;, Firefox knew that "https" meant it should connect to &lt;a href="http://tools.ietf.org/html/rfc2818#section-2.3"&gt;port 443&lt;/a&gt; at Amazon.com:&lt;/p&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si8K9mA5QcI/AAAAAAAABOI/1agNWSS6NBE/s1600-h/httpsport.png"&gt;&lt;img src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si8K9mA5QcI/AAAAAAAABOI/1agNWSS6NBE/s400/httpsport.png" /&gt;&lt;/a&gt; &lt;p&gt;Most people associate HTTPS with &lt;a id="fyrr" title="SSL" href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer"&gt;SSL&lt;/a&gt; (Secure Sockets Layer) which was &lt;a id="yq6y" title="created by Netscape" href="http://www.mozilla.org/projects/security/pki/nss/history.html"&gt;created by Netscape in the mid 90's&lt;/a&gt;. This is becoming less true over time. As Netscape lost market share, SSL's maintenance moved to the Internet Engineering Task Force (&lt;a href="http://en.wikipedia.org/wiki/IETF"&gt;IETF&lt;/a&gt;). The first post-Netscape version was re-branded as Transport Layer Security (&lt;a href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer"&gt;TLS&lt;/a&gt;) 1.0 which &lt;a href="http://tools.ietf.org/html/rfc2246"&gt;was released&lt;/a&gt; in January 1999. It's rare to see true "SSL" traffic given that TLS has been around for 10 years. &lt;/p&gt;&lt;h4&gt;Client Hello&lt;/h4&gt;&lt;p&gt;TLS wraps all traffic in "records" of different types. We see that the first byte out of our browser is the hex byte 0x16 = 22 which &lt;a id="ihzy" title="means" href="http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml"&gt;means&lt;/a&gt; that this is a "handshake" record:&lt;/p&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si-df4pU51I/AAAAAAAABQg/A1flWimwg9M/s1600-h/clienthellowithannotations.png"&gt;&lt;img src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si-df4pU51I/AAAAAAAABQg/A1flWimwg9M/s400/clienthellowithannotations.png" /&gt;&lt;/a&gt; &lt;p&gt;The next two bytes are 0x0301 which indicate that this is a version 3.1 record which shows that TLS 1.0 is essentially SSL 3.1. &lt;/p&gt;&lt;p&gt;The handshake record is broken out into several messages. The first is our "Client Hello" message (0x01). There are a few important things here:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Random:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8g9EXh8uI/AAAAAAAABOY/oBt1zr_n1XE/s1600-h/randomclientbytes.png"&gt;&lt;img src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8g9EXh8uI/AAAAAAAABOY/oBt1zr_n1XE/s400/randomclientbytes.png" /&gt;&lt;/a&gt;&lt;br /&gt;There are four bytes representing the current Coordinated Universal Time (&lt;a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time"&gt;UTC&lt;/a&gt;) in the Unix epoch format, which is the number of seconds since January 1, 1970. In this case, 0x4a2f07ca. It's followed by 28 random bytes. This will be used later on. &lt;/li&gt;&lt;li&gt;Session ID:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Si8iGgIk_gI/AAAAAAAABOg/NsPg9pMMpCw/s1600-h/sessionid.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Si8iGgIk_gI/AAAAAAAABOg/NsPg9pMMpCw/s400/sessionid.png" /&gt;&lt;/a&gt;&lt;br /&gt;Here it's empty/null. If we had previously connected to Amazon.com a few seconds ago, we could potentially resume a session and avoid a full handshake. &lt;/li&gt;&lt;li&gt;Cipher Suites:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8i6DwZDiI/AAAAAAAABOo/_Pv_1d-PbgU/s1600-h/ciphersuites.png"&gt;&lt;img src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8i6DwZDiI/AAAAAAAABOo/_Pv_1d-PbgU/s400/ciphersuites.png" /&gt;&lt;/a&gt;&lt;br /&gt;This is a list of all of the encryption algorithms that the browser is willing to support. Its top pick is a very strong choice of "&lt;a href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer"&gt;TLS&lt;/a&gt;_&lt;a href="http://en.wikipedia.org/wiki/Elliptic_Curve_Diffie-Hellman"&gt;ECDHE&lt;/a&gt;_&lt;a href="http://en.wikipedia.org/wiki/Elliptic_Curve_DSA"&gt;ECDSA&lt;/a&gt;_WITH_&lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard"&gt;AES&lt;/a&gt;_256_&lt;a href="http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29"&gt;CBC&lt;/a&gt;_&lt;a href="http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-0_and_SHA-1"&gt;SHA&lt;/a&gt;" followed by 33 others that it's willing to accept. Don't worry if none of that makes sense. We'll find out later that Amazon doesn't pick our first choice anyway. &lt;/li&gt;&lt;li&gt;&lt;a id="z8g0" title="server_name extension" href="http://tools.ietf.org/html/rfc4366#section-3.1"&gt;server_name extension&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si8jtnutNFI/AAAAAAAABOw/Czowyq3F-6Y/s1600-h/server_name.png"&gt;&lt;img src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si8jtnutNFI/AAAAAAAABOw/Czowyq3F-6Y/s400/server_name.png" /&gt;&lt;/a&gt;&lt;br /&gt;This is a way to tell Amazon.com that our browser is trying to reach &lt;a href="https://www.amazon.com/"&gt;https://www.amazon.com/&lt;/a&gt;. This is really convenient because our TLS handshake occurs long before any HTTP traffic. HTTP has a &lt;a id="v56x" title="" href="http://tools.ietf.org/html/rfc2616#section-14.23"&gt;"Host" header&lt;/a&gt; which allows a cost-cutting Internet hosting companies to pile hundreds of websites onto a single IP address. SSL has traditionally required a different IP for each site, but this extension allows the server to respond with the appropriate certificate that the browser is looking for. If nothing else, this extension should allow an extra week or so of IPv4 addresses. &lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;Server Hello&lt;/h4&gt;&lt;p&gt;Amazon.com replies with a handshake record that's a massive two packets in size (2,551 bytes). The record has version bytes of 0x0301 meaning that Amazon agreed to our request to use TLS 1.0. This record has three sub-messages with some interesting data:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;"Server Hello" Message (2):&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si-euEnAA6I/AAAAAAAABQo/l4-KRrTyNWY/s1600-h/serverhello.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si-euEnAA6I/AAAAAAAABQo/l4-KRrTyNWY/s400/serverhello.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;We get the server's four byte time Unix epoch time representation and its 28 random bytes that will be used later.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A 32 byte session ID in case we want to reconnect without a big handshake.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Of the 34 cipher suites we offered, Amazon picked "TLS_RSA_WITH_RC4_128_MD5" (0x0004). This means that it will use the "&lt;a href="http://en.wikipedia.org/wiki/RSA"&gt;RSA&lt;/a&gt;" &lt;a href="http://en.wikipedia.org/wiki/Public-key_cryptography"&gt;public key&lt;/a&gt; algorithm to verify certificate signatures and exchange keys, the &lt;a href="http://en.wikipedia.org/wiki/RC4"&gt;RC4&lt;/a&gt; encryption algorithm to encrypt data, and the &lt;a href="http://en.wikipedia.org/wiki/MD5"&gt;MD5&lt;/a&gt; hash function to verify the contents of messages. We'll cover these in depth later on. I personally think Amazon had selfish reasons for choosing this cipher suite. Of the ones on the list, it was the one that was least CPU intensive to use so that Amazon could crowd more connections onto each of their servers. A much less likely &lt;span style="font-size:85%;"&gt;possibility &lt;/span&gt;is that they wanted to pay special tribute to &lt;a href="http://en.wikipedia.org/wiki/Ronald_L._Rivest"&gt;Ron Rivest&lt;/a&gt;, who created all three of these algorithms.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Certificate Message (11):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Si8lTxR3m0I/AAAAAAAABPA/I-le95y0ldw/s1600-h/certificatemessage.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Si8lTxR3m0I/AAAAAAAABPA/I-le95y0ldw/s400/certificatemessage.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;This message takes a whopping 2,464 bytes and is the certificate that the client can use to validate Amazon's. It isn't anything fancy. You can view most of its contents in your browser:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Sirx5XZBa5I/AAAAAAAABNo/Z-R75rsjCL8/s1600-h/AmazonBasicCertInfo.png"&gt;&lt;img src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Sirx5XZBa5I/AAAAAAAABNo/Z-R75rsjCL8/s400/AmazonBasicCertInfo.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;"Server Hello Done" Message (14):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8l2fMvVlI/AAAAAAAABPI/QrxJ3S9ezOo/s1600-h/serverhellodone.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8l2fMvVlI/AAAAAAAABPI/QrxJ3S9ezOo/s400/serverhellodone.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;This is a zero byte message that tells the client that it's done with the "Hello" process and indicate that the server won't be asking the client for a certificate.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h4&gt;Checking out the Certificate&lt;/h4&gt;&lt;p&gt;The browser has to &lt;a href="http://www.koders.com/c/fid340AB659241B7C717B5B3E0095BBA4245FCE34FD.aspx#L862"&gt;figure out&lt;/a&gt; if it should trust Amazon.com. In this case, it's using certificates. It looks at Amazon's certificate and &lt;a href="http://www.koders.com/c/fid9207CD3EB61F5F08E38858D14997264BEDB5B62C.aspx#L1091"&gt;sees&lt;/a&gt; that the current time is between the "not before" time of August 26th, 2008 and before the "not after" time of August 27, 2009. It also &lt;a href="http://www.koders.com/c/fid9207CD3EB61F5F08E38858D14997264BEDB5B62C.aspx?s=CERT_CheckCertValidTimes#L1211"&gt;checks&lt;/a&gt; to make sure that the certificate's public key is authorized for exchanging secret keys. &lt;/p&gt;&lt;p&gt;Why should we trust this certificate? &lt;/p&gt;&lt;p&gt;Attached to the certificate is a "signature" that is just a really long number in &lt;a href="http://en.wikipedia.org/wiki/Endianness#Big-endian"&gt;big-endian&lt;/a&gt; format:&lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SihpJBoNeDI/AAAAAAAABNg/DgLY221ncEo/s1600-h/AmazonCertSigned.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SihpJBoNeDI/AAAAAAAABNg/DgLY221ncEo/s400/AmazonCertSigned.png" /&gt;&lt;/a&gt; &lt;p&gt;Anyone could have sent us these bytes. Why should we trust this signature? To answer that question, need to make a speedy detour into &lt;a id="tlez" title="mathemagic land" href="http://en.wikipedia.org/wiki/Donald_in_Mathmagic_Land"&gt;mathemagic land&lt;/a&gt;:&lt;/p&gt;&lt;h4&gt;Interlude: A Short, Not &lt;i&gt;Too&lt;/i&gt; Scary, Guide to RSA&lt;/h4&gt;&lt;p&gt;People &lt;a href="http://stackoverflow.com/questions/575561/do-programmers-have-to-be-good-in-mathematics-closed"&gt;sometimes wonder&lt;/a&gt; if math has any relevance to programming. Certificates give a very practical example of applied math. Amazon's certificate tells us that we should use the RSA algorithm to check the signature. &lt;a id="e:y3" title="RSA" href="http://en.wikipedia.org/wiki/RSA"&gt;RSA&lt;/a&gt; was created in the 1970's by MIT professors &lt;a id="g825" title="Ron Rivest" href="http://people.csail.mit.edu/rivest/"&gt;Ron *R*ivest&lt;/a&gt;, &lt;a id="h87n" title="Adi  Shamir" href="http://en.wikipedia.org/wiki/Adi_Shamir"&gt;Adi *S*hamir&lt;/a&gt;, and &lt;a id="m0.d" title="Len  Adleman" href="http://en.wikipedia.org/wiki/Leonard_Adleman"&gt;Len *A*dleman&lt;/a&gt; who found a &lt;a id="vw55" title="tied together" href="http://people.csail.mit.edu/rivest/Rsapaper.pdf"&gt;clever way&lt;/a&gt; to combine ideas spanning &lt;a id="w5fp" title="Greek mathematician from 300 BC" href="http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm"&gt;2000&lt;/a&gt; &lt;a id="i-7k" title="a third century AD Chinese mathematician" href="http://en.wikipedia.org/wiki/Chinese_remainder_theorem"&gt;years&lt;/a&gt; &lt;a id="ks_n" title="a 17th century French judge" href="http://en.wikipedia.org/wiki/Fermat%27s_little_theorem"&gt;of&lt;/a&gt; &lt;a id="o:ge" title="18th century math wizard" href="http://en.wikipedia.org/wiki/Euler_totient_function"&gt;math&lt;/a&gt; development to come up with a &lt;a href="http://mathworld.wolfram.com/RSAEncryption.html"&gt;beautifully simple algorithm&lt;/a&gt;:&lt;/p&gt;&lt;p&gt;You &lt;a id="si95" title="pick" href="http://en.wikipedia.org/wiki/Primality_test"&gt;pick&lt;/a&gt; two huge prime numbers "p" and "q." Multiply them to get "n = p*q." Next, you pick a small public &lt;a href="http://en.wikipedia.org/wiki/Exponentiation"&gt;exponent&lt;/a&gt; "e" which is the "encryption exponent" and &lt;a id="p_jx" title="a specially crafted inverse" href="http://en.wikipedia.org/wiki/Modular_multiplicative_inverse"&gt;a specially crafted inverse&lt;/a&gt; of "e" called "d" as the "decryption exponent." You then &lt;b&gt;make "n" and "e" public and keep "d" as secret as you possibly can&lt;/b&gt; and then throw away "p" and "q" (or keep them as secret as "d"). It's really important to remember that "e" and "d" are inverses of each other. &lt;/p&gt;&lt;p&gt;Now, if you have some message, you just need to interpret its bytes as a number "M." If you want to "encrypt" a message to create a "ciphertext", you'd calculate:&lt;/p&gt;&lt;p&gt;C ≡ M&lt;sup&gt;e&lt;/sup&gt; (mod n)&lt;/p&gt;&lt;p&gt;This means that you multiply "M" by itself "e" times. The "mod n" means that we only take the remainder (e.g. "&lt;a href="http://en.wikipedia.org/wiki/Modular_arithmetic"&gt;modulus&lt;/a&gt;") when dividing by "n." For example, 11 AM + 3 hours ≡ 2 (PM) (mod 12 hours). The recipient knows "d" which allows them to invert the message to recover the original message:&lt;/p&gt;&lt;p&gt;C&lt;sup&gt;d&lt;/sup&gt; ≡ (M&lt;sup&gt;e&lt;/sup&gt;)&lt;sup&gt;d&lt;/sup&gt; ≡ M&lt;sup&gt;e*d&lt;/sup&gt; ≡ M&lt;sup&gt;1&lt;/sup&gt; ≡ M (mod n)&lt;/p&gt;&lt;p&gt;Just as interesting is that the person with "d" can "sign" a document by raising a message "M" to the "d" exponent:&lt;/p&gt;&lt;p&gt;M&lt;sup&gt;d&lt;/sup&gt; ≡ S (mod n)&lt;/p&gt;&lt;p&gt;This works because "signer" makes public "S", "M", "e", and "n." Anyone can verify the signature "S" with a simple calculation:&lt;/p&gt;&lt;p&gt;S&lt;sup&gt;e&lt;/sup&gt; ≡ (M&lt;sup&gt;d&lt;/sup&gt;)&lt;sup&gt;e&lt;/sup&gt; ≡ M&lt;sup&gt;d*e&lt;/sup&gt; ≡ M&lt;sup&gt;e*d&lt;/sup&gt; ≡ M&lt;sup&gt;1&lt;/sup&gt; ≡ M (mod n)&lt;/p&gt;&lt;p&gt;Public key cryptography algorithms like RSA are often called "asymmetric" algorithms because the encryption key (in our case, "e") is not equal to (e.g. "symmetric" with) the decryption key "d". Reducing everything "mod n" makes it impossible to use the easy techniques that we're used to such as normal &lt;a href="http://en.wikipedia.org/wiki/Logarithm"&gt;logarithms&lt;/a&gt;. The magic of RSA works because you can calculate/encrypt C ≡ M&lt;sup&gt;e&lt;/sup&gt; (mod n) &lt;a href="http://en.wikipedia.org/wiki/Modular_exponentiation"&gt;very quickly&lt;/a&gt;, but it is &lt;i&gt;really hard&lt;/i&gt; to calculate/decrypt C&lt;sup&gt;d&lt;/sup&gt; ≡ M (mod n) without knowing "d." As we saw earlier, "d" is derived from &lt;a href="http://en.wikipedia.org/wiki/Integer_factorization"&gt;factoring&lt;/a&gt; "n" back to its "p" and "q", which is a &lt;a href="http://en.wikipedia.org/wiki/NP_%28complexity%29"&gt;tough problem&lt;/a&gt;.&lt;/p&gt;&lt;h4&gt;Verifying Signatures&lt;/h4&gt;&lt;p&gt;The big thing to keep in mind with RSA in the real world is that all of the numbers involved have to be &lt;i&gt;big&lt;/i&gt; to make things really hard to break using the &lt;a href="http://en.wikipedia.org/wiki/General_number_field_sieve"&gt;best algorithms that we have&lt;/a&gt;. How big? Amazon.com's certificate was "signed" by "VeriSign Class 3 Secure Server CA." From the certificate, we see that this VeriSign modulus "n" is 2048 bits long which has this 617 digit base-10 representation:&lt;/p&gt;&lt;blockquote&gt;1890572922 9464742433 9498401781 6528521078 8629616064 3051642608 4317020197 7241822595 6075980039 8371048211 4887504542 4200635317 0422636532 2091550579 0341204005 1169453804 7325464426 0479594122 4167270607 6731441028 3698615569 9947933786 3789783838 5829991518 1037601365 0218058341 7944190228 0926880299 3425241541 4300090021 1055372661 2125414429 9349272172 5333752665 6605550620 5558450610 3253786958 8361121949 2417723618 5199653627 5260212221 0847786057 9342235500 9443918198 9038906234 1550747726 8041766919 1500918876 1961879460 3091993360 6376719337 6644159792 1249204891 7079005527 7689341573 9395596650 5484628101 0469658502 1566385762 0175231997 6268718746 7514321&lt;/blockquote&gt;&lt;p&gt;(Good luck trying to find "p" and "q" from this "n" - if you could, you could generate real-looking VeriSign certificates.)&lt;/p&gt;&lt;p&gt;VeriSign's "e" is 2^16 + 1 = 65537. Of course, they keep their "d" value secret, probably on a safe hardware device protected by retinal scanners and armed guards. Before signing, VeriSign checked the validity of the contents that Amazon.com claimed on its certificate using a real-world "handshake" that involved &lt;a href="http://www.verisign.com/ssl/ssl-information-center/ssl-basics/index.html#a7"&gt;looking at several of their business documents&lt;/a&gt;. Once VeriSign was satisfied with the documents, they used the &lt;a href="http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-0_and_SHA-1"&gt;SHA-1&lt;/a&gt; hash algorithm to get a hash value of the certificate that had all the claims. In Wireshark, the full certificate shows up as the "signedCertificate" part:&lt;/p&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8nWe2TGdI/AAAAAAAABPY/E9qxHxjy0xA/s1600-h/certsignature.png"&gt;&lt;img src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8m5BF5D2I/AAAAAAAABPQ/Ljv8Jd0uBEE/s400/signedcertificate.png" /&gt;&lt;/a&gt; &lt;p&gt;It's sort of a misnomer since it actually means that those are the bytes that the signer is &lt;i&gt;going to sign &lt;/i&gt;and not the bytes that already include a signature.&lt;/p&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8nWe2TGdI/AAAAAAAABPY/E9qxHxjy0xA/s400/certsignature.png" /&gt; &lt;p&gt;The actual signature, "S", is simply called "encrypted" in Wireshark. If we raise "S" to VeriSign's public "e" exponent of 65537 and then take the remainder when divided by the modulus "n", we get this "decrypted" signature hex value:&lt;/p&gt;&lt;blockquote&gt;0001FFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFF00302130 0906052B0E03021A 05000414C19F8786 871775C60EFE0542 E4C2167C830539DB&lt;/blockquote&gt;&lt;p&gt;&lt;a href="http://tools.ietf.org/html/rfc2313#page-9"&gt;Per the PKCS #1 v1.5 standard&lt;/a&gt;, the first byte is "00" and it "ensures that the encryption block, [when] converted to an integer, is less than the modulus." The second byte of "01" indicates that this is a private key operation (e.g. it's a signature). This is followed by a lot of "FF" bytes that are used to pad the result to make sure that it's big enough. The padding is terminated by a "00" byte. It's followed by "30 21 30 09 06 05 2B 0E 03 02 1A 05 00 04 14" which is the &lt;a id="at3m" title="PKCS #1 v2.1 way" href="http://tools.ietf.org/html/rfc3447#page-43"&gt;PKCS #1 v2.1 way&lt;/a&gt; of specifying the &lt;a href="http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-0_and_SHA-1"&gt;SHA-1&lt;/a&gt; hash algorithm. The last 20 bytes are SHA-1 hash digest of the bytes in "signedCertificate."&lt;/p&gt;&lt;p&gt;Since the decrypted value &lt;a href="http://www.matasano.com/log/558/public-key-signature-forgery-collected/"&gt;is properly formatted&lt;/a&gt; and the last bytes are the same hash value that we can calculate independently, we can assume that whoever knew "VeriSign Class 3 Secure Server CA"'s private key "signed" it. We implicitly trust that only VeriSign knows the private key "d."&lt;/p&gt;&lt;p&gt;We can repeat the process to verify that "VeriSign Class 3 Secure Server CA"'s certificate was signed by VeriSign's "Class 3 Public Primary Certification Authority."&lt;/p&gt;&lt;p&gt;But why should we trust &lt;i&gt;that&lt;/i&gt;? There are no more levels on the trust chain. &lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sihn_4zmOYI/AAAAAAAABNY/di1a-vsPbYA/s1600-h/BuiltInCertificateHierarchy.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Sihn_4zmOYI/AAAAAAAABNY/di1a-vsPbYA/s400/BuiltInCertificateHierarchy.png" /&gt;&lt;/a&gt; &lt;p&gt;The top "VeriSign Class 3 Public Primary Certification Authority" was signed by &lt;i&gt;itself&lt;/i&gt;. This certificate has been built into Mozilla products as an implicitly trusted good certificate since version &lt;a href="http://bonsai.mozilla.org/cvslog.cgi?file=mozilla/security/nss/lib/ckfw/builtins/certdata.txt&amp;amp;rev=NSS_3_12_2_WITH_CKBI_1_73_RTM&amp;amp;mark=1.51"&gt;1.4 of certdata.txt&lt;/a&gt; in the Network Security Services (&lt;a href="http://www.mozilla.org/projects/security/pki/nss/"&gt;NSS&lt;/a&gt;) library. It was checked-in on September 6, 2000 by Netscape's Robert Relyea with the following comment:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;"Make the framework compile with the rest of NSS. Include a 'live' certdata.txt with those certs we have permission to push to open source (additional certs will be added as we get permission from the owners)." &lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;This decision has had a relatively long impact since the certificate has a validity range of January 28, 1996 - August 1, 2028.&lt;/p&gt;&lt;p&gt;As Ken Thompson explained so well in his "&lt;a href="http://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf"&gt;Reflections on Trusting Trust&lt;/a&gt;", you ultimately have to implicitly trust somebody. There is no way around this problem. In this case, we're implicitly trusting that Robert Relyea made a good choice. We also hope that &lt;a href="http://www.mozilla.org/projects/security/certs/policy/"&gt;Mozilla's built-in certificate policy&lt;/a&gt; is reasonable for the other built-in certificates.&lt;/p&gt;&lt;p&gt;One thing to keep in mind here is that all these certificates and signatures were simply used to form a trust chain. On the public Internet, VeriSign's root certificate is implicitly trusted by Firefox long before you go to any website. In a company, you can create your own root certificate authority (CA) that you can install on everyone's machine. &lt;/p&gt;&lt;p&gt;Alternatively, you can get around having to pay companies like VeriSign and avoid certificate trust chains altogether. Certificates are used to establish trust by using a trusted third-party (in this case, VeriSign). If you have a secure means of sharing a secret "key", such as whispering a long password into someone's ear, then you can use that pre-shared key (PSK) to establish trust. There are extensions to TLS to allow this, such as &lt;a href="http://tools.ietf.org/html/rfc4279"&gt;TLS-PSK&lt;/a&gt;, and my personal favorite, &lt;a href="http://tools.ietf.org/html/rfc5054"&gt;TLS with Secure Remote Password (SRP) extensions&lt;/a&gt;. Unfortunately, these extensions aren't nearly as widely deployed and supported, so they're usually not practical. Additionally, these alternatives impose a burden that we have to have some other secure means of communicating the secret that's more cumbersome than what we're trying to establish with TLS (otherwise, why wouldn't we use &lt;i&gt;that&lt;/i&gt; for everything?).&lt;/p&gt;&lt;p&gt;One final check that we need to do is to verify that the host name on the certificate is what we expected. &lt;a href="http://www.linkedin.com/in/nelsonbolyard"&gt;Nelson Bolyard&lt;/a&gt;'s comment in the &lt;a href="http://www.koders.com/c/fid1C807D78F4E4CA73466FEEAA78EA9F0B2D618199.aspx#L260"&gt;SSL_AuthCertificate function&lt;/a&gt; explains why: &lt;/p&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;span style="COLOR: rgb(0,128,0)"&gt;/* cert is OK. This is the client side of an SSL connection.&lt;br /&gt; * Now check the name field in the cert against the desired hostname.&lt;br /&gt; * NB: This is our only defense against Man-In-The-Middle (MITM) attacks! */&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;p&gt;This check helps prevent against a &lt;a href="http://en.wikipedia.org/wiki/Man-in-the-middle_attack"&gt;man-in-the-middle&lt;/a&gt; attack because we are implicitly trusting that the people on the certificate trust chain wouldn't do something bad, like sign a certificate claiming to be from Amazon.com unless it actually was Amazon.com. If an attacker is able to modify your DNS server by using a technique like &lt;a href="http://en.wikipedia.org/wiki/DNS_cache_poisoning"&gt;DNS cache poisoning&lt;/a&gt;, you might be fooled into thinking you're at a trusted site (like Amazon.com) because the address bar will look normal. This last check implicitly trusts certificate authorities to stop these bad things from happening.&lt;/p&gt;&lt;h4&gt;Pre-Master Secret&lt;/h4&gt;&lt;p&gt;We've verified some claims about Amazon.com and know its public encryption exponent "e" and modulus "n." Anyone listening in on the traffic can know this as well (as evidenced because we are using Wireshark captures). Now we need to create a random secret key that an eavesdropper/attacker can't figure out. This isn't as easy as it sounds. In 1996, researchers figured out that &lt;a href="http://en.wikipedia.org/wiki/Netscape_Navigator"&gt;Netscape Navigator&lt;/a&gt; 1.1 was &lt;a id="cjg_" title="using only three sources" href="http://www.cs.berkeley.edu/~daw/papers/ddj-netscape.html"&gt;using only three sources&lt;/a&gt; to seed their pseudo-random number generator (&lt;a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator"&gt;PRNG&lt;/a&gt;). The sources were: the time of day, the process id, and the parent process id. As the researchers showed, these "random" sources aren't that random and were relatively easy to figure out.&lt;/p&gt;&lt;p&gt;Since everything else was derived from these three "random" sources, it was possible to "break" the SSL "security" in 25 seconds on a 1996 era machine. If you still don't believe that finding randomness is hard, just &lt;a id="dfhi" title="ask the Debian OpenSSL maintainers" href="http://www.schneier.com/blog/archives/2008/05/random_number_b.html"&gt;ask the Debian OpenSSL maintainers&lt;/a&gt;. If you mess it up, all the security built on top of it is suspect.&lt;/p&gt;&lt;p&gt;On Windows, random numbers used for cryptographic purposes are generated by calling the &lt;a id="f9ln" title="CryptGenRandom function" href="http://msdn.microsoft.com/en-us/library/aa379942%28VS.85%29.aspx"&gt;CryptGenRandom function&lt;/a&gt; that hashes bits &lt;a id="qai9" title="sampled from over 125 sources" href="http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx#353493"&gt;sampled from over 125 sources&lt;/a&gt;. Firefox uses this function along with some bits derived from &lt;a id="a5vi" title="its own  function" href="http://www.koders.com/c/fidBC778BD3666AA64522D1FD4F4EC3331E44B4D204.aspx?s=RNG_GetNoise"&gt;its own function&lt;/a&gt; to seed its &lt;a id="k982" title="pseudo-random number generator" href="http://www.koders.com/c/fidD184CA9064625C0ADF48025F3FA0588FCD664057.aspx"&gt;pseudo-random number generator&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The 48 byte "pre-master secret" random value that's generated isn't used directly, but it's very important to keep it secret since a lot of things are derived from it. Not surprisingly, Firefox makes it hard to find out this value. I had to compile a debug version and set the &lt;a id="is1y" title="SSLDEBUGFILE" href="http://www.koders.com/c/fidCFCD763A9E0B2BEF3FB9D4D6C17B4094CBF21548.aspx#L2092"&gt;SSLDEBUGFILE&lt;/a&gt; and &lt;a id="sstz" title="SSLTRACE" href="http://www.koders.com/c/fidCFCD763A9E0B2BEF3FB9D4D6C17B4094CBF21548.aspx#L2101"&gt;SSLTRACE&lt;/a&gt; environment variables to see it. &lt;/p&gt;&lt;p&gt;In this particular session, the pre-master secret showed up in the SSLDEBUGFILE as: &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;4456: SSL[131491792]: Pre-Master Secret [Len: 48]&lt;br /&gt;03 01 bb 7b 08 98 a7 49 de e8 e9 b8 91 52 ec 81 ...{...I.....R..&lt;br /&gt;4c c2 39 7b f6 ba 1c 0a b1 95 50 29 be 02 ad e6 L.9{......P)....&lt;br /&gt;ad 6e 11 3f 20 c4 66 f0 64 22 57 7e e1 06 7a 3b .n.? .f.d"W~..z; &lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Note that it's not completely random. The first two bytes are, &lt;a id="ai16" title="by convention" href="http://tools.ietf.org/html/rfc2246#page-44"&gt;by convention&lt;/a&gt;, the TLS version (03 01).&lt;/p&gt;&lt;h4&gt;Trading Secrets&lt;/h4&gt;&lt;p&gt;We now need to get this secret value over to Amazon.com. By Amazon's wishes of "TLS_RSA_WITH_RC4_128_MD5", we will use RSA to do this. You &lt;em&gt;could&lt;/em&gt; make your input message equal to just the 48 byte pre-master secret, but the Public Key Cryptography Standard (PKCS) #1, version 1.5 RFC &lt;a id="fw3:" title="states" href="http://tools.ietf.org/html/rfc2313#page-8"&gt;tells us&lt;/a&gt; that we should pad these bytes with &lt;i&gt;random&lt;/i&gt; data to make the input equal to exactly the size of the modulus (1024 bits/128 bytes). This makes it harder for an attacker to determine our pre-master secret. It also gives us one last chance to protect ourselves in case we did something really bone-headed, like reusing the same secret. If we reused the key, the eavesdropper would likely see a different value placed on the network due to the random padding.&lt;/p&gt;&lt;p&gt;Again, Firefox makes it hard to see these random values. I had to insert debugging statements into &lt;a id="gyq6" title="the padding function" href="http://www.koders.com/c/fid1EB31A222A560045DBF9EC54457A1E0339825D58.aspx#L190"&gt;the padding function&lt;/a&gt; to see what was going on:&lt;/p&gt;&lt;blockquote&gt;&lt;pre&gt;wrapperHandle = fopen(&lt;span style="COLOR: rgb(163,21,21)"&gt;"plaintextpadding.txt"&lt;/span&gt;, &lt;span style="COLOR: rgb(163,21,21)"&gt;"a"&lt;/span&gt;);&lt;br /&gt;fprintf(wrapperHandle, &lt;span style="COLOR: rgb(163,21,21)"&gt;"PLAINTEXT = "&lt;/span&gt;);&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,255)"&gt;for&lt;/span&gt;(i = 0; i &amp;lt; modulusLen; i++)&lt;br /&gt;{&lt;br /&gt;    fprintf(wrapperHandle, &lt;span style="COLOR: rgb(163,21,21)"&gt;"%02X "&lt;/span&gt;, block[i]);&lt;br /&gt;}&lt;br /&gt;fprintf(wrapperHandle, &lt;span style="COLOR: rgb(163,21,21)"&gt;"\r\n"&lt;/span&gt;);&lt;br /&gt;fclose(wrapperHandle);&lt;/pre&gt;&lt;/blockquote&gt;&lt;p&gt;In this session, the full padded value was:&lt;/p&gt;&lt;blockquote&gt;00 02 12 A3 EA B1 65 D6 81 6C 13 14 13 62 10 53 23 B3 96 85 FF 24 FA CC 46 11 21 24 A4 81 EA 30 63 95 D4 DC BF 9C CC D0 2E DD 5A A6 41 6A 4E 82 65 7D 70 7D 50 09 17 CD 10 55 97 B9 C1 A1 84 F2 A9 AB EA 7D F4 CC 54 E4 64 6E 3A E5 91 A0 06 00 03 01 BB 7B 08 98 A7 49 DE E8 E9 B8 91 52 EC 81 4C C2 39 7B F6 BA 1C 0A B1 95 50 29 BE 02 AD E6 AD 6E 11 3F 20 C4 66 F0 64 22 57 7E E1 06 7A 3B&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;Firefox took this value and &lt;a href="http://www.koders.com/c/fid1B0E0F62F1B3DB6D7272F0BD781A1609D76FE6FE.aspx#L312"&gt;calculated&lt;/a&gt; "C ≡ M&lt;sup&gt;e&lt;/sup&gt; (mod n)" to get the value we see in the "&lt;a id="whfx" title="Client Key Exchange" href="http://tools.ietf.org/html/rfc2246#page-43"&gt;Client Key Exchange&lt;/a&gt;" record:&lt;/p&gt;&lt;p&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8oafu_5aI/AAAAAAAABPg/r41rp34D1pw/s1600-h/clientkeyexchange.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8oafu_5aI/AAAAAAAABPg/r41rp34D1pw/s400/clientkeyexchange.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Finally, Firefox sent out one last unencrypted message, a "&lt;a id="f_on" title="Change Cipher  Spec" href="http://tools.ietf.org/html/rfc2246#page-24"&gt;Change Cipher Spec&lt;/a&gt;" record: &lt;/p&gt;&lt;p&gt;&lt;a href="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8o_0Qi0HI/AAAAAAAABPo/M1cyaQ6le5A/s1600-h/clientchangecipherspec.png"&gt;&lt;img src="http://3.bp.blogspot.com/_Zfbv3mHcYrc/Si8o_0Qi0HI/AAAAAAAABPo/M1cyaQ6le5A/s400/clientchangecipherspec.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This is Firefox's way of telling Amazon that it's going to start using the agreed upon secret to encrypt its next message.&lt;/p&gt;&lt;h4&gt;Deriving the Master Secret&lt;/h4&gt;&lt;p&gt;If we've done everything correctly, both sides (and only those sides) now know the 48 byte (256 bit) pre-master secret. There's a slight trust issue here from Amazon's perspective: the pre-master secret just has bits that were generated by the client, they don't take anything into account from the server or anything we said earlier. We'll fix that be computing the "master secret." &lt;a id="lf0j" title="Per the spec" href="http://tools.ietf.org/html/rfc2246#page-47"&gt;Per the spec&lt;/a&gt;, this is done by calculating:&lt;/p&gt;&lt;blockquote&gt;master_secret = PRF(pre_master_secret, "master secret", ClientHello.random + ServerHello.random)&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;The "pre_master_secret" is the secret value we sent earlier. The "master secret" is simply a string whose &lt;a href="http://en.wikipedia.org/wiki/ASCII"&gt;ASCII&lt;/a&gt; bytes (e.g. "6d 61 73 74 65 72 ...") are used. We then concatenate the random values that were sent in the ClientHello and ServerHello (from Amazon) messages that we saw at the beginning.&lt;/p&gt;&lt;p&gt;The PRF is the "Pseudo-Random Function" that's also &lt;a id="vku-" title="defined in the  spec" href="http://tools.ietf.org/html/rfc2246#page-11"&gt;defined in the spec&lt;/a&gt; and is quite clever. It combines the secret, the ASCII label, and the seed data we give it by using the keyed-Hash Message Authentication Code (&lt;a href="http://en.wikipedia.org/wiki/HMAC"&gt;HMAC&lt;/a&gt;) versions of both &lt;a id="remv" title="MD5" href="http://en.wikipedia.org/wiki/MD5"&gt;MD5&lt;/a&gt; and &lt;a id="syuh" title="SHA-1" href="http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-0_and_SHA-1"&gt;SHA-1&lt;/a&gt; hash functions. Half of the input is sent to each hash function. It's clever because it is quite resistant to attack, even in the face of &lt;a id="kir7" title="MD5" href="http://www.win.tue.nl/hashclash/rogue-ca/"&gt;weaknesses in MD5&lt;/a&gt; &lt;a id="x8dy" title="and SHA-1" href="http://www.schneier.com/blog/archives/2005/02/sha1_broken.html"&gt;and SHA-1&lt;/a&gt;. This process can feedback on itself and iterate forever to generate as many bytes as we need. &lt;/p&gt;&lt;p&gt;Following this procedure, we obtain a 48 byte "master secret" of &lt;/p&gt;&lt;blockquote&gt;4C AF 20 30 8F 4C AA C5 66 4A 02 90 F2 AC 10 00 39 DB 1D E0 1F CB E0 E0 9D D7 E6 BE 62 A4 6C 18 06 AD 79 21 DB 82 1D 53 84 DB 35 A7 1F C1 01 19&lt;br /&gt;&lt;/blockquote&gt;&lt;h4&gt;Generating Lots of Keys&lt;/h4&gt;&lt;p&gt;Now that both sides have a "master secrets", the spec &lt;a id="qji3" title="shows us" href="http://tools.ietf.org/html/rfc2246#page-21"&gt;shows us&lt;/a&gt; how we can derive all the needed session keys we need using the PRF to create a "key block" where we will pull data from:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;key_block = PRF(SecurityParameters.master_secret, "key expansion", SecurityParameters.server_random + SecurityParameters.client_random);&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The bytes from "key_block" are used to populate the following:&lt;/p&gt;&lt;blockquote&gt;client_write_MAC_secret[SecurityParameters.hash_size]&lt;br /&gt;server_write_MAC_secret[SecurityParameters.hash_size]&lt;br /&gt;client_write_key[SecurityParameters.key_material_length]&lt;br /&gt;server_write_key[SecurityParameters.key_material_length]&lt;br /&gt;client_write_IV[SecurityParameters.IV_size]&lt;br /&gt;server_write_IV[SecurityParameters.IV_size]&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;Since we're using a &lt;a id="fgt_" title="stream cipher" href="http://en.wikipedia.org/wiki/Stream_cipher"&gt;stream cipher&lt;/a&gt; instead of a &lt;a id="xz.d" title="block cipher" href="http://en.wikipedia.org/wiki/Block_cipher"&gt;block cipher&lt;/a&gt; like the Advanced Encryption Standard (&lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard"&gt;AES&lt;/a&gt;), we don't need the Initialization Vectors (&lt;a id="aj5k" title="Initialization Vector" href="http://en.wikipedia.org/wiki/Initialization_vector"&gt;IV&lt;/a&gt;s). Therefore, we just need two Message Authentication Code (&lt;a id="eo8s" title="Message Authentication Code" href="http://en.wikipedia.org/wiki/Message_authentication_code"&gt;MAC&lt;/a&gt;) keys for each side that are 16 bytes (128 bits) each since the specified MD5 hash digest size is 16 bytes. In addition, the RC4 cipher uses a 16 byte (128 bit) key that both sides will need as well. All told, we need 2*16 + 2*16 = 64 bytes from the key block.&lt;/p&gt;&lt;p&gt;Running the PRF, we get these values: &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;client_write_MAC_secret = 80 B8 F6 09 51 74 EA DB 29 28 EF 6F 9A B8 81 B0&lt;br /&gt;server_write_MAC_secret = 67 7C 96 7B 70 C5 BC 62 9D 1D 1F 4A A6 79 81 61&lt;br /&gt;client_write_key = 32 13 2C DD 1B 39 36 40 84 4A DE E5 6C 52 46 72&lt;br /&gt;server_write_key = 58 36 C4 0D 8C 7C 74 DA 6D B7 34 0A 91 B6 8F A7&lt;/p&gt;&lt;/blockquote&gt;&lt;h4&gt;Prepare to be Encrypted!&lt;/h4&gt;&lt;p&gt;The last handshake message the client sends out is the "&lt;a id="n8-5" title="Finished messages" href="http://tools.ietf.org/html/rfc2246#page-46"&gt;Finished message&lt;/a&gt;." This is a clever message that proves that no one tampered with the handshake and it proves that we know the key. The client takes all bytes from all handshake messages and puts them into a "handshake_messages" buffer. We then calculate 12 bytes of "verify_data" using the pseudo-random function (PRF) with our master key, the label "client finished", and an MD5 and SHA-1 hash of "handshake_messages": &lt;/p&gt;&lt;blockquote&gt;verify_data = PRF(master_secret, "client finished", MD5(handshake_messages) + SHA-1(handshake_messages)) [12]&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;We take the result and add a record header byte "0x14" to indicate "finished" and length bytes "00 00 0c" to indicate that we're sending 12 bytes of verify data. Then, like all future encrypted messages, we need to make sure the decrypted contents haven't been tampered with. Since our cipher suite in use is TLS_RSA_WITH_RC4_128_MD5, this means we use the MD5 hash function.&lt;/p&gt;&lt;p&gt;Some people get paranoid when they hear MD5 because it has some weaknesses. I certainly don't advocate using it as-is. However, TLS is smart in that it doesn't use MD5 directly, but rather the &lt;a href="http://en.wikipedia.org/wiki/HMAC"&gt;HMAC&lt;/a&gt; version of it. This means that instead of using MD5(m) directly, we calculate:&lt;/p&gt;&lt;blockquote&gt;HMAC_MD5(Key, m) = MD5((Key ⊕ opad) ++ MD5((Key ⊕ ipad) ++ m)&lt;/blockquote&gt;&lt;p&gt;(The ⊕ means &lt;a href="http://en.wikipedia.org/wiki/Exclusive_or"&gt;XOR&lt;/a&gt;, ++ means concatenate, "opad" is the bytes "5c 5c ... 5c", and "ipad" is the bytes "36 36 ... 36").&lt;/p&gt;&lt;p&gt;In particular, we calculate:&lt;/p&gt;&lt;blockquote&gt;HMAC_MD5(client_write_MAC_secret, seq_num + TLSCompressed.type + TLSCompressed.version + TLSCompressed.length + TLSCompressed.fragment));&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;As you can see, we include a sequence number ("seq_num") along with attributes of the plaintext message (here it's called "TLSCompressed"). The sequence number foils attackers who might try to take a previously encrypted message and insert it midstream. If this occurred, the sequence numbers would definitely be different than what we expected. This also protects us from an attacker dropping a message. &lt;/p&gt;&lt;p&gt;All that's left is to encrypt these bytes.&lt;/p&gt;&lt;h4&gt;RC4 Encryption&lt;/h4&gt;&lt;p&gt;Our negotiated cipher suite was TLS_RSA_WITH_RC4_128_MD5. This tells us that we need to use &lt;a href="http://people.csail.mit.edu/rivest/faq.html"&gt;&lt;span style="COLOR: rgb(128,0,128)"&gt;Ron's Code&lt;/span&gt;&lt;/a&gt; #4 (&lt;a id="guhl" title="RC4" href="http://en.wikipedia.org/wiki/RC4"&gt;RC4&lt;/a&gt;) to encrypt the traffic. &lt;a href="http://en.wikipedia.org/wiki/Ron_Rivest"&gt;Ron Rivest&lt;/a&gt; developed the RC4 algorithm to generate random bytes based on a 256 byte key. The algorithm is so simple you can actually memorize it in a few minutes. &lt;/p&gt;&lt;p&gt;RC4 begins by creating a 256-byte "S" byte array and populating it with 0 to 255. You then iterate over the array by mixing in bytes from the key. You do this to create a state machine that is used to generate "random" bytes. To generate a random byte, we shuffle around the "S" array.&lt;/p&gt;&lt;p&gt;Put graphically, it looks like this:&lt;/p&gt;&lt;a href="http://en.wikipedia.org/wiki/RC4"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/SihmoVyIg1I/AAAAAAAABNQ/Jl6kMd1z2hE/s320/RC4.png" /&gt;&lt;/a&gt; &lt;p&gt;To encrypt a byte, we &lt;a href="http://en.wikipedia.org/wiki/Exclusive_or"&gt;xor&lt;/a&gt; this pseudo-random byte with the byte we want to encrypt. Remember that xor'ing a bit with 1 causes it to flip. Since we're generating random numbers, on average the xor will flip half of the bits. This random bit flipping is effectively how we encrypt data. As you can see, it's not very complicated and thus it runs quickly. I think that's why Amazon chose it. &lt;/p&gt;&lt;p&gt;Recall that we have a "client_write_key" and a "server_write_key." The means we need to create two RC4 instances: one to encrypt what our browser sends and the other to decrypt what the server sent us.&lt;/p&gt;&lt;p&gt;The first few random bytes out of the "client_write" RC4 instance are "7E 20 7A 4D FE FB 78 A7 33 ..." If we xor these bytes with the unencrypted header and verify message bytes of "14 00 00 0C 98 F0 AE CB C4 ...", we'll get what appears in the encrypted portion that we can see in Wireshark:&lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Si8ryrIoGrI/AAAAAAAABP4/1bSIRcRkERw/s1600-h/clientencryptedkeyexchange.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Zfbv3mHcYrc/Si8ryrIoGrI/AAAAAAAABP4/1bSIRcRkERw/s400/clientencryptedkeyexchange.png" /&gt;&lt;/a&gt; &lt;p&gt;The server does almost the same thing. It sends out a "Change Cipher Spec" and then a "Finished Message" that includes all handshake messages, including the &lt;em&gt;decrypted&lt;/em&gt; version of the client's "Finished Message." Consequently, this proves to the client that the server was able to successfully decrypt our message. &lt;/p&gt;&lt;h4&gt;Welcome to the Application Layer!&lt;/h4&gt;&lt;p&gt;Now, 220 milliseconds after we started, we're finally ready for the application layer. We can now send normal HTTP traffic that'll be encrypted by the TLS layer with the RC4 write instance and decrypt traffic with the server RC4 write instance. In addition, the TLS layer will check each record for tampering by computing the HMAC_MD5 hash of the contents.&lt;/p&gt;&lt;p&gt;At this point, the handshake is over. Our TLS record's content type is now 23 (0x17). Encrypted traffic begins with "17 03 01" which indicate the record type and TLS version. These bytes are followed by our encrypted size, which includes the HMAC hash. &lt;/p&gt;&lt;p&gt;Encrypting the plaintext of:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;GET /gp/cart/view.html/ref=pd_luc_mri HTTP/1.1&lt;br /&gt;Host: www.amazon.com&lt;br /&gt;User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009060911 Minefield/3.0.10 (.NET CLR 3.5.30729)&lt;br /&gt;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&lt;br /&gt;Accept-Language: en-us,en;q=0.5&lt;br /&gt;Accept-Encoding: gzip,deflate&lt;br /&gt;Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7&lt;br /&gt;Keep-Alive: 300&lt;br /&gt;Connection: keep-alive&lt;br /&gt;...&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;will give us the bytes we see on the wire:&lt;/p&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8s4nuKH8I/AAAAAAAABQA/feL3OBZV83s/s1600-h/firstclientappdataencrypted.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8s4nuKH8I/AAAAAAAABQA/feL3OBZV83s/s400/firstclientappdataencrypted.png" /&gt;&lt;/a&gt; &lt;p&gt;The only other interesting fact is that the sequence number increases on each record, it's now 1 (and the next record will be 2, etc).&lt;/p&gt;&lt;p&gt;The server does the same type of thing on its side using the server_write_key. We see its response, including the tell-tale application data header:&lt;/p&gt;&lt;p&gt;&lt;a href="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8tz1Y9BqI/AAAAAAAABQQ/B6_UN0lX7fM/s1600-h/firstserverappdata.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Zfbv3mHcYrc/Si8tz1Y9BqI/AAAAAAAABQQ/B6_UN0lX7fM/s400/firstserverappdata.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Decrypting this gives us: &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;HTTP/1.1 200 OK&lt;br /&gt;Date: Wed, 10 Jun 2009 01:09:30 GMT&lt;br /&gt;Server: Server&lt;br /&gt;...&lt;br /&gt;Cneonction: close&lt;br /&gt;Transfer-Encoding: chunked&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;which is a normal HTTP reply that includes a non-descriptive "Server: Server" header and a misspelled "&lt;a id="t7o1" title="Cneonction: close" href="http://www.nextthing.org/archives/2005/08/07/fun-with-http-headers"&gt;Cneonction: close&lt;/a&gt;" header coming from Amazon's load balancers.&lt;/p&gt;&lt;p&gt;TLS is just below the application layer. The HTTP server software can act as if it's sending unencrypted traffic. The only change is that it writes to a library that does all the encryption. &lt;a href="http://www.openssl.org/"&gt;OpenSSL&lt;/a&gt; is a popular open-source library for TLS.&lt;/p&gt;&lt;p&gt;The connection will stay open while both sides send and receive encrypted data until either side sends out a "&lt;a href="http://tools.ietf.org/html/rfc2246#page-25"&gt;closure alert&lt;/a&gt;" message and then closes the connection. If we reconnect shortly after disconnecting, we can re-use the negotiated keys (if the server still has them cached) without using public key operations, otherwise we do a completely new full handshake.&lt;/p&gt;&lt;p&gt;It's important to realize that application data records can be &lt;i&gt;anything&lt;/i&gt;. The only reason "HTTPS" is special is because the web is so popular. There are lots of other TCP/IP based protocols that ride on top of TLS. For example, TLS is used by &lt;a id="a7fg" title="SFTP" href="http://tools.ietf.org/html/rfc4217"&gt;FTPS&lt;/a&gt; and &lt;a id="y0ps" title="extensions to SMTP" href="http://tools.ietf.org/html/rfc3207"&gt;secure extensions to SMTP&lt;/a&gt;. It's certainly better to use TLS than inventing your own solution. Additionally, you'll benefit from a protocol that has withstood careful &lt;a href="http://tools.ietf.org/html/rfc5246#appendix-F"&gt;security analysis&lt;/a&gt;. &lt;/p&gt;&lt;h4&gt;... And We're Done!&lt;/h4&gt;&lt;p&gt;The very readable &lt;a id="u9ya" title="TLS RFC" href="http://tools.ietf.org/html/rfc5246"&gt;TLS RFC&lt;/a&gt; covers many more details that were missed here. We covered just one single path in our observation of the 220 millisecond dance between Firefox and Amazon's server. Quite a bit of the process was affected by the TLS_RSA_WITH_RC4_128_MD5 Cipher Suite selection that Amazon made with its ServerHello message. It's a reasonable choice that slightly favors speed over security. &lt;/p&gt;&lt;p&gt;As we saw, if someone could secretly factor Amazon's "n" modulus into its respective "p" and "q", they could effectively decrypt all "secure" traffic until Amazon changes their certificate. Amazon counter-balances this concern this with a short one year duration certificate:&lt;/p&gt;&lt;a href="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si8u2evehpI/AAAAAAAABQY/pFMUJ5-vmOU/s1600-h/amazoncertvalidity.png"&gt;&lt;img src="http://1.bp.blogspot.com/_Zfbv3mHcYrc/Si8u2evehpI/AAAAAAAABQY/pFMUJ5-vmOU/s400/amazoncertvalidity.png" /&gt;&lt;/a&gt; &lt;p&gt;One of the cipher suites that was offered was "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" which uses the &lt;a id="y2_." title="Diffie-Hellman key exchange" href="http://en.wikipedia.org/wiki/Diffie-Hellman_key_exchange"&gt;Diffie-Hellman key exchange&lt;/a&gt; that has a nice property of "&lt;a id="jtxx" title="forward secrecy" href="http://en.wikipedia.org/wiki/Perfect_forward_secrecy"&gt;forward secrecy&lt;/a&gt;." This means that if someone cracked the mathematics of the key exchange, they'd be no better off to decrypt another session. One downside to this algorithm is that it requires more math with big numbers, and thus is a little more computationally taxing on a busy server. The "Advanced Encryption Standard" (&lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard"&gt;AES&lt;/a&gt;) algorithm was present in many of the suites that we offered. It's different than RC4 in that it works on 16 byte "blocks" at a time rather than a single byte. Since its key can be up to 256 bits, many consider this to be more secure than RC4.&lt;/p&gt;&lt;p&gt;In just 220 milliseconds, two endpoints on the Internet came together, provided enough credentials to trust each other, set up encryption algorithms, and started to send encrypted traffic.&lt;/p&gt;&lt;p&gt;And to think, all of this just so Bob can buy milk.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I wrote a program that walks through the handshake steps mentioned in this article. &lt;a href="http://github.com/moserware/TLS-1.0-Analyzer/tree/master"&gt;I posted it to GitHub&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6800934446457898793-680453867994856278?l=www.moserware.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=qjQlyUN8Tnk:aE0vXZ6n9s0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=qjQlyUN8Tnk:aE0vXZ6n9s0:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=qjQlyUN8Tnk:aE0vXZ6n9s0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=qjQlyUN8Tnk:aE0vXZ6n9s0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=qjQlyUN8Tnk:aE0vXZ6n9s0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=qjQlyUN8Tnk:aE0vXZ6n9s0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=qjQlyUN8Tnk:aE0vXZ6n9s0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=qjQlyUN8Tnk:aE0vXZ6n9s0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Moserware?a=qjQlyUN8Tnk:aE0vXZ6n9s0:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Moserware?i=qjQlyUN8Tnk:aE0vXZ6n9s0:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Moserware/~4/qjQlyUN8Tnk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.moserware.com/feeds/680453867994856278/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=6800934446457898793&amp;postID=680453867994856278" title="121 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default/680453867994856278?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6800934446457898793/posts/default/680453867994856278?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Moserware/~3/qjQlyUN8Tnk/first-few-milliseconds-of-https.html" title="The First Few Milliseconds of an HTTPS Connection" /><author><name>Jeff Moser</name><uri>http://www.blogger.com/profile/16074905903060665396</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08376966494433799517" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_Zfbv3mHcYrc/ShgnOU1MihI/AAAAAAAABNI/BAF-YQdhkJU/s72-c/securitysymbols.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">121</thr:total><feedburner:origLink>http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html</feedburner:origLink></entry></feed>
