<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Securism Blog &#187; cryptography</title>
	<atom:link href="http://blog.securism.com/tag/cryptography/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.securism.com</link>
	<description>Simple Security.</description>
	<lastBuildDate>Fri, 23 Jul 2010 18:17:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Quick and Easy Portable Media Encryption</title>
		<link>http://blog.securism.com/2010/02/quick-and-easy-portable-media-encryption/</link>
		<comments>http://blog.securism.com/2010/02/quick-and-easy-portable-media-encryption/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 18:33:38 +0000</pubDate>
		<dc:creator>Walter Goulet</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Securism]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[delivery best practices]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.securism.com/?p=223</guid>
		<description><![CDATA[As part of my personal service delivery process, I have a need to store sensitive information for client engagements (vulnerability assessment results, network diagrams etc). To avoid having a dependency on specific test systems, I prefer to use portable USB drives to store data in the event that I need to switch to another system. [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my personal service delivery process, I have a need to store sensitive information for client engagements (vulnerability assessment results, network diagrams etc). To avoid having a dependency on specific test systems, I prefer to use portable USB drives to store data in the event that I need to switch to another system. However, I don&#8217;t want to risk losing this drive with confidential data on it. My solution is to create an encrypted partition on the disk in such a fashion that I can quickly mount the drive on another system without downtime.</p>
<p>To meet these requirements, I use a combination of Dropbox (<a href="http://www.dropbox.com">http://www.dropbox.com</a>), Keepass (<a href="http://keepass.info/">http://keepass.info/</a>), and Truecrypt (<a href="http://www.truecrypt.org/">http://www.truecrypt.org/</a>). I use Dropbox as a portable &#8216;Program Files&#8217; directory where I install portable versions of Keepass and Truecrypt. This allows me to have my &#8216;Program Files&#8217; directory replicated on all systems where the Dropbox client is installed (for backup purposes, I usually have my Dropbox account synchronized to 2 different systems).</p>
<p>I use Truecrypt to create an encrypted partition on the USB drive (using AES for encryption and HMAC-SHA-512 as a hash algorithm). The volume key used to encrypt/decrypt the partition is then stored as a password in my Keepass database (which is also stored in my Dropbox).</p>
<p>As long as the Dropbox is synchronized between my test systems, switching from one system to the other is as simple as plugging the USB drive in and launching Truecrypt/Keepass from my Dropbox.</p>
<p>Here&#8217;s my step by step instructions to replicating this setup on a Windows XP/Vista/7 system (I assume you already have Dropbox installed on your system):</p>
<ol>
<li>Create a &#8216;Programs&#8217; directory in your Dropbox folder. In this folder, create 2 subdirectories, &#8216;Keepass&#8217; and &#8216;Truecrypt&#8217;.</li>
<li>Copy the portable versions of these programs into their respective folders (Truecrypt does not have an explicit &#8216;portable&#8217; distribution, rather download the setup file <a href="http://www.truecrypt.org/downloads">here</a> and choose the &#8216;Extract&#8217; option when running the setup, Keepass on the other hand provides a portable version that can be downloaded <a href="http://keepass.info/download.html">here</a>).</li>
<li>Launch Keepass and create a new password entry for the portable drive. I suggest using the Password generator function to generate the password. Note that since this password is used as an encryption key, I recommend selecting all available characters for generating the password and using the maximum key length (64 characters).</li>
<li>Plug in the portable USB drive that will contain the encrypted partition (note: this has only been tested with USB hard drives; I have not tested this with smaller USB flash drives).</li>
<li>Launch TrueCrypt and use the &#8216;Create Volume&#8217; button to launch the new volume creation wizard. I recommend writing down the path to the volume being created to make it easier to mount later. For my personal setup, I chose to create a regular (non-hidden) partition using AES and SHA-512 for encryption and as a hash algorithm. When prompted for the volume password, use the password entry created in Keepass.</li>
<li>The volume is now created!</li>
</ol>
<p>To actually mount the encrypted partition, start Truecrypt and select an available drive entry. Select the encrypted volume from the Volume list then click &#8216;Mount&#8217;. When prompted, enter the password from the Keepass password entry.</p>
<p>Note that regardless of which system was used to create the encrypted partition, you can mount it on any other system as long as you have access to Truecrypt and your volume password.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.securism.com/2010/02/quick-and-easy-portable-media-encryption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hashes &#8211; not just for breakfast</title>
		<link>http://blog.securism.com/2009/01/hashes-not-just-for-breakfast/</link>
		<comments>http://blog.securism.com/2009/01/hashes-not-just-for-breakfast/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 05:54:54 +0000</pubDate>
		<dc:creator>Walter Goulet</dc:creator>
				<category><![CDATA[Fundamentals]]></category>
		<category><![CDATA[cryptography]]></category>

		<guid isPermaLink="false">http://blog.securism.com/?p=135</guid>
		<description><![CDATA[Hash functions are the basis of digital fingerprints which are used to ensure that information is not modified since it was created. In this post, a description of what hash functions are used for is discussed. A simple hash function is also presented along with an example.]]></description>
			<content:encoded><![CDATA[<p>Consider the problem where you need to know for sure that information you are looking at has not been altered since it was first created. A simple example that kids can relate to is a report card from school. The model for report cards is that the school gives a kid his/her report card, they bring it home and their parents sign it to show that they read the report card. An obvious problem that the school has is to be certain that the report card isn&#8217;t changed while the kid has it.</p>
<p>In cryptography, this problem is referred to as <em>&#8216;data integrity.&#8217;</em> Cryptographic systems solve this problem by creating a representation of the information that is unique. This representation is referred to as a <em>&#8216;hash&#8217; </em>(or checksum). A good way to think of a hash is as a digital fingerprint that looks totally different for each set of data that it represents. Functions that are used to create hashes from information are called hash functions. There are a couple of important points about hash functions:</p>
<ul>
<li>The result of the hash function MUST be unique for each message that it processes. That is, you should never be able to get the same result from a hash function if you feed in two different messages.</li>
<li>The result of the hash function MUST not look anything like the message that it processed.</li>
<li>It MUST be impossible, given the result of a hash function, to determine what the original message was.</li>
<li>The result of the hash function is usually smaller than the message that it processed.</li>
</ul>
<p>If you wanted to exchange a message with another person and be sure that the message hasn&#8217;t been changed along the way, you could use a hash function as follows:</p>
<ol>
<li>Create a message.</li>
<li>Feed that message into a hash function.</li>
<li>Send the message to the recipient along with the hash.</li>
<li>The recipient feeds the message into the same hash function used by the sender.</li>
<li>The recipient compares their hash with the sender&#8217;s hash. If they are identical, the recipient is sure that the message wasn&#8217;t changed.</li>
</ol>
<p>Of course this exchange isn&#8217;t secure as the hash could be changed in transit as well, but it illustrates how such a system works. I&#8217;ll explain how to make this exchange secure in a future post. To find out more about the basics of hash functions, read more.</p>
<p><span id="more-135"></span>So, how exactly do hash algorithms work? They work by mixing and mashing the messages being hashed. The mixing and mashing is done by dividing a message into a set of chunks. These chunks are then mixed together using math operations (this step varies greatly depending on the hash function being used).</p>
<p>Here&#8217;s an example of a very simple hash function. In this function, note that letters are represented using numbers (ASCII codes, so A=65, B=66, C=67 &#8230; Z=90). Note that when using ASCII characters to represent numeric values, you have to have numeric values in the range of 65 to 90 in order to be able to print them as characters.</p>
<ul>
<li>Divide your message into sets of 8 letters. If the number of letters in your message is not evenly divisible by 8, add as many &#8216;i&#8217;s to your message as needed to make it divisible by 8 (this is called <strong>&#8216;</strong><em>padding&#8217;</em>).</li>
<li>Replace the letters with numbers (ASCII values which can be found <a href="http://www.asciitable.com/">here</a>).</li>
<li>Now, arrange the sets of 8 numbers in a vertical column; ex. if your message has 24 letters, you should have 3 rows of 8 numbers arranged in a column.</li>
<li>Starting at the top row, add the first number in the first 2 rows together. Since this number is going to be larger than 90, we need to do a little more math to make it fall in the range of 65 &#8211; 90. So we will take this sum and divide it by 26. This will ensure that the number is in the range of 0 &#8211; 26. Next, we&#8217;ll take this remainder value and add 65 to it. This way, we can be sure the final value will be in the range of 65 &#8211; 90. This final value then becomes the first value in a new row. Repeat this step for all of the characters in the first two rows.  (For readers of my previous post on clock arithmetic, this calculation is just modular arithmetic, specifically we are calculating the value mod 26).</li>
<li>The new row that you&#8217;ve created now replaces the first 2 rows. Repeat the previous step until you&#8217;ve added all the rows together.</li>
<li>The final row that results from doing these operations represents the hash value for the message.</li>
</ul>
<p>Here&#8217;s an example where I calculate the hash of the value &#8220;walter goulet is here&#8221;</p>
<p>The message &#8220;WALTER GOULET IS HERE&#8221; looks like this encoded in ASCII (the value 32 is a space character.)</p>
<p>87 65 76 84 69 82 32 71 79 85 76 69 84 32 73 83 32 72 69 82 69</p>
<p>Note that there are only 21 characters in this message, so we need to add 3 &#8220;I&#8221;s to the end for padding. The ASCII code for &#8216;I&#8217; is 73. So, the padded message looks like this:</p>
<p>87 65 76 84 69 82 32 71 79 85 76 69 84 32 73 83 32 72 69 82 69 73 73 73</p>
<p>Next, we break the message into sets of 8 numbers:</p>
<ol>
<li>87 65 76 84 69 82 32 71</li>
<li>79 85 76 69 84 32 73 83</li>
<li>32 72 69 82 69 73 73 73</li>
</ol>
<p>Now, we add rows 1 and 2 together by adding each number in the same position together, dividing it by 26 to get the remainder, and add the value &#8217;65&#8242; to the result. Let&#8217;s perform this operation on rows 1 and 2:</p>
<p>87 + 79 = 166; 166 / 26 = 6 remainder 10; 10 + 65 = <strong>75</strong></p>
<p>65 + 85 = 150; 150 / 26 = 5 remainder 20; 20 + 65 = <strong>85</strong></p>
<p>and so on for each number in rows 1 and 2. The new row, after repeating this for each number, becomes</p>
<p><strong>75 85 87 88 88 75 66 89</strong></p>
<p>The new row is then added to row number 3 above using the same process.</p>
<ol>
<li>75 85 87 88 88 75 66 89</li>
<li>32 72 69 82 69 73 73 73</li>
</ol>
<p>After repeating this operation, the new row is:<br />
<strong>68 66 65 79 66 83 74 71</strong></p>
<p>After replacing these numeric values with their letter values, the final result is:<br />
<strong>D  B  A  O  B  S  J  G</strong><br />
This value is our hash value for the message &#8220;WALTER GOULET IS HERE&#8221;.</p>
<p>As an exercise, try changing a letter in the original message. You&#8217;ll see that when you do, the final hash output will change as well. Note that this toy hash function isn&#8217;t nearly as strong as real hash functions used in security technologies, but the basic ideas are the same</p>
<p>For interested readers, here&#8217;s a Ruby program implementing the hash function described above. Play around with different messages to see how the hashing works and to spot potential problems from this simplistic hash function.</p>
<blockquote>
<pre>#!/usr/bin/ruby -w</pre>
<pre>msgstr = String.new(ARGV[0])</pre>
<pre>msgarr = Array.new</pre>
<pre>arrindex = 0</pre>
<pre>msgstr.upcase!</pre>
<pre># Pad the input message string if it's length is not divisible by 8</pre>
<pre>if((numchar = msgstr.length.modulo(8)) != 0)</pre>
<pre>        padchars = 8 - numchar</pre>
<pre>        padchars.times do</pre>
<pre>                msgstr = msgstr + "I"</pre>
<pre>        end</pre>
<pre>end</pre>
<pre># Break the message into 8 character (or byte) words</pre>
<pre>strsize = msgstr.length</pre>
<pre>while(strsize &gt; 0)</pre>
<pre>        if(strsize.modulo(8) == 0)</pre>
<pre>                msgarr[arrindex] = msgstr.slice!(0..7)</pre>
<pre>                arrindex = arrindex + 1</pre>
<pre>        end</pre>
<pre>        strsize = strsize  - 1</pre>
<pre>end</pre>
<pre># Add the rows</pre>
<pre>while(msgarr.length &gt; 1)</pre>
<pre>        row1 = msgarr.shift</pre>
<pre>        row2 = msgarr.first</pre>
<pre>        0.upto(7) do |x|</pre>
<pre>                row2[x] = ((row1[x] + row2[x]) % 26) + 65</pre>
<pre>        end</pre>
<pre>end</pre>
<pre>print msgarr.first</pre>
<pre>print "n"</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.securism.com/2009/01/hashes-not-just-for-breakfast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clock arithmetic and security</title>
		<link>http://blog.securism.com/2009/01/clock-arithmetic-and-security/</link>
		<comments>http://blog.securism.com/2009/01/clock-arithmetic-and-security/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 04:12:12 +0000</pubDate>
		<dc:creator>Walter Goulet</dc:creator>
				<category><![CDATA[Fundamentals]]></category>
		<category><![CDATA[cryptography]]></category>

		<guid isPermaLink="false">http://blog.securism.com/?p=125</guid>
		<description><![CDATA[Modular arithmetic (a simple example of which is clock arithmetic) forms the basis of many key negotiation and encryption algorithms. In this post I explain how modular arithmetic works and describe a simple cryptosystem that uses modular arithmetic for key agreement.]]></description>
			<content:encoded><![CDATA[<p>Quick quiz, what do the following sequence of numbers have in common: 19, 3763, 31, and 67? The answer is, they are all the same! Ok, well obviously that&#8217;s not strictly true. More correctly, these numbers all represent the same value in modular arithmetic (7 modulo 12). When you take each of these numbers and divide them by 12, you end up with a remainder of 7 (19 / 12 = 1 remainder 7, 3763 / 12 = 313 remainder 7, 31 / 12 = 2 remainder 7, and 67 / 12 = 5 remainder 7).</p>
<p>Another simple way to think of modular arithmetic is clock arithmetic. Consider the problem when you are looking at an analog 12 hour clock. You need to figure out what time it is going to be 7 hours from now. If the current time is 3 o&#8217;clock PM, you add 7 hours and end up with 10 o&#8217;clock PM. But, what if it&#8217;s 8pm? You don&#8217;t simply add 7 hours as there is no such thing as 15 o&#8217;clock pm. Instead, when you pass 12 o&#8217;clock AM, you restart your counting. So 8 o&#8217;clock PM + 7 hours = 12 o&#8217;clock AM + 3hrs = 3 o&#8217;clock AM.</p>
<p>So what does clock arithmetic have to do with security? Going back to our original sequence of numbers, notice that you cannot possibly determine that these numbers all represent the same mathematical value without having a key piece of information, the modulo value (which in this case is 12). When you think about it, this property is useful from a secrecy perspective because you have 2 pieces of information that have a common value, but you can&#8217;t tell what that common value is unless you know some other information. This basic property of modular arithmetic forms the basis of many of the key negotiation and encryption algorithms in use today.</p>
<p>So, for fun, here&#8217;s a simple cryptosystem (secure enough to keep your 10 year old little sister from reading your journal) that uses this property. Note this cryptosystem doesn&#8217;t authenticate the two parties, but it at least allows them to exchange a pair of secret keys no matter who is listening.</p>
<ul>
<li>Alice and Bob want to exchange a secret message, but they can only talk to each other over an open communication channel.</li>
<li>Beforehand, Alice and Bob agree to use the current time as the modulo value for determining the secret value. For example, if the current time is 4pm and Alice and Bob want to agree on a secret key, they will divide their values by 4. Note that the method they are using for choosing a modulo value must remain secret for this system to work.</li>
<li>Alice sends her value to Bob in an open channel. Bob calculates the value she sent modulo the current time. The result is Alice&#8217;s encryption key.</li>
<li>Bob sends his value to Alice again in an open channel.</li>
<li>Alice calculates the value she got from Bob modulo the current time. The result is Bob&#8217;s encryption key.</li>
<li>Now, Alice and Bob can communicate securely using each other&#8217;s encryption key to encrypt messages being sent back and forth (using some pre-determined encryption algorithm).</li>
</ul>
<p>To see the system in action:</p>
<ol>
<li>The current time is 9pm.</li>
<li>Alice picks a value of 84.</li>
<li>Bob picks a value of 1156.</li>
<li>Alice and Bob send a message to each other via a open channel (normal phone call, ads in the newspaper, or even yelling at each other in a park!).</li>
<li>Alice get&#8217;s Bob&#8217;s value of 1156 and calculates 1156 / 9 = 128 remainder 4. 4 is Bob&#8217;s encryption key.</li>
<li>Bob get&#8217;s Alice&#8217;s value of 84 and calculates 84 / 9 = 9 remainder 3. 3 is Alice&#8217;s encryption key.</li>
<li>Now Bob and Alice can encrypt their messages using their respective encryption keys.</li>
</ol>
<p>The real beauty of this type of system is that no matter who learns the values that Alice and Bob selected in steps 2 &amp; 3, they will never be able to figure out how they are related without knowing what the modulo value is. In a future post, I&#8217;ll expand on this a bit more to show how modular arithmetic is used in non-toy cryptosystems.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.securism.com/2009/01/clock-arithmetic-and-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
