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

<channel>
	<title>Anthony R. Thompson&#039;s Blog &#187; crypt</title>
	<atom:link href="http://blog.anthonyrthompson.com/tag/crypt/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.anthonyrthompson.com</link>
	<description>Helpful Things</description>
	<lastBuildDate>Tue, 26 Oct 2010 17:47:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Maximum Password Length On Linux</title>
		<link>http://blog.anthonyrthompson.com/2010/02/maximum-password-length-on-linux/</link>
		<comments>http://blog.anthonyrthompson.com/2010/02/maximum-password-length-on-linux/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 10:35:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[password length]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.anthonyrthompson.com/?p=13</guid>
		<description><![CDATA[It used to be the case, years ago, that passwords on Unix systems were limited to 8 characters. Or rather, you could type in more than 8 characters, but only the first 8 characters mattered. It occurred to me recently that by now, this limit must surely have been lifted, especially as Moore&#8217;s Law has [...]]]></description>
			<content:encoded><![CDATA[<p>It used to be the case, years ago, that passwords on Unix systems were limited to 8 characters. Or rather, you could type in more than 8 characters, but only the first 8 characters mattered.</p>
<p>It occurred to me recently that by now, this limit must surely have been lifted, especially as <a href="http://en.wikipedia.org/wiki/Moore's_law">Moore&#8217;s Law</a> has improved hardware speeds and thus the ability to <a href="http://en.wikipedia.org/wiki/Password_cracking#Early_Unix_password_vulnerability">crack passwords of 8 characters easily via brute force</a>.</p>
<p>(See <a href="http://nsrc.cse.psu.edu/tech_report/NAS-TR-0030-2006.pdf">Password Exhaustion: Predicting the End of Password Usefulness &#8211; PDF</a> for more good info on this.)</p>
<p>So I asked about this over on <a href="http://stackoverflow.com/questions/2179649/are-passwords-on-modern-unix-linux-systems-still-limited-to-8-characters">Stack Overflow</a> (SO), and got a lot of good responses. But in thinking about the answers more, and in particular trying to code something to find the maximum length on a given system, I had some more thoughts.</p>
<p>In particular, while the limit of 8 characters probably went away on most Linux systems in the late 1990s or early 2000s, there&#8217;s always a lingering question (in my mind anyway) of, &#8220;Yeah, but does this system I&#8217;m currently on support characters &gt; 8 characters?&#8221;</p>
<p>Here&#8217;s what I coded up as a quick Perl script to try finding the maximum length of passwords for the system it&#8217;s run on:</p>
<pre>#!/usr/bin/perl -w
$| = 1; # turn off output buffering so each . prints out
my($newpasswd) = chr(rand(95) + 32); # ASCII char 32-126
my($lasthash) = crypt($newpasswd, '$1$12345678'); # MD5=$1$
while (1) {
    print '.'; # for debugging/progress
    $newpasswd = join('', $newpasswd, chr(rand(95) + 32));
    $newhash = crypt($newpasswd, '$1$12345678');
    if ($newhash eq $lasthash) {
        print "Maximum password length: ";
        print length($newpasswd) - 1, "\n";
        last;
    }
}
</pre>
<p>(loosely based on some code posted in response to my question on SO)</p>
<p>After looking at <a href="http://www.ratliff.net/blog/2007/09/20/password-length/">this blog post on Password Length</a>, I figured the program would stop at 79 or 127 or something, but to my surprise it didn&#8217;t, it just kept going on and on and on until eventually it was killed by my web host as a runaway program (which, I guess, it sort of was <img src='http://blog.anthonyrthompson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>This puzzled me, and <a title="Lothar of the Hill People on Hulu - do you find it vexing?" href="http://www.hulu.com/watch/4108/saturday-night-live-lothar-of-the-hill-people">vexed</a> me, so in my obsessiveness I wanted to find out why this would happen. I mean, that blog post said there was a limit, so why wasn&#8217;t I finding one?</p>
<p>It turns out that as long as you&#8217;re making the Unix crypt() function use a hashing method other than the classic/default <a href="http://en.wikipedia.org/wiki/Crypt_%28Unix%29#Traditional_DES-based_scheme">DES-based algorithm</a>, by using a salt prefix like $1$ for MD5, there really is no limit to the password because it&#8217;s like producing an MD5 hash for a file—you can get a different MD5 hash for files of any length.</p>
<p>I believe where the real limit—if there is one on a given system—comes in, is not in the Unix crypt() function, but by the password programs such as &#8220;passwd&#8221; that use it. Those programs themselves may have input limits, which is the only way I can explain the limits shown on that <a href="http://www.ratliff.net/blog/2007/09/20/password-length/">password length blog post</a>.</p>
<p>As someone on SO commented though, you&#8217;re probably always <em>safe</em> using a password longer than 8 characters—if you used &#8220;mybigbigapple&#8221; as a password and the system only paid attention to the first 8 characters, it would just ignore the &#8220;apple&#8221; part. It&#8217;s just a question of whether it wall also accept &#8220;mybigbigorange&#8221;.</p>
<p>And if it&#8217;s <em>easier</em> for you to remember a longer password, then that&#8217;s a consideration too.</p>
<p>I guess for me it&#8217;s just a question of knowing whether the system I&#8217;m on is stronger (supporting passwords &gt; 8 characters) or weaker with passwords, and for some reason I just want to <strong>know</strong> whether the system is ignoring everything I type past 8.</p>
<p>I did find it a little ironic, though, that if your password gets into the very long category, there&#8217;s actually a greater chance (<a href="http://en.wikipedia.org/wiki/MD5#Collision_vulnerability">at least with MD5</a> I believe) of a hash collision, meaning that another password (or one entered by a password cracker) might produce the same hash and thus let someone use that alternate password instead of your real password.</p>
<p>(If you have no idea what I&#8217;m talking about re: password hashes, see the Wikipedia article on Passwords, particularly the <a href="http://en.wikipedia.org/wiki/Password_cracking#Background">Background section</a>.)</p>
<p>So where does that leave us? Well, I think it&#8217;s relatively easily to check whether crypt() supports passwords longer than 8 characters:</p>
<pre>perl -e 'if (crypt(q^12345678^, q^$1$@@$^) eq
  crypt(q^123456789^, q^$1$@@$^)) { print "crypt() appears
  limited to 8 characters\n" } else { print "crypt() appears
  to support more than 8 characters\n"; }'
</pre>
<p>(typed on the command line, all in one line of course)</p>
<p>Exactly <em>how much longer</em> than 8 characters seems like it would depend on the particular program and not crypt() itself. The <a href="http://www.ratliff.net/blog/2007/09/20/password-length/">password length blog post</a> seems to say that 72 or 79 might be a common limit, and since the average English word length appears to be 5.1 letters, that&#8217;s about 14 words.</p>
<p>So as a rule of thumb, we can probably figure that maybe a 10 word maximum for a password (really a &#8220;pass phrase&#8221;) is about right. That&#8217;s what I&#8217;ll go with anyway, at least after I use the command above to check that such a longer password/passphrase will actually be worth the trouble on a given system <img src='http://blog.anthonyrthompson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>At least until passwords <a title="Short clip of eye scan from Minority Report" href="http://www.youtube.com/watch?v=kx9IEP8pmiI">go away completely</a> of course! <img src='http://blog.anthonyrthompson.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>(And while I&#8217;m on the topic of security, let me recommend the excellent book <a href="http://www.amazon.com/exec/obidos/ASIN/0470395354/antrtho-20/">Schneier on Security</a>. I picked it up in the bookstore recently with a stack of other books to breeze through, and long after putting the other books down I was still reading it! Very good thinking on a wide range of computer security topics.)</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">http://nsrc.cse.psu.edu/tech_report/NAS-TR-0030-2006.pdf</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonyrthompson.com/2010/02/maximum-password-length-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

