Pages:
Author

Topic: A public service announcement - page 2. (Read 3817 times)

legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 03:10:15 PM
#23
This is what hashes were designed to do.

No. They are designed to quickly compute a mostly unique digest for a preimage.

Quote from: ShadowOfHarbringer
[image]

Can you please stop talking "I'm smarter than you and I know better" bullshit and show me the difference between bcrypt() and my algo ?
Because sorry - there isn't any according to PHP manual.


----
EDIT2:
Investingating the matter further, actually it seems that my function far better than crypt(), as it uses different salt for each layer of hashing, where crypt() only uses single salt for all layers.

----
EDIT:
OK, i have had enough of this.
Only a fool uses the argument of power instead of power of arguments.

So you either show me the logical evidence that you are correct, or I will officially view you as a fool. I dare you.
sr. member
Activity: 252
Merit: 250
September 11, 2011, 03:06:06 PM
#22
This is what hashes were designed to do.

No. They are designed to quickly compute a mostly unique digest for a preimage.

Quote from: ShadowOfHarbringer

legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 02:45:38 PM
#21
Here ya go:

Code:
define('CNF_PASSWORD_SALT1', 'fvuiyt8635t394nng'); //Change this to some random stuff
define('CNF_PASSWORD_SALT2', 'sdfkofuhnA%^%^23J'); //Change this to some random stuff

define('CNF_PASSWORD_HASH0', 'sha512');
define('CNF_PASSWORD_HASH1', 'whirlpool');
define('CNF_PASSWORD_HASH2', 'sha512');

//20 rounds by default. Change to more if more security is required
define('CNF_PASSWORD_EXTRA_ROUNDS', 20);


class HashPassword {

protected static $level0PassHash = null;
protected static $level1PassHash = null;
protected static $level2PassHash = null;

protected static $defaultHashRounds = null;

protected static function _init(){
self::$level0PassHash = CNF_PASSWORD_HASH0;
self::$level1PassHash = CNF_PASSWORD_HASH1;
self::$level2PassHash = CNF_PASSWORD_HASH2;

self::$defaultHashRounds = CNF_PASSWORD_EXTRA_ROUNDS;
}

public static function Make($inputData, $extraSalt = false, $extraRounds = false) {
if (!isset(self::$level0PassHash)){
self::_init();
}

if ($extraRounds === false) {
$extraRounds = self::$defaultHashRounds;
}

if ($extraRounds > 0) {//More rounds through recursion
$halfStringPos = floor(strlen($inputData) / 2);
$inputData = substr($inputData, $halfStringPos) . substr($inputData, 0, $halfStringPos); //This shifts the string on each round -  '123456' into '456123' etc.
$inputData = self::Make($inputData, $extraSalt, $extraRounds - 1); // Recursion
}

$hashLevel0 = $extraSalt ?
hash(self::$level0PassHash, $extraSalt.$inputData.$extraSalt) :
hash(self::$level0PassHash, $inputData);

$hashLevel1 = hash(self::$level1PassHash, CNF_PASSWORD_SALT1.$inputData.CNF_PASSWORD_SALT1);

$output = hash(self::$level2PassHash, CNF_PASSWORD_SALT2.$hashLevel0.CNF_PASSWORD_SALT2);

return $output;
}

}

3 layered hashing, different salt on each layer. Level 3 salting is optional.

There are 3 smaller rounds in a single big round, so a total of 20 rounds (default) gives you 60 salted hashing rounds in total for a single password. Benchmark your scripts and change the number of rounds depending of the power of your servers. Too many rounds can clog up the server as users logging in massively will use a lot of CPU.

20 big rounds should be enough for everyone for starters.

Usage:
Code:
HashPassword::Make($data, [optional] $additionalLevel3Salt = null, [optional] $changeNumberOfRounds = 20);

If you want some serious security, put (for example) user's registration date (or anything else generated randomly on registration) into the $additionalLevel3Salt parameter. It will make rainbow tables attack unfeasible.

This is a production - grade code. It should work without any modifications.


License:
WTFPL License, http://en.wikipedia.org/wiki/WTFPL



---------------------
EDIT:
Also, there is a useful list of different hashing algorithms' speed on php.net

