Hi
1DMF said:
Also, I assume they MD5 the username/pword string, and pass me the hash, how do I unhash it to know what user they are trying to log in and also check password.
The username should not be hashed. That is kind of public information anyway. ( Raise your hands who
not knows what is 1DMF's username on Tek-Tips. )
If you want, you can send that too as MD5 hash, but separately, not concatenated with the password and the challenge.
1DMF said:
Do I need to run some process which stores a user's credentials in the SQL DB as a MD5 hash, so I can then do a SQL lookup?
Yes, if you are sending the username too as MD5 hash, is better to store it in the database too.
Storing the password only as MD5 hash is the suggested way. ( By security maniacs anyway. ) However this makes things abit more complicated when a challenge comes into view.
For example having this data :
Code:
[navy]$username[/navy][teal]=[/teal][green][i]'1DMF'[/i][/green][teal];[/teal]
[navy]$password[/navy][teal]=[/teal][green][i]'padavan'[/i][/green][teal];[/teal]
[navy]$salt[/navy][teal]=[/teal][COLOR=darkgoldenrod]md5_hex[/color][teal]([/teal]time[teal].[/teal]$$[teal].[/teal][b]rand[/b][teal]);[/teal]
[navy]$passsalt[/navy][teal]=[/teal][COLOR=darkgoldenrod]md5_hex[/color][teal]([/teal][green][i]"$password $salt"[/i][/green][teal]);[/teal]
Code:
username | passsalt | salt
----------+----------------------------------+----------------------------------
1DMF | 3e205f67daf9d6d59d1ff9783926f882 | 9959c098f7c14b7ddf93624adac82b6f
[ul]
[li]server : thinks to a challenge [tt][navy]$challenge[/navy][teal]=[/teal]
md5_hex[teal]([/teal]time[teal].[/teal]$$[teal].[/teal]
rand[teal]);[/teal] [gray]# 2a560205dd7718ecc098a0a5e30acf35[/gray][/tt], stores the challenge locally, sends challenge and credential.salt to client[/li]
[li]client : calculates the password's hash [tt][navy]$passhash[/navy][teal]=[/teal]
md5_hex[teal]([/teal]
md5_hex[teal]([/teal][green]
"$password $salt"[/green][teal]).[/teal]" [navy]$challenge[/navy][teal]);[/teal] [gray]# f5da5e01262b6000ca39037882d8c364[/gray][/tt] and sends it to the server[/li]
[li]server : calculates the password's hash [tt][navy]$passhash[/navy][teal]=[/teal]
md5_hex[teal]([/teal][navy]$credential[/navy][teal]{[/teal][green]
'passalt'[/green][teal]}[/teal][teal].[/teal]" [navy]$challenge[/navy][teal]);[/teal] [gray]# f5da5e01262b6000ca39037882d8c364[/gray][/tt] and compares it with the one received from the client[/li]
[/ul]
This way the $password is neither sent or stored and the credential.passsalt is not sent over the network.
The above is based on Paul Johnston's removed article, Login System. Which was replaced by the less clear
Protecting Passwords.
As you can guess, the problem will be with the subscription. But I suppose that not affects you in this case.
Feherke.