Is this a secure implementation of password reset email?
What you describe looks secure to me, but excessively complicated.  The following simpler procedure should suffice:

When a password reset token is requested:


Generate a secure random token and save it (or a cryptographic hash of it) in the database, along with a timestamp.  Overwrite the previous token, if any.
Send the token to the user by e-mail (suitably encoded).


When the user submits a token:


Check that it matches the token in the database, and that the corresponding timestamp is not too old.


The only part of the process which needs to involve any cryptography at all is generating the random token, and optionally hashing it.  You can usually offload the former task to the OS; on Unixish systems, for example, you can read the token from /dev/urandom.  Alternatively, if you're using a decent crypto library, it should provide a routine for generating secure random numbers (which may call the OS random number generator internally).



Ps. The one situation where you might want to go with a more crypto-heavy solution would be if you didn't have access to a convenient database for storing the tokens.  In that case, you could, for example, compute the token as MACK(userid || timestamp), where MACK is a message authentication code keyed by the secret key K, and have the user submit the timestamp along with the token.  (You could also include a random number in the MAC input, but that's not really necessary &mdash; without the key K, an attacker won't be able to forge the MAC.)  However, since you do have a database available, this doesn't really apply.