At the login page you could do a check on the length of the database field returned (md5 is shorter than sha256), and since you have the cleartext password at that point you can recompute the new hash after comparing it to the md5($cleartext) to see if it matched.<br>
<br>
<div class="gmail_quote">On Tue, Mar 11, 2008 at 2:04 AM, Mark Wu &lt;<a href="mailto:markplace@gmail.com">markplace@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div dir="ltr" align="left"><font face="新細明體"><font color="#0000ff"><font size="2"><span>** </span>sha2($salt + sha2($password + $salt))</font></font></font></div>
<div dir="ltr" align="left"><font face="新細明體" color="#0000ff" size="2"></font>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">I consider this before, the problem is I have to keep the compatibility.</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">In lieftype 1.2.x and before, the $password is stored in database with md5($password)...</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">So, any algorithm have to based on this, like</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">sha2($salt + md5($password) + sha2($salt))&nbsp; or</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">sha2(md5($password) + $private_key)</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">Or, there is no way for us to upgrade.... since we can not get the original plain text password</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">Unless we leave an option for user( administrator)&nbsp;to use the old algorithm.</font></span></div>
<div><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div><span><font face="新細明體" color="#0000ff" size="2">Mark</font></span></div>
<div dir="ltr" align="left"><br></div>
<blockquote style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<div lang="zh-tw" dir="ltr" align="left">
<hr>
<font face="Tahoma" size="2">
<div class="Ih2E3d"><b>From:</b> <a href="mailto:plog-svn-bounces@devel.lifetype.net" target="_blank">plog-svn-bounces@devel.lifetype.net</a> [mailto:<a href="mailto:plog-svn-bounces@devel.lifetype.net" target="_blank">plog-svn-bounces@devel.lifetype.net</a>] <b>On Behalf Of </b>Matt Wood<br>
</div><b>Sent:</b> Tuesday, March 11, 2008 1:49 PM 
<div>
<div></div>
<div class="Wj3C7c"><br><b>To:</b> LifeType Developer List<br><b>Subject:</b> Re: [pLog-svn] Salted MD5<br></div></div></font><br></div>
<div>
<div></div>
<div class="Wj3C7c">
<div></div>
<div>From a cryptographic standpoint, since sha256 has a larger byte output, there are situations where the md5 calculation will actually reduce the number of bytes of &quot;randomness&quot; (entropy).&nbsp;And since we&#39;re talking about a WebApp here... not a high speed&nbsp;wireless encryption scheme, why not just use sha256 all the way through? Same for the salt, if it contains a sufficient amount of entropy.</div>

<div>&nbsp;</div>
<div>And to clairify what I said about the salt before... simply adding a salt will defeat rainbow attacks as Reto has already said, the added complexity of using a &quot;hash function&quot;, of any kind, on the salt, does not significantly impact a dedicated attacker. Because in the situation of a database compromise the salt (which is assumably stored in the database, per user, and of sufficient entropy) has already been revealed, and the hash of it simply needs to be calculated once for the brute force attack on the password.</div>