Performance test results on my laptop:
Results are here shorten to fit php web notes ...
This was tested with 1024000 bytes (1000 KB) of random data, md4 always gets the first place, and md2 always get the last place Smiley

Results: (in microseconds)
   1.  md4                           5307.912
   2.  md5                           6890.058
   3.  crc32b                        7298.946
   4.  crc32                         7561.922
   5.  sha1                          8886.098
   6.  tiger128,3                    11054.992
   7.  haval192,3                    11132.955
   8.  haval224,3                    11160.135
   9.  tiger160,3                    11162.996
  10.  haval160,3                    11242.151
  11.  haval256,3                    11327.981
  12.  tiger192,3                    11630.058
  13.  haval128,3                    11880.874
  14.  tiger192,4                    14776.945
  15.  tiger128,4                    14871.12
  16.  tiger160,4                    14946.937
  17.  haval160,4                    15661.954
  18.  haval192,4                    15717.029
  19.  haval256,4                    15759.944
  20.  adler32                       15796.184
  21.  haval128,4                    15887.022
  22.  haval224,4                    16047.954
  23.  ripemd256                     16245.126
  24.  haval160,5                    17818.927
  25.  haval128,5                    17887.115
  26.  haval224,5                    18085.002
  27.  haval192,5                    18135.07
  28.  haval256,5                    18678.903
  29.  sha256                        19020.08
  30.  ripemd128                     20671.844
  31.  ripemd160                     21853.923
  32.  ripemd320                     22425.889
  33.  sha384                        45102.119
  34.  sha512                        45655.965
  35.  gost                          57237.148
  36.  whirlpool                     64682.96
  37.  snefru                        80352.783
  38.  md2                           705397.844

Plus the lengths of hashes produced by each of the algos:

Quote
md2           32
md4           32
md5           32
sha1          40
sha256        64
sha384        96
sha512       128
ripemd128     32
ripemd160     40
ripemd256     64
ripemd320     80
whirlpool    128
tiger128,3    32
tiger160,3    40
tiger192,3    48
tiger128,4    32
tiger160,4    40
tiger192,4    48
snefru        64
gost          64
adler32        8
crc32          8
crc32b         8
haval128,3    32
haval160,3    40
haval192,3    48
haval224,3    56
haval256,3    64
haval128,4    32
haval160,4    40
haval192,4    48
haval224,4    56
haval256,4    64
haval128,5    32
haval160,5    40
haval192,5    48
haval224,5    56
haval256,5    64


Have fun.
legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 02:13:44 PM
#20
If you create a modification for SMF that uses advanced password hashing and gracefully upgrades from old hash types, I will use it.

Bcrypt is probably fine, though I tend to prefer many iterations of traditional hash algorithms. This is what hashes were designed to do. PGP does it, and it's used in many crypto standards.

I can supply the hashing algorithm, as I have already written it.
Give me half an hour, i need to start up the laptop and find it.
administrator
Activity: 5222
Merit: 13032
September 11, 2011, 01:37:47 PM
#19
If you create a modification for SMF that uses advanced password hashing and gracefully upgrades from old hash types, I will use it.

Bcrypt is probably fine, though I tend to prefer many iterations of traditional hash algorithms. This is what hashes were designed to do. PGP does it, and it's used in many crypto standards.
legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 10:28:45 AM
#18
I studied the topic a little more:

Here is the description of the crypt() function from PHP manual, which was specified in the article "Use Bcrypt Fool":

Description
string crypt ( string $str [, string $salt ] )

crypt() will return a hashed string using the standard Unix DES-based algorithm or alternative algorithms that may be available on the system.

Some operating systems support more than one type of hash. In fact, sometimes the standard DES-based algorithm is replaced by an MD5-based algorithm. The hash type is triggered by the salt argument. Prior to 5.3, PHP would determine the available algorithms at install-time based on the system's crypt(). If no salt is provided, PHP will auto-generate either a standard two character (DES) salt, or a twelve character (MD5), depending on the availability of MD5 crypt(). PHP sets a constant named CRYPT_SALT_LENGTH which indicates the longest valid salt allowed by the available hashes.

The standard DES-based crypt() returns the salt as the first two characters of the output. It also only uses the first eight characters of str, so longer strings that start with the same eight characters will generate the same result (when the same salt is used).

