<?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>Edward Ned Harvey</title>
	<atom:link href="http://nedharvey.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://nedharvey.com/blog</link>
	<description>nedharvey.com</description>
	<lastBuildDate>Fri, 13 Apr 2012 20:55:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Broken RSA Keys (part 3: openssl)</title>
		<link>http://nedharvey.com/blog/?p=81</link>
		<comments>http://nedharvey.com/blog/?p=81#comments</comments>
		<pubDate>Sun, 19 Feb 2012 15:35:49 +0000</pubDate>
		<dc:creator>rahvee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nedharvey.com/blog/?p=81</guid>
		<description><![CDATA[Openssl uses the RANDFILE environment variable or configuration setting in its config file to specify the location of a random seed. During key generation, this seed is combined with a few bytes from /dev/urandom, to be used as a new &#8230;<p class="read-more"><a href="http://nedharvey.com/blog/?p=81">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Openssl uses the RANDFILE environment variable or configuration setting in its config file to specify the location of a random seed.  During key generation, this seed is combined with a few bytes from /dev/urandom, to be used as a new seed for the openssl internal pseudorandom number generator.</p>
<p>In most systems, you can find your own personal openssl seed in ~/.rnd, and for the purposes of this blog post, I am going to use ~/.rnd and RANDFILE interchangeably.  But of course, you need to use whatever is the correct RANDFILE in your configuration.  Upon first run, openssl should generate ~/.rnd for you.  If you generate some key with openssl and ~/.rnd still doesn&#8217;t exist, you better dig into your environment variables and openssl config file to find RANDFILE.  You&#8217;re going to need it momentarily.</p>
<p>Every time openssl reads ~/.rnd, it overwrites the file with a new random seed for next time.  So to ensure strong entropy using openssl, all you need to do is ensure strong entropy entered into this file once.  After that, you may safely assume all your openssl operations on that machine include high entropy.</p>
<p>This file is 1k long (8192 bits) but your openssl private key has a cryptographic strength around 128 or 256 bits (a 3072 bit RSA or DH private key has a cryptographic strength of 128 bits).  Also, when openssl reads your RANDFILE, it will include additional bytes from urandom, which can only strengthen your key further.  So we don&#8217;t need anywhere near 8192 bits of entropy in your RANDFILE.  32 bytes = 256 bits</p>
<p>There are lots of easy ways to get this wrong.  You could be reading the wrong openssl.cnf file. Maybe you had a type-o when you set RANDFILE. Maybe the openssl you&#8217;re using ignores your RANDFILE environment variable. To eliminate all of these possible sources of error, do this:</p>
<ul>
<li>Run your openssl command.</li>
<li>Now check your ~/.rnd file (or whatever RANDFILE) to ensure it exists.</li>
<li>Get the md5sum.</li>
<li>Run your openssl command again.</li>
<li>Get the new md5sum, and ensure it&#8217;s different from before. This will ensure you&#8217;re definitely looking at the right RANDFILE, which is definitely being used by your openssl command.</li>
</ul>
<p>Now, overwrite that file with a new random seed:<br />
<code>dd if=/dev/random bs=1 count=32 of=~/.rnd</code></p>
<p>After generating a new random seed file, run your openssl command for real, trusting that you have strong entropy from now on.</p>
<p>Please see also:</p>
<p><a href="http://nedharvey.com/blog/?p=63">Broken RSA Keys (part1: the problem)</a><br />
and<br />
<a href="http://nedharvey.com/blog/?p=78">Broken RSA Keys (part 2: fixing ssh keys)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nedharvey.com/blog/?feed=rss2&#038;p=81</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Broken RSA Keys (part 2: fixing ssh keys)</title>
		<link>http://nedharvey.com/blog/?p=78</link>
		<comments>http://nedharvey.com/blog/?p=78#comments</comments>
		<pubDate>Sun, 19 Feb 2012 15:26:02 +0000</pubDate>
		<dc:creator>rahvee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nedharvey.com/blog/?p=78</guid>
		<description><![CDATA[As mentioned in a previous post, there are problems with people generating keys with insufficient entropy. This is particularly a problem for ssh, which generates the host ssh keys upon first boot, when there was probably insufficient entropy available. If &#8230;<p class="read-more"><a href="http://nedharvey.com/blog/?p=78">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>As mentioned in a previous post, there are problems with people generating keys with insufficient entropy.  This is particularly a problem for ssh, which generates the host ssh keys upon first boot, when there was probably insufficient entropy available.</p>
<p>If you&#8217;re generating ssh keys (ssh-keygen) you can solve the problem by using <code>SSH_USE_STRONG_RNG</code> as shown below. Note, in this command, it&#8217;s bytes. So 32 equals 256 bits.</p>
<p>To generate good SSH Keys (assuming redhat derivative linux):<br />
<code><br />
sudo mkdir /etc/ssh/oldkeys<br />
sudo mv /etc/ssh/*_key* /etc/ssh/oldkeys</p>
<p>export SSH_USE_STRONG_RNG=32<br />
sudo ssh-keygen -q -C "" -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key<br />
sudo ssh-keygen -q -C "" -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key<br />
sudo ssh-keygen -q -C "" -N "" -t rsa1 -f /etc/ssh/ssh_host_key</p>
<p>sudo chmod 600 /etc/ssh/*_key<br />
sudo chmod 644 /etc/ssh/*_key.pub<br />
sudo chown root:root /etc/ssh/*key*</p>
<p>sudo service sshd restart<br />
</code></p>
<p>Please also see:<br />
<a href="http://nedharvey.com/blog/?p=63">Broken RSA Keys (part1: the problem)</a><br />
and<br />
<a href="http://nedharvey.com/blog/?p=81">Broken RSA Keys (part 3: openssl)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nedharvey.com/blog/?feed=rss2&#038;p=78</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Broken RSA Keys (part1: the problem)</title>
		<link>http://nedharvey.com/blog/?p=63</link>
		<comments>http://nedharvey.com/blog/?p=63#comments</comments>
		<pubDate>Thu, 16 Feb 2012 16:04:10 +0000</pubDate>
		<dc:creator>rahvee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nedharvey.com/blog/?p=63</guid>
		<description><![CDATA[Lots of stories circulating the news right now (such as this one) about RSA keys providing no security. The problem is not RSA. The problem is bad random seeds when you generated your keys. The solution: Generate new keys using &#8230;<p class="read-more"><a href="http://nedharvey.com/blog/?p=63">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Lots of stories circulating the news right now (such as <a href="http://arstechnica.com/business/news/2012/02/crypto-shocker-four-of-every-1000-public-keys-provide-no-security.ars">this one</a>) about RSA keys providing no security. The problem is not RSA. The problem is bad random seeds when you generated your keys. The solution: Generate new keys using good randomness.</p>
<p>The word for &#8220;randomness&#8221; is &#8220;entropy.&#8221;  Entropy is the measure of unpredictability.  A single fair coin toss represents a single bit of entropy.</p>
<p>For the moment, I&#8217;ll write about linux specifically.  Much of this information comes from man (4) random.</p>
<p>/dev/random is gathered from hardware entropy sources, such as TPM and keyboard &amp; mouse movements, and unpredictable disk seek times and supposedly unpredictable characteristics of the ethernet and hardware interrupts, etc.  Since there is a limited amount of system entropy available, if you try to read /dev/random, your read will block (stall) until more bytes become available.</p>
<p>/dev/urandom is a pseudorandom number generator, based on hash algorithms or ciphers or similar.  It is actually deterministic given the initial seed.  This is a non-blocking device, so you can read infinite bytes from it as fast as the CPU can generate them.  If you read enough data from /dev/urandom, it may exhaust any available entropy, and it will be reused.  In other words, a pattern will emerge.</p>
<p>As entropy becomes available in /dev/random, it is fed into /dev/urandom.  This helps to continually re-seed urandom and helps urandom to be more actually unpredictable.  Basically, urandom is an amplifier of the true entropy.</p>
<p>Unfortunately, when a system is freshly installed, upon first boot, there hasn&#8217;t been much entropy gathered. It&#8217;s fairly deterministic. During first boot, even if you use urandom, it is only amplifying a very small amount of actual entropy.  This is when your ssh keys get generated.</p>
<p>Clearly, you should generate new server ssh keys (and any other keys) sometime after you can assure sufficient entropy. The question is, how do you know you have sufficient entropy in your key generation process?</p>
<p>I&#8217;m going to answer this question in two parts, separately.  Once for ssh, and once for openssl.  Please see:<br />
<a href="http://nedharvey.com/blog/?p=78">Broken RSA Keys (part 2: fixing ssh keys)</a><br />
and<br />
<a href="http://nedharvey.com/blog/?p=81">Broken RSA Keys (part 3: openssl)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nedharvey.com/blog/?feed=rss2&#038;p=63</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Competitive Advantage</title>
		<link>http://nedharvey.com/blog/?p=58</link>
		<comments>http://nedharvey.com/blog/?p=58#comments</comments>
		<pubDate>Sat, 24 Dec 2011 16:21:13 +0000</pubDate>
		<dc:creator>rahvee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nedharvey.com/blog/?p=58</guid>
		<description><![CDATA[There is a level of support (IT and otherwise) that is necessary just to keep the doors open for business. Many businesses cut their support down to this level, thinking of us as &#8220;overhead.&#8221; But beyond that point &#8211; IT &#8230;<p class="read-more"><a href="http://nedharvey.com/blog/?p=58">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>There is a level of support (IT and otherwise) that is necessary just to keep the doors open for business.  Many businesses cut their support down to this level, thinking of us as &#8220;overhead.&#8221;  But beyond that point &#8211; IT is a force multiplier, we provide competitive advantage (neutralizing competitors&#8217; advantage, or gaining our own competitive advantage).  Both in terms of our organization&#8217;s ability to produce more and meet more targets, and in terms of our ability to attract &#038; retain talented workforce.</p>
<p>When you think about it, most of the &#8220;coolness&#8221; factors of an organization are support related, IT and otherwise.  Coolness factors represent a real, but often intangible or unmeasurable, advantage to attracting &#038; retaining talent.  It&#8217;s company image, it&#8217;s marketing for your brand.</p>
]]></content:encoded>
			<wfw:commentRss>http://nedharvey.com/blog/?feed=rss2&#038;p=58</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>selinux notes</title>
		<link>http://nedharvey.com/blog/?p=12</link>
		<comments>http://nedharvey.com/blog/?p=12#comments</comments>
		<pubDate>Sun, 02 Oct 2011 17:36:47 +0000</pubDate>
		<dc:creator>rahvee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nedharvey.com/blog/?p=12</guid>
		<description><![CDATA[These are my notes, after learning from Fedora Selinux FAQ Become root. Although you could do this with sudo, it&#8217;s more of a pain. Also, you may be glad, some day, that you left these files laying around, and the &#8230;<p class="read-more"><a href="http://nedharvey.com/blog/?p=12">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>These are my notes, after learning from <a title="Fedora Selinux FAQ" href="http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385" target="_blank">Fedora Selinux FAQ</a></p>
<ul>
<li>Become root. Although you could do this with sudo, it&#8217;s more of a pain.<br />
Also, you may be glad, some day, that you left these files laying around, and the best place for that is in root&#8217;s home directory (or a subdirectory.)</p>
</li>
<li>You must ensure the auditd service is installed and started.<br />
<code>yum -y install auditd policycoreutils-python</code><br />
<code>service auditd start</code></p>
</li>
<li>First, make sure there&#8217;s nothing in your audit log.<br />
<code>audit2allow -m local -l -i /var/log/audit/audit.log</code><br />
If there is anything in there, clear it out with<br />
<code>semodule --reload</code></p>
</li>
<li>Now, temporarily disable selinux<br />
<code>setenforce 0</code></p>
</li>
<li>Do whatever would normally get blocked.<br />
<code> </code></p>
</li>
<li>And re-enable selinux<br />
<code>setenforce 1</code></p>
</li>
<li>Make up a new module name, such as &#8220;httpdwritehomes&#8221; and prepare that module from the list of stuff that was captured in the audit log:<br />
<code>export newmod=httpdwritehomes</code><br />
<code>audit2allow -m $newmod -l -i /var/log/audit/audit.log &gt; $newmod.te</code><br />
Be sure to edit that file, read it over, and remove anything that doesn&#8217;t belong</p>
</li>
<li>Note: If nothing appears in the logs, you might have to disable &#8220;don&#8217;taudit&#8221;  See <a href="http://danwalsh.livejournal.com/11673.html">http://danwalsh.livejournal.com/11673.html</a><br />
<code>semodule -DB</code><br />
and later<br />
<code>semodule -B</code></p>
</li>
<li>Now compile and install the new module<br />
<code>checkmodule -M -m -o $newmod.mod $newmod.te<br />
semodule_package -o $newmod.pp -m $newmod.mod<br />
semodule -i $newmod.pp</code></p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://nedharvey.com/blog/?feed=rss2&#038;p=12</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

