<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Stop using unsafe keyed hashes, use HMAC</title>
	<atom:link href="http://rdist.root.org/2009/10/29/stop-using-unsafe-keyed-hashes-use-hmac/feed/" rel="self" type="application/rss+xml" />
	<link>http://rdist.root.org/2009/10/29/stop-using-unsafe-keyed-hashes-use-hmac/</link>
	<description>Embedded security, crypto, software protection</description>
	<lastBuildDate>Mon, 08 Mar 2010 21:19:29 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: B-Con</title>
		<link>http://rdist.root.org/2009/10/29/stop-using-unsafe-keyed-hashes-use-hmac/#comment-5453</link>
		<dc:creator>B-Con</dc:creator>
		<pubDate>Fri, 04 Dec 2009 20:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://rdist.root.org/?p=456#comment-5453</guid>
		<description>OK, thanks. I just wanted to be certain that, in order for that attack to work, the collision had to be for messages of equal lengths.</description>
		<content:encoded><![CDATA[<p>OK, thanks. I just wanted to be certain that, in order for that attack to work, the collision had to be for messages of equal lengths.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate Lawson</title>
		<link>http://rdist.root.org/2009/10/29/stop-using-unsafe-keyed-hashes-use-hmac/#comment-5451</link>
		<dc:creator>Nate Lawson</dc:creator>
		<pubDate>Fri, 04 Dec 2009 05:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://rdist.root.org/?p=456#comment-5451</guid>
		<description>I think you&#039;re confused because you&#039;re trying to compare it to the length extension attack. This is a different attack. I said nothing about the length of m and m&#039; being different. For the case of auth tokens, the input message length is usually constant.

The attack is to create an internal collision of m and m&#039; before k is appended. At that point, the chaining variables are identical so adding k and the padding will result in identical final hashes. You are right in that this attack does not allow different lengths for m and m&#039;. However, this is not a serious limitation for the attack since you are choosing m, and thus can make it any length you want in order to match the eventual m&#039;.</description>
		<content:encoded><![CDATA[<p>I think you&#8217;re confused because you&#8217;re trying to compare it to the length extension attack. This is a different attack. I said nothing about the length of m and m&#8217; being different. For the case of auth tokens, the input message length is usually constant.</p>
<p>The attack is to create an internal collision of m and m&#8217; before k is appended. At that point, the chaining variables are identical so adding k and the padding will result in identical final hashes. You are right in that this attack does not allow different lengths for m and m&#8217;. However, this is not a serious limitation for the attack since you are choosing m, and thus can make it any length you want in order to match the eventual m&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: B-Con</title>
		<link>http://rdist.root.org/2009/10/29/stop-using-unsafe-keyed-hashes-use-hmac/#comment-5439</link>
		<dc:creator>B-Con</dc:creator>
		<pubDate>Thu, 12 Nov 2009 22:21:57 +0000</pubDate>
		<guid isPermaLink="false">http://rdist.root.org/?p=456#comment-5439</guid>
		<description>I&#039;m confused by the second method to defeat the hash(m &#124;&#124; k) scheme, because most hashes have length padding that is added to the end. Could you help clear this up?

If m and m&#039; have the same length, then the length padding for m &#124;&#124; k and m&#039; &#124;&#124; k will be the same and a collision with m and m&#039; will yeild a collision for m &#124;&#124; k and m&#039; &#124;&#124; k. However, if m and m&#039; have a different length then the length padding, AFAIK, will cause problems. Here is my reasoning:

Since the attacker can choose m and m&#039;, they can ensure that the hashes of m and m&#039;, including padding, are equal. This external collision relies on both m and m&#039; and their padding. But k is concatenated before the padding which means that the new padding for both will be altered. If the padding for both messages is altered then the collision is no longer gaurenteed. (Unless adding a constant to the pre-image of a collision preserves the collision.)

The paper explicitly requires an internal collision in order to make this attack work. But if the messages have different padding, then the hashes will be equal right up until the padding is added.

The attacker can compensate by (assuming he knows the length of k) adjusting the padding he uses to reflect a length of length(m &#124;&#124; k). He can then find a collision using the altered padding for m and m&#039;. But still, adding the key to the end of the message, but before the padding, cause the internal state to be different before processing the padding, which should yield different hashes.

I&#039;ve read the paper by Preneel that you linked to, and it seems as if the problem I mention is because MD5 and SHA1 are not &quot;pure&quot; Merkle–Damgård constructions. The paper defines the &quot;iterative&quot; hash functions to be (from pg. 4):

H_0 = IV; H_i = f(H_{i-1},m_i), 1 &lt;= i &lt;= t ; hash(m) = H_t

and in the case of a MAC:

hash(m) = g(H_t)

However, for a function that includes length padding, this seems to be more like:

hash(m) = g(H_t,l(m))

because the final transform is a function of both the last block and the entire message (which is the length of the entire message).

Am I missing something here? This second method of attack against hash(m &#124;&#124; k) only seems to work for substituting m&#039; of equal length to m when dealing with hashes like SHA or MD5.</description>
		<content:encoded><![CDATA[<p>I&#8217;m confused by the second method to defeat the hash(m || k) scheme, because most hashes have length padding that is added to the end. Could you help clear this up?</p>
<p>If m and m&#8217; have the same length, then the length padding for m || k and m&#8217; || k will be the same and a collision with m and m&#8217; will yeild a collision for m || k and m&#8217; || k. However, if m and m&#8217; have a different length then the length padding, AFAIK, will cause problems. Here is my reasoning:</p>
<p>Since the attacker can choose m and m&#8217;, they can ensure that the hashes of m and m&#8217;, including padding, are equal. This external collision relies on both m and m&#8217; and their padding. But k is concatenated before the padding which means that the new padding for both will be altered. If the padding for both messages is altered then the collision is no longer gaurenteed. (Unless adding a constant to the pre-image of a collision preserves the collision.)</p>
<p>The paper explicitly requires an internal collision in order to make this attack work. But if the messages have different padding, then the hashes will be equal right up until the padding is added.</p>
<p>The attacker can compensate by (assuming he knows the length of k) adjusting the padding he uses to reflect a length of length(m || k). He can then find a collision using the altered padding for m and m&#8217;. But still, adding the key to the end of the message, but before the padding, cause the internal state to be different before processing the padding, which should yield different hashes.</p>
<p>I&#8217;ve read the paper by Preneel that you linked to, and it seems as if the problem I mention is because MD5 and SHA1 are not &#8220;pure&#8221; Merkle–Damgård constructions. The paper defines the &#8220;iterative&#8221; hash functions to be (from pg. 4):</p>
<p>H_0 = IV; H_i = f(H_{i-1},m_i), 1 &lt;= i &lt;= t ; hash(m) = H_t</p>
<p>and in the case of a MAC:</p>
<p>hash(m) = g(H_t)</p>
<p>However, for a function that includes length padding, this seems to be more like:</p>
<p>hash(m) = g(H_t,l(m))</p>
<p>because the final transform is a function of both the last block and the entire message (which is the length of the entire message).</p>
<p>Am I missing something here? This second method of attack against hash(m || k) only seems to work for substituting m&#039; of equal length to m when dealing with hashes like SHA or MD5.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