On systems where the crypt() function supports multiple hash types, the following constants are set to 0 or 1 depending on whether the given type is available:

    CRYPT_STD_DES - Standard DES-based hash with a two character salt from the alphabet "./0-9A-Za-z". Using invalid characters in the salt will cause crypt() to fail.
    CRYPT_EXT_DES - Extended DES-based hash. The "salt" is a 9-character string consisting of an underscore followed by 4 bytes of iteration count and 4 bytes of salt. These are encoded as printable characters, 6 bits per character, least significant character first. The values 0 to 63 are encoded as "./0-9A-Za-z". Using invalid characters in the salt will cause crypt() to fail.
    CRYPT_MD5 - MD5 hashing with a twelve character salt starting with $1$
    CRYPT_BLOWFISH - Blowfish hashing with a salt as follows: "$2a$", a two digit cost parameter, "$", and 22 digits from the alphabet "./0-9A-Za-z". Using characters outside of this range in the salt will cause crypt() to return a zero-length string. The two digit cost parameter is the base-2 logarithm of the iteration count for the underlying Blowfish-based hashing algorithmeter and must be in range 04-31, values outside this range will cause crypt() to fail.
    CRYPT_SHA256 - SHA-256 hash with a sixteen character salt prefixed with $5$. If the salt string starts with 'rounds=$', the numeric value of N is used to indicate how many times the hashing loop should be executed, much like the cost parameter on Blowfish. The default number of rounds is 5000, there is a minimum of 1000 and a maximum of 999,999,999. Any selection of N outside this range will be truncated to the nearest limit.
    CRYPT_SHA512 - SHA-512 hash with a sixteen character salt prefixed with $6$. If the salt string starts with 'rounds=$', the numeric value of N is used to indicate how many times the hashing loop should be executed, much like the cost parameter on Blowfish. The default number of rounds is 5000, there is a minimum of 1000 and a maximum of 999,999,999. Any selection of N outside this range will be truncated to the nearest limit.


Then basically, what crypt() function does, is multiple salted rounds of hashing.

So can somebody explain to me what is the difference between bcrypt and my algorithm ?

Code:
hash_algo1(salt1 + hash_algo2(salt2 + hash_algo3(salt3 + data))) * N recursive rounds

Because, seriously - I cannot find one.
legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 10:21:06 AM
#17
Glorious.

I am not finished.
I can also increase the entropy by using extra secret field from the database PLUS the user's registration date which is also needed to generate the final hash.

So the entropy is not low (like in the examples shown here) anywhere within the hashing process.
sr. member
Activity: 350
Merit: 251
September 11, 2011, 10:13:11 AM
#16
i still think bcrypt is stupid because i refuse to change my ways, you will never change me, you communist.


yes its a joke.
sr. member
Activity: 252
Merit: 250
September 11, 2011, 10:09:15 AM
#15


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.

I am a programmer from 14 years, and FYI, i have written some stron cryptography myself from scratch.
So stop talking bullshit.



Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.

Wait, just let me get something straight before i continue this discussion.

If i generate a password hash using bcrypt with X rounds, and then i increase it to Y rounds, will both functions generate the same hash ?

I mean is bcrypt(pwd, rounds = 10, salt) equal to bcrypt(pwd, rounds = 20, salt) ?

Am I understanding this correctly ?

id assume no, or else it would be pointless to increase round time.

If no is the answer, then there is completely no advantage of using bcrypt versus multi hashes with multi salt as I have already written a recurrent function which does exactly the same as bcrypt().

You simply use the_hash_function($data, salt1, salt2, salt3, rounds) and basically what it does is it recurrently repeats

Code:
hash_algo1(salt1 + hash_algo2(salt2 + hash_algo3(salt3 + data))) 

for X number of rounds, each time salting everything again.

Once the hardware becomes more powerful, i can simply increase the number of rounds to Y.

Glorious. Way to miss the point of this fundamental concept.
sr. member
Activity: 350
Merit: 251
September 11, 2011, 10:08:41 AM
#14


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.

I am a programmer from 14 years, and FYI, i have written some stron cryptography myself from scratch.
So stop talking bullshit.



Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.

