<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2836700939935266529</id><updated>2012-02-20T18:48:17.376-05:00</updated><category term='x0xb0x'/><category term='Python'/><category term='Cryptography'/><category term='rebirth'/><category term='Encryption'/><category term='linux dd backup gzip compression'/><category term='AES'/><category term='muzak'/><category term='googles'/><category term='blog'/><category term='PyCrypto'/><category term='303'/><title type='text'>Das Bityard</title><subtitle type='html'>Do not bend, staple, or fold.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-6457594570632738635</id><published>2011-12-15T00:36:00.000-05:00</published><updated>2011-12-15T00:37:02.007-05:00</updated><title type='text'>Web Frameworks: When Love is Gone</title><content type='html'>&lt;a href="http://djangoproject.com/"&gt;Django&lt;/a&gt; and I were not meant to be.&lt;br /&gt;&lt;br /&gt;For the last few months I've been trying to throw together a quick little site for my wife's photography hobby. Normally I reach for &lt;a href="http://codeigniter.com/"&gt;CodeIgniter&lt;/a&gt; (a PHP web framework) when I want to bang together a web site where an existing CMS doesn't quite fit the bill. CodeIgniter simply takes care of all the mundane stuff that you normally have to worry about when developing a web site or application. To use it, you simply extract the CodeIgniter tarball, perform some minor configuration, and point Apache at it. From there, you just add your models, views, controllers, templates, and static files. You can utilize any of the plentiful CodeIgniter helper libraries and classes if you happen to need or want them.&lt;br /&gt;&lt;br /&gt;But where I work, Python is more or less the programming language of choice for anything that isn't primarily shell work (bash) or high-performance (C). Since I haven't used Python extensively for Serious Work, I thought I would give a Python web framework a try for this new project. Django came highly recommended, so I went with it. One thing I fell in love with immediately was Django's built-in customizable admin interface based around the app's models. Man, that's slick.&lt;br /&gt;&lt;br /&gt;I followed the rather lengthy tutorial in the beginning and was encouraged. At the outset, it looked like Django was going to be a lot like CodeIgniter only "Pythonic" and with many more built-in features. But as dug into it, I found that the authors were explaining less as they went along, which forced me to wade through the Django documentation to get an idea of what was really going on. Now, the Django docs aren't bad per se but to me they read more like system specs than a teaching tool. I'm big on thorough, simple explanation, with plenty of examples. Maybe I'm just a bit thicker than your average Python hacker.&lt;br /&gt;&lt;br /&gt;Anyway, tonight I drew the line. Django does not fit the bill for my fly-by-night one-off projects. At this point, I feel I've spent almost as much time reading (and re-reading) Django documentation as I would have in implementing the whole thing in PHP with CodeIgniter from the beginning. And that includes referencing the docs. The last straw was when I figured out a quirk of Django's static file handling by trial and error.&lt;br /&gt;&lt;br /&gt;I spent about five hours trying to troubleshoot why the wrong CSS file was being loaded from a static files directory. I pored over docs. Googled here and there. Questioned my own sanity. A wild and almost random stab in the dark finally solved it, but the fact that it took &lt;i&gt;so damn long&lt;/i&gt; and that the unexpected caveat doesn't seem to be mentioned anywhere in the docs (or at least, anywhere I thought to look) spoke volumes to me. On top of this, I &lt;i&gt;just&lt;/i&gt; had a conversation with a good friend of mine a couple days ago about how highly I recommended CodeIgniter as a starting point for getting most any small- to mid-size app off the ground quickly.&lt;br /&gt;&lt;br /&gt;Maybe Django is great for web developers crafting large production sites and who have all the time in the world to read docs and figure out the minutia of their intricate framework. But I don't, so it looks like Django and I will be parting ways, at least for now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-6457594570632738635?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/6457594570632738635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=6457594570632738635' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6457594570632738635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6457594570632738635'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2011/12/web-frameworks-when-love-is-gone.html' title='Web Frameworks: When Love is Gone'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-4518198175690980054</id><published>2011-11-15T22:50:00.002-05:00</published><updated>2011-11-15T22:54:11.531-05:00</updated><title type='text'>Banned from the U.S.A.</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://projectnifty.com/sites/default/files/Pogo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://projectnifty.com/sites/default/files/Pogo.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.pogomix.net/"&gt;Pogo&lt;/a&gt; (Nick Bertke) is one of my favorite independent &lt;a href="http://www.youtube.com/user/Fagottron"&gt;electronic music&lt;/a&gt; artists. He's a young, extremely talented DJ who is travelling around the world to do tours and remix movies and culture. His fans alone foot the bill for travels. Here's one video he did while in Johannesburg, South Africa:&lt;br /&gt;&lt;br /&gt;&lt;iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/bs66ORnV5jU" width="560"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;I just found out that while attempting to travel to the U.S., Pogo was detained for not having all the proper paperwork. Rather than attempt to remedy their goof, &lt;a href="http://www.theagencygroup.com/agent.aspx?AgentID=299"&gt;his travel agency&lt;/a&gt; cut their ties to him and refused to speak to either him or U.S. customs on his behalf. Pogo sat in a New York jail for three weeks before finally being deported and being informed that he was &lt;a href="http://www.pogomix.net/banned-from-the-usa"&gt;barred from attempting to enter the country&lt;/a&gt; for 10 years.&lt;br /&gt;&lt;br /&gt;In light of this situation, I'd like to cordially extend my middle finger to the &lt;a href="http://www.cbp.gov/"&gt;United States Customs&lt;/a&gt; and Border protection and &lt;a href="http://www.dhs.gov/"&gt;Department of Homeland Security&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-4518198175690980054?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/4518198175690980054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=4518198175690980054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4518198175690980054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4518198175690980054'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2011/11/banned-from-usa.html' title='Banned from the U.S.A.'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/bs66ORnV5jU/default.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-4861390364408884045</id><published>2010-10-05T23:06:00.004-04:00</published><updated>2010-10-05T23:47:24.203-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PyCrypto'/><category scheme='http://www.blogger.com/atom/ns#' term='Cryptography'/><category scheme='http://www.blogger.com/atom/ns#' term='Encryption'/><category scheme='http://www.blogger.com/atom/ns#' term='AES'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Symmetric Encryption with PyCrypto, Part 2</title><content type='html'>This is the second part of my introductory series on cryptography in Python and it covers the AES block cipher with lots of actual code this time. Please read &lt;a href="http://bityard.blogspot.com/2010/01/symmetric-encryption-with-pycrypto-part.html"&gt;the first part&lt;/a&gt; if you're new to this stuff. I consider these articles to be works in progress so don't be surprised if you notice something change between visits. I appreciate feedback and suggestions!&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;AES Encryption&lt;/h2&gt;&lt;div class="level2"&gt;&lt;br /&gt;There are many encryption algorithms that can be used for secure  cryptography, but we'll settle on AES (the Advanced Encryption Standard)  in this tutorial. If you have your heart set on implementing something  else, fear not: everything you'll learn here applies to other  commonly-used symmetric block ciphers as well. The only real differences  will be their internal implementations, and the range of key and block  sizes that the ciphers accept.&lt;br /&gt;&lt;br /&gt;AES is an open encryption standard set forth by the U.S. government in  2002 and is based on a set of ciphers called Rijndael. Due to its  importance, transparency, and longevity, AES is widely used around the  world and has received much scrutiny within the cryptographic community.  If properly implemented, it is considered unbreakable by all currently known  techniques.&lt;br /&gt;&lt;br /&gt;All AES ciphers have a block size of 128 bits (16 bytes). A “block” is  the string of plaintext data that is fed into the cipher, along with the  key, for which a corresponding ciphertext block is returned. The three  AES ciphers are AES-128, AES-192, and AES-256. The numbers indicate the  key size that each cipher utilizes (16 bytes, 24 bytes, and 32 bytes  respectively). &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://img.bityard.net/blog/aes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://img.bityard.net/blog/aes.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;i&gt;Illustration 1: How AES Works&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt; &lt;br /&gt;The illustration above is a simplified example of how AES works. To  encrypt, the cipher takes two inputs: a key and plaintext. It uses the  key to encrypt the plaintext and yields the resulting ciphertext. (For  you purists out there, it should be noted that the ciphertext given in  this illustration is only an example. It was not actually generated by  AES. The ciphertext generated by AES is binary and cannot normally be  printed in a readable fashion directly.)&lt;br /&gt;&lt;br /&gt;As their name implies, block ciphers are designed to work on data in  terms of discrete blocks. The AES block size is 128 bits (16 bytes), so  programs which perform AES encryption feed plaintext (or ciphertext, for  decryption) to the cipher in 16-byte chunks. We illustrate this in the  above example by breaking the message and corresponding ciphertext into  seven 16-byte lines.&lt;br /&gt;&lt;br /&gt;You might have noticed that the last line in the plaintext is  technically too short. The last block of the message consists of only  two characters followed by what programmers call “padding” to fill out  the remaining length of a fixed-size string. Block ciphers depend on  their input being a specific known size; the algorithm won't work  otherwise. To satisfy the requirement that every block be exactly 16  bytes in AES, we use the uppercase letter 'X' in this example. In many  cases, this is sufficient. Anyone who decrypts this ciphertext and reads  the resulting message will probably realize that the long string of 'X'  isn't intended to be part of the message. But this doesn't necessarily  work all the time, since there may be legitimate cases where the final  character 'X' is an important part of the message. Fortunately, there is  a much better solution to dealing with padding that we will discuss in  the next article. &lt;/div&gt;&lt;h2&gt;A Practical Example&lt;/h2&gt;&lt;div class="level2"&gt;&lt;br /&gt;As with any decent cryptographic system, AES is sufficiently complex  that you wouldn't want to try whipping up your own implementation to use  for important data unless you have a few years of hardcore crypto  experience under your belt. (And probably not even then.) Fortunately,  we're using Python, which has a number of quality cryptographic modules  available. Since the standard C Python distribution doesn't come with  modules for symmetric block ciphers, we'll use the Python Cryptography  Toolkit, also known as PyCrypto.&lt;br /&gt;&lt;br /&gt;PyCrypto can be fetched and built from &lt;a class="urlextern" href="http://www.pycrypto.org/" title="http://www.pycrypto.org"&gt;pycrypto.org&lt;/a&gt;,  but many Linux distributions carry it in their software repositories as  well; look for and install the 'python-crypto' package on Debian,  Ubuntu, and Fedora. There is no official Windows or OS X binary distribution of PyCrypto, but &lt;a class="urlextern" href="http://dearauthor.com/wordpress/2010/02/21/how-to-install-python-and-pycrypto/" title="http://dearauthor.com/wordpress/2010/02/21/how-to-install-python-and-pycrypto/"&gt;this article&lt;/a&gt; describes how to install Python and PyCrypto on Windows and OS X.&lt;br /&gt;&lt;br /&gt;Once you have PyCrypto installed, we can start off with a simple example:&amp;nbsp; &lt;br /&gt;&lt;pre class="code python"&gt;&lt;span class="co1"&gt;# Example 1&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; Crypto.&lt;span class="me1"&gt;Cipher&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; AES&lt;br /&gt;&amp;nbsp;&lt;br /&gt;key = &lt;span class="st0"&gt;'mysecretpassword'&lt;/span&gt;&lt;br /&gt;plaintext = &lt;span class="st0"&gt;'Secret Message A'&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;encobj = AES.&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;key, AES.&lt;span class="me1"&gt;MODE_ECB&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="co1"&gt;# Resulting ciphertext in hex&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; ciphertext.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;) &lt;/span&gt;&lt;/pre&gt;&lt;i&gt;Example 1: Basic encryption&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt; &lt;br /&gt;This script creates a ciphering object using a key and a feedback mode  (ECB, which we'll discuss later). It then feeds the plaintext into that  object with the encrypt() method which returns a ciphertext string.  Since the resulting ciphertext is a binary string, we encode it in hex  before printing it to the screen. When the script is run, it prints:&amp;nbsp; &lt;br /&gt;&lt;pre class="code"&gt;e8da47acc08bc751745ef8fbff44e107&amp;nbsp;&lt;/pre&gt;Not very interesting, is it? That's exactly the point. You can change  the key and the plaintext (keeping in mind the key sizes and block size  of AES) and note how the ciphertext comes out entirely different every  time. You might have noticed that the length of hex-encoded ciphertext  is 32 characters. By encoding it in hex, we've doubled the size because  each binary character is represented by two hex characters, thus the  actual ciphertext is only 16 characters. This is–not coincidentally–the  block size of AES.&lt;br /&gt;&lt;br /&gt;Let's see how the reverse operation works:&lt;br /&gt;&lt;pre class="code python"&gt;&lt;span class="co1"&gt;# Example 2&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; Crypto.&lt;span class="me1"&gt;Cipher&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; AES&lt;br /&gt;&lt;span class="kw1"&gt;import&lt;/span&gt; &lt;span class="kw3"&gt;binascii&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;key = &lt;span class="st0"&gt;'mysecretpassword'&lt;/span&gt;&lt;br /&gt;ciphertext = &lt;span class="kw3"&gt;binascii&lt;/span&gt;.&lt;span class="me1"&gt;unhexlify&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'e8da47acc08bc751745ef8fbff44e107'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;decobj = AES.&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;key, AES.&lt;span class="me1"&gt;MODE_ECB&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;plaintext = decobj.&lt;span class="me1"&gt;decrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;ciphertext&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="co1"&gt;# Resulting plaintext&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; plaintext&lt;/pre&gt;&lt;i&gt;Example 2: Simple decryption&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt; &lt;br /&gt;This script performs decryption on the ciphertext that was generated  from the script in Example 1. The binascii module is used only to  convert the hex representation of our ciphertext back into binary before  it is fed into the decrypt() method of the ciphering object. &lt;/div&gt;&lt;h2&gt;A Weakness Uncovered&lt;/h2&gt;&lt;div class="level2"&gt;&lt;br /&gt;Symmetric block ciphers, powerful though they are, have an inherent weakness. &lt;br /&gt;When you encrypt a block of data, you typically do so with the  expectation that eventually you'd like to retrieve that data again.  Thus, the algorithm has to be deterministic. That is, for a given key  and plaintext, a specific ciphertext will be generated each time. Which  poses a problem: suppose you have blocks within the plaintext that are  identical. This isn't terribly hard to imagine. A spreadsheet often has  multiple cells containing the same data. An image almost always has  multiple pixels of the same color value. If you encrypt files like these  with a block cipher and do nothing else, an attacker could see a  pattern in the ciphertext and use it to gain crucial insight into the  nature of the plaintext. Take these two images for example: &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;a href="http://img.bityard.net/blog/tuxecb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://img.bityard.net/blog/tuxecb.png" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;i&gt;Illustration 2: Patterns in ciphertext&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt; &lt;br /&gt;The plaintext image on the left is Tux, the Linux mascot. The  image on the right is not actually an encrypted file, but is the result  of running each pixel color value through a block cipher (with a key  unknown to us). The image is then recreated with the encrypted color  values. The image is technically encrypted with a strong cipher, but  patterns in the plaintext data result in easily-discernible patterns in  the ciphertext. This is a violation of the principle of non-uniformity  we talked about in Section 1. Encrypting the data did little to hide the  essence of the original file. &lt;br /&gt;Here's a demonstration in code: &lt;br /&gt;&lt;pre class="code python"&gt;&lt;span class="co1"&gt;# Example 3&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; Crypto.&lt;span class="me1"&gt;Cipher&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; AES&lt;br /&gt;&amp;nbsp;&lt;br /&gt;key = &lt;span class="st0"&gt;'mysecretpassword'&lt;/span&gt;&lt;br /&gt;plaintext1 = &lt;span class="st0"&gt;'Secret Message A'&lt;/span&gt;&lt;br /&gt;plaintext2 = &lt;span class="st0"&gt;'Secret Message B'&lt;/span&gt;&lt;br /&gt;plaintext3 = &lt;span class="st0"&gt;'Secret Message C'&lt;/span&gt;&lt;br /&gt;plaintext4 = &lt;span class="st0"&gt;'Secret Message A'&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;encobj = AES.&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;key, AES.&lt;span class="me1"&gt;MODE_ECB&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext1 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext1&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext2 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext2&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext3 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext3&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext4 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext4&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="co1"&gt;# Resulting ciphertext in hex&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; ciphertext1.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; ciphertext2.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; ciphertext3.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; ciphertext4.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;i&gt;Example 3: Demonstrating the ECB mode of operation&lt;/i&gt; &lt;br /&gt;This prints: &lt;br /&gt;&lt;pre class="code"&gt;e8da47acc08bc751745ef8fbff44e107&lt;br /&gt;49b1f4635c9a53c4f7538ba3b4452b32&lt;br /&gt;0d750ffff1ab846b838a6a304860372e&lt;br /&gt;e8da47acc08bc751745ef8fbff44e107&lt;br /&gt;&lt;/pre&gt;You can see that the ciphertext for plaintext1 and plaintext4 are  identical. In real-world applications, ciphers are usually paired with a  method to eliminate these redundancies in the resulting ciphertext.  These methods are called &lt;b&gt;modes of operation&lt;/b&gt;. In all of the examples so far, we used the Electronic Code Book (ECB) mode when creating the AES cipher object: &lt;br /&gt;&lt;pre class="code"&gt;encobj = AES.new(key, AES.MODE_ECB)&lt;/pre&gt;ECB is just the cryptographers' formal way of saying, “nothing has been  done to eliminate obvious patterns in the ciphertext.” PyCrypto supports another mode of operation, Cipher Block Chaining (CBC). To eliminate redundancies in the resulting ciphertext, CBC incorporates  the ciphertext of the previous block with that of the next so that the  entire volume of ciphertext appears to be pseudo-random. When encrypting  the first block, a random value called the initialization vector (IV) is XORed with the plaintext. The result is encrypted with the provided key.  Before the second block is encrypted, its plaintext is XORed with the  ciphertext of the previous block. And so it goes until all of the blocks  in the file or message have been encrypted in this manner. Here's an  illustration (the circled plus sign indicates the XOR operation):&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://upload.wikimedia.org/wikipedia/commons/d/d3/Cbc_encryption.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://upload.wikimedia.org/wikipedia/commons/d/d3/Cbc_encryption.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;i&gt;Illustration 3: Cipher Block Chaining&lt;/i&gt;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;To use CBC in PyCrypto, all we have to do is supply an IV and change the mode: &lt;br /&gt;&lt;pre class="code python"&gt;&lt;span class="co1"&gt;# Example 4&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; Crypto.&lt;span class="me1"&gt;Cipher&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; AES&lt;br /&gt;&lt;span class="kw1"&gt;import&lt;/span&gt; &lt;span class="kw3"&gt;os&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;key = &lt;span class="st0"&gt;'mysecretpassword'&lt;/span&gt;&lt;br /&gt;iv = &lt;span class="kw3"&gt;os&lt;/span&gt;.&lt;span class="me1"&gt;urandom&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;16&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="co1"&gt;# Output the initialization vector&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'IV: '&lt;/span&gt; + iv.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;plaintext1 = &lt;span class="st0"&gt;'Secret Message A'&lt;/span&gt;&lt;br /&gt;plaintext2 = &lt;span class="st0"&gt;'Secret Message B'&lt;/span&gt;&lt;br /&gt;plaintext3 = &lt;span class="st0"&gt;'Secret Message C'&lt;/span&gt;&lt;br /&gt;plaintext4 = &lt;span class="st0"&gt;'Secret Message A'&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;encobj = AES.&lt;span class="kw3"&gt;new&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;key, AES.&lt;span class="me1"&gt;MODE_CBC&lt;/span&gt;, iv&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext1 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext1&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext2 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext2&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext3 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext3&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;ciphertext4 = encobj.&lt;span class="me1"&gt;encrypt&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;plaintext4&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="co1"&gt;# Resulting ciphertext in hex&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'A:  '&lt;/span&gt; + ciphertext1.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'B:  '&lt;/span&gt; + ciphertext2.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'C:  '&lt;/span&gt; + ciphertext3.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'A:  '&lt;/span&gt; + ciphertext4.&lt;span class="me1"&gt;encode&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;'hex'&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;i&gt;Example 4: Demonstrating the CBC mode of operation&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt; &lt;br /&gt;If we run this example, we get something like: &lt;br /&gt;&lt;pre class="code"&gt;IV: 1c531872a9b7a71bfc060b22c459136b&lt;br /&gt;A:  ed7a68aa4a7c316047b6c6493b2d03d9&lt;br /&gt;B:  5177729609a9bbd0500f8ea2614c7906&lt;br /&gt;C:  46b19bace80917f655846aa697f201fb&lt;br /&gt;A:  0e298e3b3072e8c595637d2e5feb16ec&lt;br /&gt;&lt;/pre&gt;The first thing to note here is that the ciphertext for message A no  longer repeats. This is good! This keeps repeating plaintext blocks from  forming patterns in the ciphertext. In fact, on every invocation of the  script, all the ciphertext blocks change completely because a different  IV is generated at random each time, even though the key and plaintext  messages stay exactly the same.&lt;br /&gt;&lt;br /&gt;You may have also noticed that we now have 5 blocks of ciphertext for 4  blocks of plaintext. The reason is simple: we added an extra block to  the output by including an IV. The IV is generated at random and passed  into the ciphering object. The IV has to be known at the time of  decryption in order to produce the expected plaintext, so it is often  prepended to the ciphertext. Knowledge of the IV itself cannot help an  attacker break the encryption, so including it as generated poses no  risk.&lt;br /&gt;&lt;br /&gt;If you've understood everything presented so far, you should have a good  idea as to what a decryption script for the above data looks like. If  you're in the mood to do some homework, now is a great time to write  one.&lt;br /&gt;&lt;br /&gt;Stay tuned for Part 3 where we'll be discussing keys and key strengthening techniques!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;i&gt;The image of Tux in Illustration 2 is copyrighted by Larry Ewing and was created with The GIMP.&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-4861390364408884045?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/4861390364408884045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=4861390364408884045' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4861390364408884045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4861390364408884045'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2010/10/symmetric-encryption-with-pycrypto-part.html' title='Symmetric Encryption with PyCrypto, Part 2'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-5245043054465584445</id><published>2010-02-02T22:07:00.007-05:00</published><updated>2010-03-04T23:58:39.841-05:00</updated><title type='text'>Playing with localStorage</title><content type='html'>This seems to be something of a well-kept secret. It appears that almost all newer web browsers support various types of client storage without the use of cookies. The &lt;a href="http://dev.w3.org/html5/webstorage/"&gt;web storage specification&lt;/a&gt; (part of HTML5) describes new facilities that web authors can use to store arbitrary data on the client using a simple key/value store. &lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The best part: instead of being limited to 4K of data total as with cookies, each website can store megabytes of data on the client. (Implementations vary, but the draft specification recommends somewhere in the area of 5MB per origin.) This ultimately means that we'll start seeing a lot of web applications (E.g., Google Docs) storing data locally for offline access. The specification describes (so far) session storage and local storage.&lt;br /&gt;&lt;br /&gt;Two other kinds of local storage were once proposed, but eventually dropped: global storage and database storage. Global storage is like session and local storage, except that the website could scope data along the domain name heirarchy. (See &lt;a href="https://developer.mozilla.org/en/DOM/Storage#globalStorage"&gt;Mozilla's explanation&lt;/a&gt; for details.) Database storage is essentially an SQL engine inside the browser. The only browsers that support it are those based on recent versions of WebKit, namely Chrome and Safari.&lt;br /&gt;&lt;br /&gt;Back to local storage, however. These are the browsers that I successfully tested with support for local storage:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Chrome 4.0.302.2&lt;/li&gt;&lt;li&gt;Firefox 3.5, 3.6&lt;/li&gt;&lt;li&gt;Safari for iPhone/iPod Touch 3.1.2&lt;/li&gt;&lt;li&gt;Internet Explorer 8&lt;/li&gt;&lt;/ul&gt;While these browsers are not the majority of the ones currently in use, they or their descendants will be soon. Users are finally starting to realize that it's in their best interest to stay reasonably up to date on their software and some &lt;a href="http://www.google.com/"&gt;large web properties&lt;/a&gt; are beginning to drop support entirely for crusty old ancient browsers (&lt;a href="http://en.wikipedia.org/wiki/Internet_Explorer_6"&gt;ahem&lt;/a&gt;). It's safe to say that local storage will be a big part of future web apps.&lt;br /&gt;&lt;br /&gt;So, here's how it works. Items are stored as simple key/value pairs. Programmers know this as a &lt;a href="http://en.wikipedia.org/wiki/Hash_table"&gt;hash table&lt;/a&gt;. The object in Javascript to manipulate the storage is called, unsurprisingly, &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;localStorage&lt;/span&gt;. This object has the following methods: &lt;br /&gt;&lt;ul&gt;&lt;li&gt;getItem(&lt;i&gt;key&lt;/i&gt;) - retrieve a value via the key&lt;/li&gt;&lt;li&gt;setItem(&lt;i&gt;key&lt;/i&gt;, &lt;i&gt;value&lt;/i&gt;) - add or change a key/value pair&lt;/li&gt;&lt;li&gt;removeItem(&lt;i&gt;key&lt;/i&gt;) - remove an item from storage&lt;/li&gt;&lt;li&gt;key(&lt;i&gt;index&lt;/i&gt;) - retrieve the key via its index&lt;/li&gt;&lt;li&gt; clear() - empty the local storage&lt;/li&gt;&lt;/ul&gt;And one property:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; length - the number of items in local storage&lt;/li&gt;&lt;/ul&gt;The above should be mostly self-explanatory. You can get the key for a specific item by specifying its index number but note that since this is a hash table, the index-to-key mappings are not static. You can never presume that a particular index belongs to a certain key. The key() method is primarily meant to be used with the length property so that you can iterate over each item in storage.&lt;br /&gt;&lt;br /&gt;Pretty simple, eh? This tiny feature adds a load of capability and, together with the rest of HTML5, will finally start to turn the web browser into a proper applications platform, even if it never will be a particularly efficient one.&lt;br /&gt;&lt;br /&gt;A quick note on privacy and security: each fully-qualified domain name that you visit has its own storage. For example, yahoo.com and google.com can never share storage. And as far as I understand, the policy is the same for subdomains as well, so mail.google.com and code.google.com can't access each others' storage either.&lt;br /&gt;&lt;br /&gt;I put together a demo that lets you directly &lt;a href="http://img.bityard.net/blog/lstest.html"&gt;play around with &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;localStorage&lt;/span&gt; in your browser&lt;/a&gt;. Take a peek at the source code, save it, steal it, whatever. Everything except the jQuery library is contained within the one HTML file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-5245043054465584445?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/5245043054465584445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=5245043054465584445' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/5245043054465584445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/5245043054465584445'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2010/02/playing-with-localstorage.html' title='Playing with localStorage'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-6176848301674054398</id><published>2010-01-28T17:31:00.003-05:00</published><updated>2010-01-31T00:24:01.344-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux dd backup gzip compression'/><title type='text'>HOWTO: Backup an Entire Hard Disk to a Smaller One</title><content type='html'>In my book, one of the best ways to back up an entire disk is to simply dump an image of it to external media. For instance, let's say you have an OS installed on your workstation and you want to try a new Linux distribution. You could repartition the drive, mess with the bootloader, and install the new OS next to the old one. Then, if you don't like it, nuke the new partition, resize the old one, and fix up the MBR to point back to the old OS. This is certainly a common scenario, but it carries with it the substantial possibility that something will go wrong. You could lose your main OS and have to start over from scratch. Or you might end up spending hours trying to recover your old OS that you didn't properly back up before starting the procedure. Because hey, you're a Linux superstar by now, who needs backups anyway?&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It's much simpler to just boot from a live CD and copy the entire disk image (partition table and all) to a file on external media with dd(1). When done with your experimentations, simply copy it back. This way you don't have to muck about with partitions, permissions, metadata, bootloaders, or anything. It takes a bit of time, but it is exceedingly simple and much less risky than other backup and restore methods. Here's an example. Assume that /dev/sda is the main disk in the machine that you're backing up and /dev/sdb1 is a partition on external storage.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;mkdir /mnt/sdb1&lt;br /&gt;mount /dev/sdb1 /mnt/sdb1&lt;br /&gt;dd if=/dev/sda of=/mnt/sdb1/sda.img&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This works great, but one obvious drawback is that the free space on sdb1 must be greater than (or by freakish coincidence, exactly equal to) the total size of /dev/sda. Unless, perhaps, we compress it. Then the minimum free space requirement on /dev/sdb1 becomes much lower. In effect, required space is equal to the amount of actual data on /dev/sda after it's been compressed. For example, if /dev/sda is 80GB in size, but the df(1) command reports that only about 10GB of it is in use, it's fair to guess that a compressed image of the disk should end up somewhere under 10GB in size.&lt;br /&gt;&lt;br /&gt;So, there's no theoretical reason this couldn't work. But we have to recognize that the free space must compress well in order to get this kind of efficiency. Except in very specific circumstances, the "free" space on a hard disk is not actually empty. When you delete a file, the data is still there; the OS simply removes the &lt;i&gt;references&lt;/i&gt; to the file. This data will be included in a dumped image of the disk and it may or may not compress well.&lt;br /&gt;&lt;br /&gt;The solution is to fill up the free space with zeros. When it comes down to it, there's nothing that compresses better than a whole lot of nothing. For best results, this should be done on all file systems in addition to the swap partition.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Backup Procedure&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Mount the main disk and fill up the remaining free space on all partitions with a file containing all zeros. (/dev/sda1 is the only data partition in this example.)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;mkdir /mnt/sda1&lt;br /&gt;mount /dev/sda1 /mnt/sda1&lt;br /&gt;dd if=/dev/zero of=/mnt/sda1/zero&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Wait until you get the error "No space left on device", then remove the zero file on each partition.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;rm /mnt/sda1/zero&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Umount the partition.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;umount /mnt/sda1&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Zero the swap partition. (Shown as /dev/sda5 here.)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;dd if=/dev/zero of=/dev/sda5&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Reinitialize the swap partition. (Otherwise it won't be detected and enabled on boot after restore.)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;mkswap /dev/sda5&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Mount the backup partition.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;mkdir /mnt/sdb1&lt;br /&gt;mount /dev/sdb1 /mnt/sdb1&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Copy the entire disk to an image file on the backup drive (/dev/sdb1), piping it through gzip for compression.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;dd if=/dev/sda | gzip - &amp;gt; /mnt/sdb1/backup-sda.gz&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Umount the backup device, reboot, and you're free to do whatever you like to your main disk, knowing that you have a good backup on hand.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Restore Procedure&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Restoring is even easier than backing up. Once you're up and running on the live CD:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;mkdir /mnt/sdb1&lt;br /&gt;mount /dev/sdb1 /mnt/sdb1&lt;br /&gt;gunzip -c /mnt/sdb1/backup-sda.gz | dd of=/dev/sda&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Unmount the backup drive, reboot, and you should have your original OS back just as it was before the backup.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-6176848301674054398?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/6176848301674054398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=6176848301674054398' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6176848301674054398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6176848301674054398'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2010/01/howto-backup-entire-hard-disk-to.html' title='HOWTO: Backup an Entire Hard Disk to a Smaller One'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-1266558541275666382</id><published>2010-01-24T01:53:00.007-05:00</published><updated>2010-10-05T23:58:10.695-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PyCrypto'/><category scheme='http://www.blogger.com/atom/ns#' term='Cryptography'/><category scheme='http://www.blogger.com/atom/ns#' term='Encryption'/><category scheme='http://www.blogger.com/atom/ns#' term='AES'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Symmetric Encryption with PyCrypto, Part I</title><content type='html'>This is a multi-part series on the basics of implementing symmetric cryptography in Python with &lt;a href="http://www.dlitz.net/software/pycrypto/"&gt;PyCrypto&lt;/a&gt;. By the end of the series, we'll have a program that takes a password plus a file and outputs the encrypted version of the file. (And of course, the reverse.) This first part is mainly intended for the novice. Those already well-versed in encryption or don't care for a refresher should consider &lt;a href="http://bityard.blogspot.com/2010/10/symmetric-encryption-with-pycrypto-part.html"&gt;skipping to Part 2&lt;/a&gt;. Also, I'll attempt to explain concepts as best I can, but you'll want to have a decent grasp of Python in order to make full use of the tutorial.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Before we dive right in, a disclaimer:&amp;nbsp;I am writing these articles in the hope that they will be educational and useful to others like myself and to solidify the concepts in my own mind. Crypto is hard to do right.  Please don't use these articles as a replacement for a professional security consultant.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The Goal&lt;/h2&gt;&lt;br /&gt;We are going to write a Python program that will take an unencrypted file, prompt for a password, and spit out an encrypted version of the file. It will, of course, also be quite capable of the reverse: read an encrypted file, prompt for a password, and give you the unencrypted file back. This is called &lt;b&gt;symmetric encryption&lt;/b&gt; because one key allows you to perform both the encryption and the decryption operations. &lt;br /&gt;&lt;br /&gt;Before we can talk semi-intelligently about crypto, we need to know a few basic definitions. More than almost any other technical field, crypto is rife with metaphors. The jargon, therefore, is generally pretty easy to comprehend.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;key&lt;/b&gt;: The piece of information that allows you to either encrypt or decrypt your data. Although it's tempting to think of a crypto key as being similar to a physical key, a slightly better real-world analogy is that of the combination to a combination lock. A combination is a random-looking series of numbers which can be memorized, transferred, and transformed easily, rather like an encryption key.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;plaintext&lt;/b&gt;: The information that you want to keep hidden, in its unencrypted form. The information does not actually have to be text, it's just the term that cryptographers use. The plaintext can be any data at all: a picture, a spreadsheet, or even a whole hard disk. The synonym "message" is sometimes used as well, especially when dealing with situations where encrypted data is being passed from one party or computer to another.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ciphertext&lt;/b&gt;: The information in encrypted form. If the encryption software is written correctly and all of the proper procedures are followed, the ciphertext is completely unreadable and unbreakable without the key. Although it's generally considered good security practice to reasonably protect your ciphertext from third parties, the theory goes that you could print it in a national newspaper if you wanted to and nobody would be able to decode it to plaintext without knowing the correct key.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;cipher&lt;/b&gt;: The algorithm that converts plaintext to ciphertext and vice-versa. We won't go into any details about how the internals of cipher algorithms work, as it would be a very technical subject well beyond the scope of this introduction. Fortunately, ciphers tend to be simple enough to use that a high-level overview of the basic concepts is sufficient to make full use of them. An analogy might be that you don't have to know how a compression algorithm works in order to "zip" a file.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;A First Example&lt;/h2&gt;&lt;br /&gt;To visualize how these parts work together, consider this example code for an encryption operation:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;plaintext = 'I say, mater, cabbage crates coming over the briny.'&lt;br /&gt;key = 'ocelot'&lt;br /&gt;ciphertext = encrypt(plaintext, key)&lt;br /&gt;# The variable 'ciphertext' now contains the string: &lt;br /&gt;# 'Qng5tnrf97OG4pHooBCT96aSykSsdAiHb92RPXQPVDfdAKapuX4'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And the reverse operation, decryption:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ciphertext = 'Qng5tnrf97OG4pHooBCT96aSykSsdAiHb92RPXQPVDfdAKapuX4'&lt;br /&gt;key = 'ocelot'&lt;br /&gt;plaintext = decrypt(ciphertext, key)&lt;br /&gt;# The variable 'plaintext' now contains the string:&lt;br /&gt;# 'I say, mater, cabbage crates coming over the briny.'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note that the key is the same in both operations. That's what makes this symmetric encryption. If we were to leave the first listing alone but change the key to "caribou" in the second listing, the decrypt() function would return either gibberish or nothing at all, depending on the implementation.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Doing Encryption Right&lt;/h2&gt;&lt;br /&gt;In order to stand up against a focused attack, the encryption system as a whole must be well designed and well implemented. There are certain properties of each part of the encryption system that--when put together--make it secure. We'll briefly mention some of these properties here.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Full Disclosure&lt;/h3&gt;&lt;br /&gt;The complete workings of a cryptographic system should be open, public, and available for analysis by expert cryptographers. Many ciphers have been invented, and many have been subverted due to various design flaws. A cipher is deemed secure by experts only after it has withstood sufficient scrutiny from the public and experts in the field of cryptography. A programmer implementing an encryption system should never rely on some hidden feature or obfuscation for the security of the system. Even if the system is never intended to be released publicly, it should be designed as if it will be. The only component that should ever be treated as truly secret is the user's encryption key itself.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Non-Uniformity&lt;/h3&gt;&lt;br /&gt;The ciphertext produced by a cipher should be completely indistinguishable from random data. If the ciphertext had any observable pattern at all, an adversary could theoretically use that information to make a guess about the nature of the plaintext or use whatever is known about the pattern to more easily crack the cipher. The reverse is not necessarily true, however: random-looking cipher output is not by itself any indication of a secure cipher.&lt;br /&gt;&lt;br /&gt;Another closely-related principle is a small change in the either the plaintext or the key should cause a dramatic change in the ciphertext as whole. If either input is off by a even single bit, the ciphertext should come out completely different.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Key Strength&lt;/h3&gt;&lt;br /&gt;The key should be as secure as possible. In many implementations, users will choose a password which is then converted into a key. The problem with passwords is that they can be easy to guess. If an adversary wants access to your encrypted data and you have an easily guessable key, they don't need millions of computers brute forcing the password for millions of years, they can just try a few hundred thousand obvious keys until they find the one that unlocks your data. Using a weak password nullifies any benefit obtained from using encryption. In fact, it can make things worse on the whole, because it could lull you into a false sense of security.&lt;br /&gt;&lt;br /&gt;Key-strengthening techniques have been devised to counter these types of brute-force attacks. They are no replacement for a strong password, but they make it harder to pre-compute the keys from a password list. We'll discuss these techniques later.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Key Length&lt;/h3&gt;&lt;br /&gt;An encryption key has to be large enough so that simply trying every possible combination of bits would be an insurmountable task. Imagine, again, the key as the combination to a lock on a safe. The fewer numbers in the combination, the easier it is to find the right one to open the safe simply by incrementing the combination for each try. In cryptography, a small key can be easily found with the same method. For example, an attacker trying to find an 8-bit key (one byte) only has try to all 256 (2^8) possible different combinations.&lt;br /&gt;&lt;br /&gt;For each bit that is added to the key, the number of combinations to try is doubled. So, a 9-bit key takes 512 guesses, a 10-bit key, 1024 guesses, and so on. The standard in symmetric cryptography is 128 bits. If you enter 2 to the power of 128 into a calculator, you'll see an extremely large number as the result. Experts have theorized that trying to sequentially search for a key of this size would take more than 10 trillion years to exhaust the key space. So if an attacker were able to set up a device to brute-force a 128-bit key at the moment the universe was created, they will have had only about a 1 in 1000 chance of finding it by now. (&lt;a href="http://en.wikipedia.org/wiki/Brute_force_attack"&gt;Source&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;Barring any unforeseen fantastic breakthroughs in mathematics or physics, 128 bits is more than plenty for a good long time. Many ciphers support key sizes of up to 256 bits to make them stronger against unforeseen attacks. The extra 128 bits provide an enormous margin of safety in case weaknesses are later discovered in the ciphers or (more likely) their implementations.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Cipher Strength&lt;/h3&gt;&lt;br /&gt;These days, modern encryption ciphers tend to be very well engineered. They are invented by people with a firm grasp of the mathematical theories behind cryptography and they tend to be peer-reviewed, openly discussed, and publicly available. Researchers are constantly on the lookout for ways to break popular ciphers or at least compute them with far less effort than it would take to brute-force them with ordinary means. Those that withstand such scrutiny over time become trusted.&lt;br /&gt;&lt;br /&gt;History is littered with ciphers that were once thought to be secure but have since been proven to have serious flaws. Some symmetric ciphers that are considered secure (as far as we know) are AES (a.k.a. Rijndael), Blowfish, Serpent, and Twofish.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Stay Tuned&lt;/h2&gt;&lt;br /&gt;&lt;a href="http://bityard.blogspot.com/2010/10/symmetric-encryption-with-pycrypto-part.html"&gt;In Part 2&lt;/a&gt;, we cover AES, write some code to test PyCrypto functionality, and discuss modes of operation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-1266558541275666382?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/1266558541275666382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=1266558541275666382' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1266558541275666382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1266558541275666382'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2010/01/symmetric-encryption-with-pycrypto-part.html' title='Symmetric Encryption with PyCrypto, Part I'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-5170365784248596113</id><published>2009-10-25T21:18:00.004-04:00</published><updated>2009-10-25T22:20:14.632-04:00</updated><title type='text'>The State of Solid State</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img.bityard.net/blog/disk.jpg"&gt;&lt;img style="cursor: pointer; width: 500px; height: 431px;" src="http://img.bityard.net/blog/disk.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, &lt;a href="http://www.physorg.com/news175505861.html"&gt;this guy does some speculative research&lt;/a&gt; and comes to the conclusion that mechanical hard disks will still be the dominant secondary storage technology for computers in 2020. Somehow, I'm a bit skeptical.&lt;br /&gt;&lt;p&gt;If you want to see what's going to happen in regard to mechanical vs solid state hard disks, you don't need a crystal ball. Just look at the transition from CRT to LCD displays. It wasn't so long ago that LCD monitors were horribly expensive and that fact (combined with their other drawbacks) made them an unattractive option for most people. I can recall many, &lt;i&gt;many&lt;/i&gt; people saying that they would &lt;i&gt;never&lt;/i&gt; give up their enormous, power-hungry, failure-prone CRT displays. Now, you can't even buy a CRT computer monitor because LCD quality caught up and surpassed CRTs for most purposes while price plummeted. The same will happen with mechanical disks and SSDs. Maybe it'll happen faster, maybe slower, but it will happen.&lt;/p&gt;&lt;p&gt;Keep in mind also which company this "prediction" is coming from: Seagate lived a long and prosperous career engineering and manufacturing mechanical hard disks. They are a huge company whose entire operation is based around the concept of shipping hunks of metal with rotating platters inside. Since an SSD is just a bunch of memory chips duct-taped together, the memory companies (Transcend, Crucial, Corsair, Samsung, etc) were the first ones with SSDs on the market. The SSD thing likely hit Seagate by surprise and they can see that their run won't last long.&lt;/p&gt;&lt;p&gt;It's not too late for them to start transitioning to manufacturing memory chips, but doing so would be brutal for many reasons. To start with, their decades of mechanical drive development experience, manufacturing facilities, engineers, trade secrets, R&amp;amp;D, etc are mostly about to be worthless. If they start selling this stuff off now while it's still fairly valuable, shareholders are going to do a huge "WTF?" and walk off. Second, the memory companies have a few years head start. Even if Seagate could enter the market and compete with them, the company would be leaving their position as a market leader to be a market newcomer, taking cues from everyone else. (Cue the sound of their last few shareholders stomping out.)&lt;/p&gt;&lt;p&gt;Basically, unless Seagate can buy up a few of the leading memory companies making SSDs right now, they're screwed. Until that happens, all they &lt;i&gt;can&lt;/i&gt; do right now is appease their shareholders and put their executives up on stage to have them parrot the lie that their business is going to be viable for a good long time yet. Oh, and &lt;a href="http://www.infoworld.com/d/security-central/seagate-lawsuit-against-stec-could-raise-ssd-prices-375"&gt;frivolously sue&lt;/a&gt; all the SSD manufacturers on &lt;a href="http://searchstorage.techtarget.com/news/article/0,289142,sid5_gci1309855,00.html"&gt;broad patent infringement grounds&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/2836700939935266529-5170365784248596113?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/5170365784248596113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=5170365784248596113' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/5170365784248596113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/5170365784248596113'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/10/blog-post.html' title='The State of Solid State'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-5031261201170104388</id><published>2009-10-12T21:49:00.002-04:00</published><updated>2009-10-12T21:51:24.724-04:00</updated><title type='text'>Sonic 3 Ice Cap Zone Act 1 on Korg EMX-1</title><content type='html'>&lt;p&gt;For fans of a particular blue hedgehog.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/OSueK3fYYkc&amp;amp;hl=en&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/OSueK3fYYkc&amp;amp;hl=en&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-5031261201170104388?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/5031261201170104388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=5031261201170104388' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/5031261201170104388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/5031261201170104388'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/10/sonic-3-ice-cap-zone-act-1-on-korg-emx.html' title='Sonic 3 Ice Cap Zone Act 1 on Korg EMX-1'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-4449951487892489199</id><published>2009-08-12T01:57:00.006-04:00</published><updated>2010-02-27T01:09:28.736-05:00</updated><title type='text'>x0xb0x #3</title><content type='html'>Just finished up x0xb0x #3. All of the basic functionality seems to work and it sounds just like a 303. Well, better than a 303 in my book but I guess I'm probably biased.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x3-a.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/x0x3-a_500.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;They gray knobs were special-ordered from Korg Europe. They were made for the Electribe ESX-1 and EMX-1 but they happen to be &lt;em&gt;perfect&lt;/em&gt; for the x0xb0x. I could have ordered the large switch knobs too, but I would have had to hack the encoder shafts even more than I already did.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x3-b.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/x0x3-b_500.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The top panel is a standard &lt;a href="http://adafruit.com/"&gt;Adafruit&lt;/a&gt; x0xb0x clear acrylic panel. To make it awesome, I just sprayed the underside with black paint. I wanted to use vinyl instead, but the paint turned out to be &lt;em&gt;so&lt;/em&gt; much easier. Looks great, the only downside is that the panel came with some scratches from the store. Oh, and it's a friggen fingerprint magnet. Next time, I may take a drill bit and scrape out the LED holes a bit so that they light up the laser-engraved letters on the panel.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x3-c.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/x0x3-c_500.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I used a clear I/O panel this time, so the innards can be seen without taking the x0x apart. I think I'll go back to metal unless I can devise an easy way to get an LED or two in there for show. All I have left to do on this one is tune it, perform a full function check, and hack in a power switch and then it's eBay time!&lt;br /&gt;&lt;br /&gt;I posted the innards of this x0x in a previous post &lt;a href="http://bityard.blogspot.com/2009/08/x0x-3-almost-ready.html"&gt;here&lt;/a&gt; and did a writeup on x0xb0x #2 &lt;a href="http://bityard.blogspot.com/2009/03/x0x-2.html"&gt;here&lt;/a&gt;. I hope to put together a video of me rocking the x0x sometime this week or next.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-4449951487892489199?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/4449951487892489199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=4449951487892489199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4449951487892489199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4449951487892489199'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/08/x0xb0x-3.html' title='x0xb0x #3'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-38390594074037532</id><published>2009-08-11T01:22:00.004-04:00</published><updated>2010-02-27T01:07:31.999-05:00</updated><title type='text'>x0x #3 Almost ready!</title><content type='html'>I'm almost done with x0xb0x #3.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x3-1.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/x0x3-1_500.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This one is being quite the problem child, actually. Two note LEDs flat-out didn't work, so those had to be replaced. The TEMPO LED had to be replaced because I scratched it to hell and back. The TEMPO encoder was replaced because the first one didn't work. (Talk about a wild goose chase there.) The USB chip wasn't talking to the microcontroller, which was fixed by cleaning up and reflowing the teeny-tiny SMD pins of the FT232 chip. The MIDI-in port still isn't working as I write this, despite the fact that I've already swapped the resistor that I assumed was causing the trouble.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x3-2.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/x0x3-2_500.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;On the upshot, I did a nifty thing with the control panel faceplate, so this one should look fully bad-arsed once it's all working and put together. Pics will be forthcoming for sure. I was hoping to have the unit done and sold in time to buy myself an EMX-1 for my birthday, but it doesn't look like that's going to happen at this point.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x3-3.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/x0x3-3_500.JPG" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-38390594074037532?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/38390594074037532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=38390594074037532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/38390594074037532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/38390594074037532'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/08/x0x-3-almost-ready.html' title='x0x #3 Almost ready!'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-6401810251425434290</id><published>2009-05-28T22:06:00.005-04:00</published><updated>2009-05-28T22:29:50.985-04:00</updated><title type='text'>On not coming in last</title><content type='html'>Not content with making it as difficult as humanly possible for a person to enter back into his or her own country, now the U.S. Customs and Border Patrol want to &lt;a href="http://www.itnews.com.au/News/104310,homeland-security-to-scan-fingerprints-of-travellers-exiting-the-us.aspx"&gt;scan and store the fingerprint profile&lt;/a&gt; of every person exiting the border, even U.S. citizens.  &lt;br /&gt;&lt;br /&gt;And incredibly, they can't even state why this would be a good security measure:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Michael Hardin, a senior policy analyst with the US-Visit Program at the United States Department of Homeland Security told a Biometrics Institute conference today that the DHS will use the data from the trial to "inform us as to where to take [exit screening] next."&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Seriously. He actually said that the only reason they're implementing it to begin with is because they want to see how much they can get away with. If I didn't know any better, I'd say that they only seem to be interested in keeping tabs on citizens' whereabouts...&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;"We are trying to ensure we know more about who came and who left," he said.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;C'mon, Michael! You're not even trying!&lt;br /&gt;&lt;br /&gt;You know, there were other countries that pulled stunts like this. Ones that ended up having such a tight grip on their borders and citizens that travel and free movement was effectively impossible. Countries that, if I am not mistaken, we either went to war with or fought against in other ways because we did not want to see the world becoming that kind of place. We did not want America to be the last bastion of freedom. I guess it proves that you have to be careful what you wish for. An anonymous poster on Slashdot said this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;You know, I'm a Canadian, and ten years ago, I would have voted to join the US. I felt that Americans recognised the value of their freedoms and that they had, and would fight to keep, a more free society than just about anywhere else on Earth. Today, I won't even travel there. It reminds me of all those B movies just after WW2 "Achtung! Show me your papers". How could y'all have just let this happen?&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-6401810251425434290?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/6401810251425434290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=6401810251425434290' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6401810251425434290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6401810251425434290'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/05/not-content-with-making-it-as-difficult.html' title='On not coming in last'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-4080427565177031133</id><published>2009-03-25T03:09:00.003-04:00</published><updated>2009-03-26T01:48:11.425-04:00</updated><title type='text'>x0x #2</title><content type='html'>To make up for the rather non-trivial amount of money it cost to build my x0xb0x, I decided to make another and sell it on eBay. I've been working on it since January (often while I should have been studying) but finally got it done after about 2 months of work. This is the result:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x1-1.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/thumb-x0x1-1.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The primary differences between this x0x and the "stock" &lt;a href="http://www.ladyada.net/make/x0xb0x/index.html"&gt;ladyada edition&lt;/a&gt; are mostly aesthetic. I chose to paint the case a darker shade of red, which turned out better than expected with the silver vinyl overlay. The overlay itself is sweet, but the alignment of the holes left much to be desired. I had to trim &lt;em&gt;all&lt;/em&gt; of the LED holes with a knife after applying the overlay so the vinyl didn't end up sticking to the LEDs. That alone took several episodes of &lt;a href="http://sho.com/site/ptbs"&gt;Bullshit&lt;/a&gt; to fully accomplish. The end result is reasonable as long as you don't look too closely.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x1-2.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/thumb-x0x1-2.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The knobs are the same as those on ladyada's parts list, but grey instead of black, and with a red pointer instead of white. If I had it to do over, I would have gotten black knobs with a white pointer. The grey doesn't really stand out enough and the red is actually more of a pink.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img.bityard.net/x0x/x0x1-4.JPG"&gt;&lt;img src="http://img.bityard.net/x0x/thumb-x0x1-4.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;On the inside, I used individual wires instead of ribbon cable for the jumpers. This might have worked better with a smaller gauge wire. (I should have used 24 or 26, but 22 is all I have on hand right now.) Also, I used connectors instead of soldering the wires straight to the board. This ended up being a life-saver but introduced a few problems as well. For starters, the connectors are hideously expensive (about $25 for the whole lot, I think). Also, the 12-pin row on the mainboard ends up standing too tall and hits the bottom of the case when assembled.&lt;br /&gt;&lt;br /&gt;Had no problems at all during the construction of this x0x and only found one silly but glaring issue the day before I shipped it to the buyer: The MIDI input and outputs weren't working at all. After an hour or so of troubleshooting with the oscilloscope, I finally figured out that I had soldered in &lt;em&gt;six&lt;/em&gt; resistors of entirely the wrong value. Replaced them and it worked like a champ!&lt;br /&gt;&lt;br /&gt;I'm a little sad now that it's gone, but building the second one was every bit as fun as the first.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-4080427565177031133?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/4080427565177031133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=4080427565177031133' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4080427565177031133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4080427565177031133'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/03/x0x-2.html' title='x0x #2'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-3872674416335423025</id><published>2009-03-10T02:02:00.009-04:00</published><updated>2009-03-26T01:50:51.600-04:00</updated><title type='text'>kick-ass song time</title><content type='html'>I'm an avid fan of music. Electronic music in particular, with only a few exceptions. I try to keep only freely-redistributable muzak in my playlists. Not only is it more affordable, but I believe music turns out better when the person composing it is doing so out of passion rather than profit. Nowhere is this more true than in the demoscene, where geekery intersects artistry.&lt;br /&gt;&lt;br /&gt;One song I've been grooving to lately is &lt;i&gt;Ride the Lightning&lt;/i&gt; by keith303. His website seems to be down as I post this, but check out his artist pages on &lt;a href="http://virb.com/k303"&gt;Virb&lt;/a&gt; and &lt;a href="http://www.last.fm/music/keith303"&gt;Last.fm&lt;/a&gt;. He's German! Always a plus in my book. &lt;i&gt;Ride the Lightning&lt;/i&gt; is a demo song that comes with &lt;a href="http://www.renoise.com/"&gt;Renoise&lt;/a&gt;, the most ass-kicking-est mashup between an old-school &lt;a href="http://en.wikipedia.org/wiki/Tracker"&gt;tracker&lt;/a&gt; and modern digital audio workstation that you'll ever see this decade.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Artist: &lt;a href="http://www.keith303.de/"&gt;Keith303&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;MP3 download: &lt;a href="ftp://ftp.scene.org/pub/music/artists/keith303/keith303_-_ride_the_lightning.mp3"&gt;Ride the Lightning&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Renoise Song download: &lt;a href="http://www.sdcompo.com/entry.php?dl=255"&gt;Ride the Lightning&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;object type="application/x-shockwave-flash" data="http://img.bityard.net/blog/objects/player_mp3.swf" width="200" height="20"&gt;&lt;br /&gt;    &lt;param name="movie" value="http://img.bityard.net/blog/objects/player_mp3.swf" /&gt;&lt;br /&gt;    &lt;param name="bgcolor" value="#ffffff" /&gt;&lt;br /&gt;    &lt;param name="FlashVars" value="mp3=http%3A//img.bityard.net/blog/kasotw/keith303_-_ride_the_lightning.mp3&amp;amp;showstop=1&amp;amp;showinfo=1" /&gt;&lt;br /&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-3872674416335423025?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/3872674416335423025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=3872674416335423025' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/3872674416335423025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/3872674416335423025'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/03/kick-ass-song-time.html' title='kick-ass song time'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-6878831600854360282</id><published>2009-02-09T16:41:00.002-05:00</published><updated>2009-02-09T17:26:52.955-05:00</updated><title type='text'>getting wired</title><content type='html'>A recent &lt;a href="http://slashdot.org"&gt;Slashdot&lt;/a&gt; article reminded me of my first attempts at trying to communicate with the outside world via computer. Growing up, I lived in a relatively remote area with no one I could talk to about computers or swap tips and programs with. But I learned as much as I could through magazines and books and eventually I learned that it was possible (with the right equipment) to connect your computer to a phone line and have it "talk" to another computer.&lt;br /&gt;&lt;br /&gt;It wasn't until we got a Packard Hell 16MHz 386 that I was able to try this out for myself. It happened to come with a 2400 bps modem pre-installed. And if you know me, you'd know that there was no way I was going to let that thing go unplayed with. One boring day, I ran a long phone line over to the computer, plugged it in, and used HyperTerminal (or something like it) to connect to a BBS on the other side of the state. I can't remember exactly how I got the number, but on this BBS I found that you could download programs, leave messages on the electronic forums, play games, and even talk with people in real time. I was floored. I had to share it with someone.&lt;br /&gt;&lt;br /&gt;Me: Mom! I'm talking to someone on the computer!&lt;br /&gt;Mom: What? How?&lt;br /&gt;Me: I connected it to the phone line and dialed up someone else's computer. Now I'm talking to them.&lt;br /&gt;Mom: Oh cool!&lt;br /&gt;Mom: ...&lt;br /&gt;Mom: Wait, is that long distance?&lt;br /&gt;&lt;br /&gt;In my area, pretty much every phone call was long distance and it wasn't cheap. Although we had a CompuServe account for some time, it wasn't until our local phone company added a local dial-up number for Internet access that I was able to spend huge amounts of time online.&lt;br /&gt;&lt;br /&gt;Now, a mere 15-20 years later, it's rare to &lt;em&gt;not&lt;/em&gt; have instant and constant access to the largest computer network in the world. I can't even imagine what kind of access the next couple of decades will bring.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-6878831600854360282?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/6878831600854360282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=6878831600854360282' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6878831600854360282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/6878831600854360282'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/02/getting-wired.html' title='getting wired'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-2008970712544866283</id><published>2009-01-21T01:17:00.006-05:00</published><updated>2009-01-21T02:14:39.223-05:00</updated><title type='text'>OpenSSH: The Poor Man's SOCKS Proxy</title><content type='html'>Just when I think I know everything I need to know about &lt;a href="http://openssh.org/"&gt;OpenSSH&lt;/a&gt;, I end up learning something new and tremendously useful. Today, that would be the -D argument.&lt;br /&gt;&lt;br /&gt;Many times I have been stuck on an "untrusted" Internet connection and need to log in (insecurely) to a certain site. My university, for example, uses a system that has no way of logging in via HTTPS, nor does it secure the traffic to and from the browser. I have moderate faith that the folks at my ISP aren't snooping my traffic (since I know the company pretty well and used to work with them), so I don't have a huge problem logging into their site at home. I also have a colocated server at the web hosting company I work for, so I know the layout of their network even better and trust them not to snoop or interfere with my traffic. But when I'm on the road connected to some dodgy insecure hotel wifi, I acquire no small amount of anxiety over the fact that anyone with a packet sniffer can get access to all of my personal and academic details.&lt;br /&gt;&lt;br /&gt;For the past few years, I've had this plan to get &lt;a href="http://openvpn.net/"&gt;OpenVPN&lt;/a&gt; set up for my network and laptop so that I can always have a secure connection to my home and colocated server. And for the past few years, I've kept putting it off. While OpenVPN is easier to use than many other VPN solutions I could name, it's still at least a good hour of my time getting all the settings right and testing it out.&lt;br /&gt;&lt;br /&gt;I was already aware of OpenSSH's -L option which simply forwards a local port through an SSH tunnel to a port on the remote machine. Very handy when you want to connect surely to a site hosted on that server and happen to have a shell account on it. But to do much more than that ranges from the complex to impossible. This is where -D comes in.&lt;br /&gt;&lt;br /&gt;The -D arg tells OpenSSH to be a &lt;a href="http://en.wikipedia.org/wiki/SOCKS"&gt;SOCKS&lt;/a&gt; proxy. So you simply log in to the endpoint via SSH with the -D arg like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;ssh -D 1234 user@host.example.com&lt;/pre&gt;&lt;br /&gt;And then tell your web browser to use a SOCKS v5 proxy on localhost at the specified port and bingo, you have a secure connection to your endpoint. In fact, any application with SOCKS support can have its traffic routed through the SSH tunnel via SOCKS. Firefox supports SOCKS just fine, Opera doesn't. Konqueror is supposed to, but judging from the Google responses I got, support might be a little flaky.&lt;br /&gt;&lt;br /&gt;The final test was whether I'd be able to use this newfangled (to me) proxy method on my Nokia N800, a device that I browse and email with quite often whilst traveling. Obviously OpenSSH has to be installed as it doesn't come with the firmware. And the N800's web browser, MicroB, uses the Gecko engine. The UI has no widgets for entering a SOCKS proxy, but you can set the preferences manually with about:config:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;network.proxy.socks localhost&lt;br /&gt;network.proxy.socks_port 1234&lt;br /&gt;network.proxy.type 1&lt;/pre&gt;&lt;br /&gt;The result? Portable proxy surfing!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-2008970712544866283?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/2008970712544866283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=2008970712544866283' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/2008970712544866283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/2008970712544866283'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/01/make-openssh-socks-proxy.html' title='OpenSSH: The Poor Man&apos;s SOCKS Proxy'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-3973926523016186401</id><published>2009-01-18T19:12:00.003-05:00</published><updated>2009-01-18T19:32:53.725-05:00</updated><title type='text'>Korg Electribe EMX-1</title><content type='html'>Next on my list of completely bad-ass gadgets to acquire in the distant future:&lt;br /&gt;&lt;br /&gt;&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/KZaqlSudOuw&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/KZaqlSudOuw&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;(This is not me playing by the way, it's the user known as &lt;a href="http://www.youtube.com/profile?user=Denkitribe&amp;view=videos"&gt;Denkitribe on YouTube&lt;/a&gt; and his beats generally rock.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-3973926523016186401?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/3973926523016186401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=3973926523016186401' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/3973926523016186401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/3973926523016186401'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2009/01/korg-electribe-emx-1.html' title='Korg Electribe EMX-1'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-1263295368544349676</id><published>2008-12-16T02:39:00.001-05:00</published><updated>2008-12-16T02:40:40.920-05:00</updated><title type='text'>My Progeny</title><content type='html'>&lt;img src="http://img.bityard.net/blog/progeny.jpg" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-1263295368544349676?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/1263295368544349676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=1263295368544349676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1263295368544349676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1263295368544349676'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/12/my-progeny.html' title='My Progeny'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-1886594033402221125</id><published>2008-11-25T22:27:00.004-05:00</published><updated>2008-11-25T22:43:51.716-05:00</updated><title type='text'>muddy thinking</title><content type='html'>&lt;span style="font-weight:bold;"&gt;&lt;a href="http://digg.com/environment/3_000_Riot_to_Protest_Crackdown_on_Illegal_Amazon_Logging"&gt;3,000 Riot to Protest Crackdown on Illegal Amazon Logging&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You know you've had your head stuck inside a computer for too long when, after reading the headline above, you start wondering why:&lt;br /&gt;&lt;br /&gt;1. How long had Amazon.com been keeping these logs?&lt;br /&gt;2. In which country is excessive logging of customer data illegal?&lt;br /&gt;3. How much did Jeff Bezos have to pay these protesters to incite a riot?&lt;br /&gt;&lt;br /&gt;But it turns out of course that it's a rainforest article. (Insert "couldn't see the forest for the trees" pun here.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-1886594033402221125?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/1886594033402221125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=1886594033402221125' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1886594033402221125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1886594033402221125'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/11/3000-riot-to-protest-crackdown-on.html' title='muddy thinking'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-858546098507907837</id><published>2008-11-15T18:46:00.008-05:00</published><updated>2008-11-16T00:23:04.841-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='x0xb0x'/><title type='text'>We be x0xing</title><content type='html'>It occurred to me today that I hadn't put up many pictures yet of my &lt;a href="http://www.ladyada.net/make/x0xb0x/"&gt;x0xb0x&lt;/a&gt; whilst under construction. It further occurred to me I had not &lt;em&gt;taken&lt;/em&gt; many pictures of my x0xb0x whilst under construction either. Besides the one a few posts down, this is it:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img.bityard.net/blog/progress-vco-vca.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;Here the power supply is done (the components on the smaller PCB to the right) as well as the VCO and VCA sections of the mainboard. And also a few IC sockets are in because I got bored one night and wanted to solder but didn't have all the parts yet.&lt;br /&gt;&lt;br /&gt;Here's a photo of the finished product:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img.bityard.net/blog/x0x-finished.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;It simply sounds marvelous and is a joy to tinker with. I used diffused blue LEDs (which are actually hard to get a hold of cheaply) and metal knobs. The knobs ended up being the wrong size though, so they sort of wobble a little when you turn them. (The center of the pot is not the same as the center of the knob.)&lt;br /&gt;&lt;br /&gt;I also happened across a picture of the oscilloscope I bought on eBay. Four channels, 100MHz, all awesome. It's the exact same model that I used in the Air Force to repair autopilot systems so I'm already familiar with its operation. Usually, buying something like an oscilloscope on eBay is extremely risky. An oscilloscope is a precision instrument with a million different things that can go wrong and quite a few bits inside that have to be calibrated every so often. On top of that, most of the test equipment for sale on eBay comes from auctions a.k.a., refuse.&lt;br /&gt;&lt;br /&gt;I got lucky, though: $300 (free shipping) and there's not a single thing wrong with it. I like gambles that work out in my favor.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img.bityard.net/blog/tek2246a.jpg" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-858546098507907837?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/858546098507907837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=858546098507907837' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/858546098507907837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/858546098507907837'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/11/we-be-x0xing.html' title='We be x0xing'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-4884610517972523509</id><published>2008-11-02T00:19:00.010-04:00</published><updated>2009-03-26T01:54:34.947-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='x0xb0x'/><category scheme='http://www.blogger.com/atom/ns#' term='rebirth'/><category scheme='http://www.blogger.com/atom/ns#' term='muzak'/><category scheme='http://www.blogger.com/atom/ns#' term='303'/><title type='text'>Overcontroller</title><content type='html'>Not only is this my first &lt;a href="http://www.ladyada.net/make/x0xb0x/index.html"&gt;x0xb0x&lt;/a&gt; track, it's the first full piece of "music" I've composed. Evar.&lt;br /&gt;&lt;br /&gt;The main sound is a x0xb0x connected to a Zoom 506 bass guitar effects pedal with some pretty wild settings. The x0x provided MIDI sync to &lt;a href="http://www.rebirthmuseum.com/"&gt;ReBirth&lt;/a&gt;, a software synthesizer for Windows which donated a second 303 to the track as well as authentic 808 and 909 drum machine sounds. ReBirth performs admirably on Linux with the help of &lt;a href="http://www.winehq.org/"&gt;Wine&lt;/a&gt;, even the MIDI stuff.&lt;br /&gt;&lt;br /&gt;This was recorded "live" in a single go, although there was some rehearsal. (And obviously the patterns were not programmed on the fly.) It's also kinda noisy since I've yet to perfect the art of recording things from the audio-in of a sound card. The drum machine effects themselves are known to be cheesy (808 cowbell!) since I was just trying to get something that sounded somewhat catchy without getting bogged down in minutiae. Overall, I'm quite happy with how it turned out.&lt;br /&gt;&lt;br /&gt;Here are links to it in two formats: OGG and MP3. The OGG one sounds better but you might only have an MP3 player handy.&lt;ul&gt;&lt;li&gt;&lt;a href="http://img.bityard.net/muzak/overcontroller.ogg"&gt;overcontroller.ogg&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://img.bityard.net/muzak/overcontroller.mp3"&gt;overcontroller.mp3&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;object type="application/x-shockwave-flash" data="http://img.bityard.net/blog/objects/player_mp3.swf" width="200" height="20"&gt;&lt;br /&gt;    &lt;param name="movie" value="http://img.bityard.net/blog/objects/player_mp3.swf" /&gt;&lt;br /&gt;    &lt;param name="bgcolor" value="#ffffff" /&gt;&lt;br /&gt;    &lt;param name="FlashVars" value="mp3=http%3A//img.bityard.net/muzak/overcontroller.mp3&amp;amp;showstop=1&amp;amp;showinfo=1" /&gt;&lt;br /&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;a rel="license" href="http://creativecommons.org/licenses/by/3.0/us/"&gt;&lt;img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-4884610517972523509?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/4884610517972523509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=4884610517972523509' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4884610517972523509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4884610517972523509'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/11/overcontroller.html' title='Overcontroller'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-793114032424770685</id><published>2008-10-27T14:54:00.005-04:00</published><updated>2008-10-27T16:50:49.285-04:00</updated><title type='text'>Linux terminal speed benchmarks</title><content type='html'>In system administration, you spend a lot of time typing into and reading back information from a terminal. Although all terminals pretty much do the same thing, they can differ somewhat in their UI features or which desktop they were designed to be integrated into.&lt;br /&gt;&lt;br /&gt;A few years back I was doing a lot of compiling (Gentoo, FreeBSD) and I felt that a good deal of that time was spent just waiting for the terminal to print the enormous amount of compiler cruft to the screen. So I did some quick benchmarks. I don't remember the exact results of those benchmarks nor if I actually made a decision based on them but I clearly remember that results were interesting.&lt;br /&gt;&lt;br /&gt;The topic of terminal speed came up at work today so I set out to replicate the experiment. Creating a benchmark like this is harder than it sounds because every time a single a character is printed in a graphical terminal, code is being run in the Linux kernel, numerous places in X, the video card driver, the command shell (bash), and the application running the benchmark itself and even the raw performance of the video card itself can come into play. To design the perfect graphical terminal benchmark, you'd need deep knowledge of how all of those work and carefully craft the benchmark so as to maximize the "stress" on the graphical terminal code while minimizing "stress" on the other components of the system.&lt;br /&gt;&lt;br /&gt;However, I'm far too lazy for all that.&lt;br /&gt;&lt;br /&gt;So I just catted a &lt;a href="http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.23"&gt;Linux kernel changelog&lt;/a&gt; to the screen. Each benchmark was run four times times sequentially and the time averaged among the last three trials. (The first is a dry run to ensure that the file is cached in memory.)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Terminal        time cat ChangeLog-2.6.23&lt;br /&gt;-----------------------------------------&lt;br /&gt;xfce4-terminal  11.109&lt;br /&gt;gnome-terminal  11.022&lt;br /&gt;terminator      10.878&lt;br /&gt;xterm           7.320&lt;br /&gt;konsole         3.191&lt;br /&gt;rxvt            2.983&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I was rather expecting rxvt to win since it's widely regarded as the minimalist terminal, but Konsole was a surprise. It beats even xterm by a large margin. Like KDE, Konsole is almost certainly written in C++, widely regarded as slower than C which is what makes these results pretty interesting. It's also noteworthy that the xfce4 terminal is right on par with the Gnome terminal when XFCE is supposed to be more lightweight than Gnome. (And probably is, overall.) Based on these figures, one could speculate that terminator, xfce4-terminal, and gnome-terminal are all based on similar code or libraries.&lt;br /&gt;&lt;br /&gt;And finally, just in case you skipped the part above where I said how poorly this "benchmark" was really constructed, I want to emphasize it again: This benchmark is completely unscientific. This is how these terminals did on my computer. You may get a different (even perhaps contradictory) set of results if you run them on your computer. Nevertheless, I'm fairly confident that the results here are representative of what most people will see.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-793114032424770685?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/793114032424770685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=793114032424770685' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/793114032424770685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/793114032424770685'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/10/linux-terminal-speed-benchmarks.html' title='Linux terminal speed benchmarks'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-1456217135193347398</id><published>2008-10-24T02:12:00.006-04:00</published><updated>2008-10-24T11:02:31.473-04:00</updated><title type='text'>Ghetto-sistor</title><content type='html'>This, my friends, is what is called a "ghetto-sistor."&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img.bityard.net/blog/ghettosistor.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;It's what you get when you need a 1K ohm resistor, but don't have a new one handy, and instead have to settle for ripping one out of an old telephone before you realize that one leg is going to be too short so you solder a piece of solid scrap wire onto it so it's the right length.&lt;br /&gt;&lt;br /&gt;Ghetto-sistor. GET IT?&lt;br /&gt;&lt;br /&gt;Sheesh, you have no sense of humor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-1456217135193347398?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/1456217135193347398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=1456217135193347398' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1456217135193347398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1456217135193347398'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/10/ghetto-sistor.html' title='Ghetto-sistor'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-1883988173043666960</id><published>2008-10-24T01:26:00.003-04:00</published><updated>2008-10-24T01:52:58.245-04:00</updated><title type='text'>It's Alive!</title><content type='html'>&lt;img src="http://img.bityard.net/blog/blinky.jpg"&gt;&lt;br /&gt;&lt;br /&gt;And by god, it is blinky.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-1883988173043666960?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/1883988173043666960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=1883988173043666960' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1883988173043666960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/1883988173043666960'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/10/its-alive.html' title='It&apos;s Alive!'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2836700939935266529.post-4954129119878025914</id><published>2008-10-13T21:14:00.001-04:00</published><updated>2008-10-13T22:06:31.602-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='blog'/><category scheme='http://www.blogger.com/atom/ns#' term='googles'/><title type='text'>Well, heck dang.</title><content type='html'>Seeing as everyone else in the known universe has a blog now, I figured it was high time I jumped on the bandwagon. Technically, I was blogging before it was cool, but &lt;a href="http://archive.org/"&gt;ye olde archive machine&lt;/a&gt; doesn't have too many of my pages from way back when.&lt;br /&gt;&lt;br /&gt;Because I'm picky, I'd like to write my own backend for the site and host it on my own server as I don't exactly trust teh Googles. But writing that is going to take a small eternity, most likely, so this will have to do for now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2836700939935266529-4954129119878025914?l=bityard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bityard.blogspot.com/feeds/4954129119878025914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2836700939935266529&amp;postID=4954129119878025914' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4954129119878025914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2836700939935266529/posts/default/4954129119878025914'/><link rel='alternate' type='text/html' href='http://bityard.blogspot.com/2008/10/well-heck-dang.html' title='Well, heck dang.'/><author><name>charles</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
