title: Strong Algorithm for "resetting password" securely
body: <p>I'm working on developing a Strong Algorithm to reset passwords securely and looking for feedback from the User Community. Here's what I've come up with so far (with help from <a href="https://stackoverflow.com/questions/1066611/what-are-best-practices-for-activation-registration-password-reset-links-in-emai">What are best practices for activation/registration/password-reset links in emails with nonce</a>)</p>
  
  <p>Password Reset process works as follows:
    When a User requests that a "reset password link be emailed to them"...</p>
  
  <ol>
  <li>Generate a $<a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29" rel="nofollow noreferrer">salt</a></li>
  <li>Prompt the user for the $email address they want to have their "reset password" link sent to.</li>
  <li>Retrieve a $key (=secret user-predefined sensitive account data that only they know such as the city they were born in or SSN#Last4)</li>
  <li>Create $<a href="http://en.wikipedia.org/wiki/Cryptographic_nonce" rel="nofollow noreferrer">nonce</a> = hash($email . $key)</li>
  <li>Save to table: <ul>
      <li>$nonce (PK)</li>
      <li>$salt</li>
      <li>$exp_date</li></ul></li>
  <li>Create $hash =hash($salt . $email . $key)</li>
  <li>Email the user a link to reset their password @ URL=...?hash=$hash</li>
  </ol>
  
  <p>When the User clicks on the link we sent them, it brings them to a form:
       <ul><li>Enter $email</li>
       <li>Enter $newPassword</li>
       <li>Confirm $newPassword</li>
       <li>Prompt for Key Field... ie: "Enter the City you were born in:" Enter $key</li></ul></p>
  
  <p>When the User submits this form...</p>
  
  <ol><li>Retrieve $hash from the URL</li>
  <li>Recreate $nonce = hash($email . $key)</li>
  <li>Use $nonce to retrieve $salt from our table (if unexpired).</li>
  <li>If hash($salt . $email . $key) == $hash from URL, then the Validation is GOOD!, so we...
     Update the user's password in the database</li>
  <li>Otherwise, we refuse the attempt to change the password</li></ol>
  
  <p>Notes:</p>
  
  <ul><li>All $email and $key responses are trimmed & lower-cased before processing to avoid confusion.</li><li>Regular maintenance task sproc should periodically remove all expired nonces to keep the table clean</li></ul>
  
  <p>What do you think?</p>