Wait, just let me get something straight before i continue this discussion.

If i generate a password hash using bcrypt with X rounds, and then i increase it to Y rounds, will both functions generate the same hash ?

I mean is bcrypt(pwd, rounds = 10, salt) equal to bcrypt(pwd, rounds = 20, salt) ?

Am I understanding this correctly ?

id assume no, or else it would be pointless to increase round time.

If no is the answer, then there is completely no advantage of using bcrypt versus multi hashes with multi salt as I have already written a recurrent function which does exactly the same as bcrypt().

You simply use the_hash_function($data, salt1, salt2, salt3, rounds) and basically what it does is it recurrently repeats

Code:
hash_algo1(salt1 + hash_algo2(salt2 + hash_algo3(salt3 + data))) 

for X number of rounds, each time salting everything again.

Once the hardware becomes more powerful, i can simply increase the number of rounds to Y.

he said it uses a slow key schedule, so i dont think this is the same thing if you are using traditional hashing.
legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 10:05:56 AM
#13


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.

I am a programmer from 14 years, and FYI, i have written some stron cryptography myself from scratch.
So stop talking bullshit.



Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.

Wait, just let me get something straight before i continue this discussion.

If i generate a password hash using bcrypt with X rounds, and then i increase it to Y rounds, will both functions generate the same hash ?

I mean is bcrypt(pwd, rounds = 10, salt) equal to bcrypt(pwd, rounds = 20, salt) ?

Am I understanding this correctly ?

id assume no, or else it would be pointless to increase round time.

If no is the answer, then there is completely no advantage of using bcrypt versus multi hashes with multi salt as I have already written a recurrent function which does exactly the same as bcrypt().

You simply use the_hash_function($data, salt1, salt2, salt3, rounds) and basically what it does is it recurrently repeats

Code:
hash_algo1(salt1 + hash_algo2(salt2 + hash_algo3(salt3 + data))) 

for X number of rounds, each time salting everything again.

Once the hardware becomes more powerful, i can simply increase the number of rounds to Y.
sr. member
Activity: 252
Merit: 250
September 11, 2011, 10:05:05 AM
#12


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.

I am a programmer from 14 years, and FYI, i have written from scratch strong cryptography algorithms myself.
So please stop talking bullshit and let's have a real discussion other than "BCRYPT FTW, IF YOU DON'T THINK SO, STFU".

Scary... but doubtful.



Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.

Wait, just let me get something straight before i continue this discussion.

If i generate a password hash using bcrypt with X rounds, and then i increase it to Y rounds, will both functions generate the same hash ?

I mean is bcrypt(pwd, rounds = 10, salt) equal to bcrypt(pwd, rounds = 20, salt) ?

Am I understanding this correctly ?

No. Try reading the links. Also, bcrypt doesn't use "rounds" as a means to be slow. It has a slow key schedule.
sr. member
Activity: 350
Merit: 251
September 11, 2011, 10:00:55 AM
#11


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.

I am a programmer from 14 years, and FYI, i have written some stron cryptography myself from scratch.
So stop talking bullshit.



Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.

Wait, just let me get something straight before i continue this discussion.

If i generate a password hash using bcrypt with X rounds, and then i increase it to Y rounds, will both functions generate the same hash ?

I mean is bcrypt(pwd, rounds = 10, salt) equal to bcrypt(pwd, rounds = 20, salt) ?

Am I understanding this correctly ?

id assume no, or else it would be pointless to increase round time.
legendary
Activity: 1470
Merit: 1006
Bringing Legendary Har® to you since 1952
September 11, 2011, 09:57:32 AM
#10


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.

I have been a programmer for 14 years, and FYI, i have written from scratch strong cryptography algorithms myself.
So please stop talking bullshit and let's have a real discussion other than "BCRYPT FTW, IF YOU DON'T THINK SO, STFU".



Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.

Wait, just let me get something straight before i continue this discussion.

If i generate a password hash using bcrypt with X rounds, and then i increase it to Y rounds, will both functions generate the same hash ?

I mean is bcrypt(pwd, rounds = 10, salt) equal to bcrypt(pwd, rounds = 20, salt) ?

