![]() |
|
|
store salts as plaintext? where? |
|
Experienced Talker
Posts: 35
Location: kalamazoo
|
The link: http://www.webmaster-talk.com/php-fo...ht=store+salts is really informative. But I wonder: Where do you store the salts. If they're randomly generated, we can't reproduce the same ones at every user's login. So where and how do you store them?
Thank you, matt w |
|
|
|
| Sponsored Links (We share ad revenue): |
|
|
Re: store salts as plaintext? where? |
|
Fetchez la vache!
Latest Blog Post:
Pretty pretty please…. Posts: 1,689
Name: Thierry
Location: In the void
|
I like to generate them, from a mathematical formula over, say, the user ID.
It can fairly simple, but it will give a different one for each members of your tables, making it way harder to breach. Why not simply take the ascii value of the character and multiply it by pie (pi, py, pye ??? 3.1416 !!!). This alone is simple and don't need anything stored anywhere.
__________________
Listen to the ducky: "This is awesome!!!" |
|
|
|
|
|
Re: store salts as plaintext? where? |
|
Full-Time TeraTasker
Posts: 631
Name: Jeremy Miller
Location: Reno, NV
|
I store the salt in the same file as the DB config file or a master config file depending on the software. Oh, and I store it as a variable.
I suggest not using a salt based on an algorithm as tripy has suggested. Then, the security relies on no one being able to guess the algorithm instead of no one being able to guess the salt. Encryption should not rely on methodology.
__________________
Jeremy Miller - TeraTask Technologies, LLC Content Farmer - Automated Posting for Content & Blog Sites |
|
|
|
|
|
Re: store salts as plaintext? where? |
|
Will Code for Food
Posts: 459
Name: Matt
Location: Irvine, CA
|
I usually just store a different salt for each user in my database. When someone punches in the cooresponding username it checks the password they gave encrypted with the salt with the one in the database.
PHP Code:
PHP Code:
__________________
http://tinsology.com/ - Under construction Last edited by NullPointer : 05-08-2008 at 03:18 PM. |
|
|
|
|
|
Re: store salts as plaintext? where? |
|
Full-Time TeraTasker
Posts: 631
Name: Jeremy Miller
Location: Reno, NV
|
Sorry Inet, but you should NOT append your salt to the hashed value -- that defeats the whole point.
Let me illustrate: Hash 2 texts. Compare which characters are contiguously the same. Those characters are the salt. Then a dictionary attack will allow you to find the correct password (for simple passwords). Also, in Inet's code (again, no offense), the salt is either randomly generated (i.e. useless give the hack method I just explained) or stored elsewhere and passed to the function meaning that you still have to store it and you're back to step 1. Now, to say something positive, wrapping the hash seed in a function is another way of solving the problem. The code would look something like this: PHP Code:
__________________
Jeremy Miller - TeraTask Technologies, LLC Content Farmer - Automated Posting for Content & Blog Sites |
|
|
|
|
|
Re: store salts as plaintext? where? |
|
Full-Time TeraTasker
Posts: 631
Name: Jeremy Miller
Location: Reno, NV
|
Good point Rob. You're right there -- they would have to know the hash length. That wasn't immediately obvious to me when going through it the first time. The user would then need to have a clue about the hashing function (or write a brute force script -- not too much harder than writing a dictionary script given that hashing functions are well known and their lengths are known).
One note for everyone: hash functions are not permanently secure. 5 years ago, md5 was fine, but now 2 inputs with the same output have been found; same deal for sha1; same deal for any hash given enough time. Using a salt SIGNIFICANTLY increases the security, however. Thanks for the correction Rob. EDIT: I make "brute force" and "dictionary" hacks sound easy -- they are fairly easy to code, but that doesn't mean they solve the problem quickly; they could take years of work. In fact, the CIA uses such attacks by indexing every word on your computer and every word on every website you've visited and uses every computer in their system (including desktops) to try every possible combination of found words to try and hack you. That ends up being a LOT of computing power (think of the SETI screen saver program), but even then things take time.
__________________
Jeremy Miller - TeraTask Technologies, LLC Content Farmer - Automated Posting for Content & Blog Sites Last edited by JeremyMiller : 05-09-2008 at 10:54 PM. |
|
|
|
| Sponsored Links (We share ad revenue): |
| Thread Tools | |
|
|
| Webmaster Resources Marketplace: |
| Software Development Company | Webhosting.UK.com |
| Web Templates | Text Link Brokers | Stock Photos |