<div>&nbsp;</div>
<div>Either way, the salt is a good addition. I&#39;m pleased you guys are so proactive about security.</div>
<div>&nbsp;</div>
<div>However, if you are wishing to increase the security (time to&nbsp;brute force)&nbsp;of the password/salt entry it may be worthwhile to follow the following algorithm instead.</div>
<div>&nbsp;</div>
<div>sha2($salt + sha2($password + $salt))</div>
<div>&nbsp;</div>
<div>you can repeat that ad-naseum increasing the complexity of the brute force by&nbsp;forcing the attacker to follow the chained hash algorithm in their brute forcing attempts. You can even add multiple salts... Just don&#39;t store the final hash in the HTTP cookie like some of these other blogging platforms...<br>
</div>
<div class="gmail_quote">On Tue, Mar 11, 2008 at 12:04 AM, Mark Wu &lt;<a href="mailto:markplace@gmail.com" target="_blank">markplace@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">That&#39;s why I use (MD5($password)+MD5($salt)) to keep it easy to upgrade.</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">And use sha256() to enhence the security level.</font></span></div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font face="新細明體" color="#0000ff" size="2">Mark</font></span></div><br>
<blockquote style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<div lang="zh-tw" dir="ltr" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> <a href="mailto:plog-svn-bounces@devel.lifetype.net" target="_blank">plog-svn-bounces@devel.lifetype.net</a> [mailto:<a href="mailto:plog-svn-bounces@devel.lifetype.net" target="_blank">plog-svn-bounces@devel.lifetype.net</a>] <b>On Behalf Of </b>Matt Wood<br>
<b>Sent:</b> Tuesday, March 11, 2008 3:23 AM 
<div>
<div></div>
<div><br><b>To:</b> LifeType Developer List<br><b>Subject:</b> Re: [pLog-svn] Salted MD5<br></div></div></font><br></div>
<div>
<div></div>
<div>
<div></div>The only reason you would salt passwords in a database means your concerned that the password db table has been compromised... if you fear that has happened then the salt that your storing in the database is available to the attacker. Thus adding md5 or sha1 or sha256 of that salt to the password is no more secure than just appending the salt in plaintext. The same number of computations will be required to &quot;crack&quot; the password hash.<br>
<br>-Matt<br><br>PS. md5/sha1 are not cryptographically secure hash algorithms anymore (however probably are ok for this situation). any sha2 algorithm (sha256, sha512) is suposedly.<br><br>
<div class="gmail_quote">On Mon, Mar 10, 2008 at 11:32 AM, Mark Wu &lt;<a href="mailto:markplace@gmail.com" target="_blank">markplace@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; How much more secure is than simply:<br>&gt;<br>&gt; md5($password . $private_key)<br><br></div>Actually, it&#39;s no difference for normal people, but much secure for those<br>hackers...<br><br>BTW, VBB and IPB use:<br>
<br>md5(md5($password).md5($private_key))<br>
<div><br>&gt;<br>&gt; And are there any downsides of the new method - ie. will it<br>&gt; fail on upgrades, or fail for certain servers, etc?<br>&gt;<br><br></div>mmm .... for lifetype 2.0 . The minimal requirement is php 5.1.x ...<br>
<br>so, It won&#39;t be a problem.<br><br>mhash become &quot;hash&quot; in pecl in php5, if there is no hash installed, it will<br>use the pure php &nbsp;implementation...<br>
<div>
<div></div>
<div><br>&gt;<br>&gt; On Mon, 10 Mar 2008, Mark Wu wrote:<br>&gt;<br>&gt; &gt; Here comes more secure algorithm:<br>&gt; &gt;<br>&gt; &gt; sha256(md5($password)+md5($your_provide_private_key));<br>&gt; &gt;<br>&gt; &gt; I use sha256 here.<br>
&gt; &gt;<br>&gt; &gt; Here also comes the pure php sha256 implementation:<br>&gt; &gt;<br>&gt; &gt; <a href="http://nanolink.ca/pub/sha256/" target="_blank">http://nanolink.ca/pub/sha256/</a><br>&gt; &gt;<br>&gt; &gt; If the server has &quot;hash&quot; pecl, it will use it instead of<br>
&gt; the pure one.<br>&gt; &gt;<br>&gt; &gt; Mark<br>&gt; &gt;<br>&gt; &gt;&gt; -----Original Message-----<br>&gt; &gt;&gt; From: <a href="mailto:plog-svn-bounces@devel.lifetype.net" target="_blank">plog-svn-bounces@devel.lifetype.net</a><br>
&gt; &gt;&gt; [mailto:<a href="mailto:plog-svn-bounces@devel.lifetype.net" target="_blank">plog-svn-bounces@devel.lifetype.net</a>] On Behalf Of Reto Hugi<br>&gt; &gt;&gt; Sent: Monday, March 10, 2008 7:25 PM<br>&gt; &gt;&gt; To: LifeType Developer List<br>
&gt; &gt;&gt; Subject: Re: [pLog-svn] Salted MD5<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Hi Mark<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; I welcome your suggestion and think that this is valuable<br>&gt; &gt;&gt; protection against rainbow table attacks.<br>
&gt; &gt;&gt;<br>&gt; &gt;&gt; We already had an issue with the revealed admin password<br>&gt; &gt;&gt; hash. This would have been less severe with the saltet md5.<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Thanks for suggesting!<br>
&gt; &gt;&gt;<br>&gt; &gt;&gt; reto<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Mark Wu wrote:<br>&gt; &gt;&gt;&gt; Hi All:<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; I plan to upgrade our password algorithm to salted MD5, take the<br>
&gt; &gt;&gt;&gt; following for eaxample:<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; sha1(md5($password) + user_defined_private_key);<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; I will also remain an option in lifetype admin panel for<br>
&gt; &gt;&gt; user to use<br>&gt; &gt;&gt;&gt; the old MD5 way to keep compatability.<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; If we use the algorithm above, It is also possible to<br>&gt; &gt;&gt; convert the old<br>&gt; &gt;&gt;&gt; hashed password to new hased password.<br>
&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; How do you think?<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;<br>&gt; <a href="http://kuza55.blogspot.com/2006/10/online-reverse-lookup-tables-for.ht" target="_blank">http://kuza55.blogspot.com/2006/10/online-reverse-lookup-tables-for.ht</a><br>
&gt; &gt;&gt;&gt; ml<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; These kind of online reverse lookup table sites making<br>&gt; the MD5 only<br>&gt; &gt;&gt;&gt; algorithm more dangerous.<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; Mark<br>
&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;<br>&gt; ----------------------------------------------------------------------<br>&gt; &gt;&gt;&gt; --<br>
&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; _______________________________________________<br>&gt; &gt;&gt;&gt; pLog-svn mailing list<br>&gt; &gt;&gt;&gt; <a href="mailto:pLog-svn@devel.lifetype.net" target="_blank">pLog-svn@devel.lifetype.net</a><br>
&gt; &gt;&gt;&gt; <a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br>&gt; &gt;&gt;<br>&gt; &gt;&gt; _______________________________________________<br>
&gt; &gt;&gt; pLog-svn mailing list<br>&gt; &gt;&gt; <a href="mailto:pLog-svn@devel.lifetype.net" target="_blank">pLog-svn@devel.lifetype.net</a><br>&gt; &gt;&gt; <a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br>
&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; pLog-svn mailing list<br>&gt; &gt; <a href="mailto:pLog-svn@devel.lifetype.net" target="_blank">pLog-svn@devel.lifetype.net</a><br>&gt; &gt; <a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br>
&gt; &gt;<br>&gt;<br>&gt; --<br>&gt; Jon Daley<br>&gt; <a href="http://jon.limedaley.com/" target="_blank">http://jon.limedaley.com/</a><br>&gt;<br>&gt; We are all made different, but we are all sinners.<br>&gt; -- Jim Herron<br>
&gt; _______________________________________________<br>&gt; pLog-svn mailing list<br>&gt; <a href="mailto:pLog-svn@devel.lifetype.net" target="_blank">pLog-svn@devel.lifetype.net</a><br>&gt; <a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br>
<br>_______________________________________________<br>pLog-svn mailing list<br><a href="mailto:pLog-svn@devel.lifetype.net" target="_blank">pLog-svn@devel.lifetype.net</a><br><a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br>
</div></div></blockquote></div><br></div></div></blockquote></div><br>_______________________________________________<br>pLog-svn mailing list<br><a href="mailto:pLog-svn@devel.lifetype.net" target="_blank">pLog-svn@devel.lifetype.net</a><br>
<a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br></blockquote></div><br></div></div></blockquote></div><br>_______________________________________________<br>
pLog-svn mailing list<br><a href="mailto:pLog-svn@devel.lifetype.net">pLog-svn@devel.lifetype.net</a><br><a href="http://limedaley.com/mailman/listinfo/plog-svn" target="_blank">http://limedaley.com/mailman/listinfo/plog-svn</a><br>
</blockquote></div><br>