Am I understanding this correctly ?
sr. member
Activity: 350
Merit: 251
September 11, 2011, 09:51:25 AM
#9
heres an idea that might sound crazy, but what if we all used secure passwords? sure hashing as some weaknesses, but it allows for you to log in fast, and if you use a good password and a salt you should be good, as i dont think any huge company handling huge volumes of traffic would use that algorithm, simply because they do not have the required amount of processing power to keep the passwords secure and a reasonable login time.

Wrong threat model. Read this link:
http://codahale.com/how-to-safely-store-a-password/

the link contains no information i didnt already know, again, a 64cha hexadecimal password will take a really long time according to https://www.grc.com/haystack.htm . assuming the hashing algorithm isnt found to be insecure or something. hell, acording to grc, "thecowsaysmoo" would take months to crack, id consider that relatively safe, sure over time it becomes more insecure, but it does not have all the drawbacks of bcrypt. its probably fine for personal use, but once you get thousands of people logging on at the same time, that's a thousand seconds worth of computing time you need.
sr. member
Activity: 252
Merit: 250
September 11, 2011, 09:43:14 AM
#8
heres an idea that might sound crazy, but what if we all used secure passwords? sure hashing as some weaknesses, but it allows for you to log in fast, and if you use a good password and a salt you should be good, as i dont think any huge company handling huge volumes of traffic would use that algorithm, simply because they do not have the required amount of processing power to keep the passwords secure and a reasonable login time.

Wrong threat model. Read this link:
http://codahale.com/how-to-safely-store-a-password/
sr. member
Activity: 350
Merit: 251
September 11, 2011, 09:34:01 AM
#7
heres an idea that might sound crazy, but what if we all used secure passwords? sure hashing as some weaknesses, but it allows for you to log in fast, and if you use a good password and a salt you should be good, as i dont think any huge company handling huge volumes of traffic would use that algorithm, simply because they do not have the required amount of processing power to keep the passwords secure and a reasonable login time.
sr. member
Activity: 252
Merit: 250
September 11, 2011, 08:40:15 AM
#6
Some real programmers, please chime in.

That must mean you are not a real programmer also and are nothing more than a parrot that can only repeat stuff without even understand what he's saying, right?

I won't presume to call myself and expert in web programming, but I have experience in certain fields going back more than 10 years. At the very least, I do know how to protect a local password database.

For those who refuse to read linked texts (lazy TL;DR crowd), let me quote a portion of it:
Quote
To cut a long story short, hashing a hash N times doesn't make your passwords more secure and can actually make it less secure as a hacker can quite easily reverse the process by generating hash collisions.

[...]

It has already been mentioned before but the solution is to use an algorithm called "BCrypt". BCrypt is a hashing algorithm based on Blowfish with a small twist: it keeps up with Moore's law. The idea of BCrypt is quite simple, don't just use regular characters (and thus increasing the entropy) and make sure password X always takes the same amount of time regardless of how powerful the hardware is that's used to generate X. I'm not going to cover all the technical details but basically BCrypt requires you to specify a cost/workfactor in order to generate a password. This workfactor not only makes the entire process slower but is also used to generate the end hash. This means that if somebody were to change the workfactor the hash would also be different. In other words, hackers, you're fucked. In order for a hacker to gain the original password he must use the same workfactor and thus has to wait N times longer than when not using a workfactor.

It might be useful to avoid problems which have long ago been solved. Simple things like using proper functions and understanding programming interfaces makes life much easier and keeps us from embarassing situations like MTGOX and others repeatedly keep finding themselves in.
full member
Activity: 143
Merit: 101
September 11, 2011, 08:22:51 AM
#5


Totally wrong. Basically, all of your "advice" is garbage.

Some real programmers, please chime in.
You should be using bcrypt().
Not whatever many rounds of hashing.

Hashing is meant for huge amounts of data (such as files) and is meant to run fast - which means it can be bruteforced fast.

By using bcrypt with a high work factor, logins take one second to process - and bruteforcing takes one second per hash as opposed to 10 billion hashes per second.
legendary
Activity: 1358
Merit: 1002
September 11, 2011, 08:18:28 AM
#4
Some real programmers, please chime in.

That must mean you are not a real programmer also and are nothing more than a parrot that can only repeat stuff without even understand what he's saying, right?
Pages:
Jump to: