Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 921584766B6 for ; Wed, 21 Aug 2002 22:22:16 -0400 (EDT) Received: from candle.pha.pa.us (216-55-132-35.dsl.san-diego.abac.net [216.55.132.35]) by postgresql.org (Postfix) with ESMTP id 0592547669B for ; Wed, 21 Aug 2002 22:22:14 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g7M2LiZ23553; Wed, 21 Aug 2002 22:21:44 -0400 (EDT) From: Bruce Momjian Message-Id: <200208220221.g7M2LiZ23553@candle.pha.pa.us> Subject: Re: OT: password encryption (salt theory) In-Reply-To: <20020821191821.1ba58982.Tim.Ellis@gamet.com> To: Tim Ellis Date: Wed, 21 Aug 2002 22:21:44 -0400 (EDT) Cc: "David F. Skoll" , fstefan@cable.vol.at, pgsql-admin@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/253 X-Sequence-Number: 5367 We use salt in our MD5 implementation. One is random and prevents playback of packets. The second is salt used for storage in pg_shadow. As long as the salt is visible to the user just like the MD5 version of the password, we don't see any advantage to a random salt. We use the username as our salt for storage just so that two people with the same password don't show the same MD5 output in pg_shadow. --------------------------------------------------------------------------- Tim Ellis wrote: > > But a straight md5sum leaves you open to a dictionary attack. > > Of course. I argue everything does. > > > You want > > to add some salt by doing something like this: > > > > salt = random_4_char_string; > > encrypted_password = salt + md5sum(salt + cleartext_password); > > I've always wondered about this. It just means for a dictionary attack, > instead of: > > if (encpass == md5sum (dictionaryword)) > > you do > > if (encpass == substr(encpass,4)+md5sum(substr(encpass,4)+dictionaryword)) > > Which obviously is just linearly slower than the normal dictionary attack. > > What is the purpose of the salt in this case? I can only assume the > standard documented of using a salt is wrong, because I've never seen an > implementation that I could see increased the security over plain > hashing. > > The only way I could see a salt increasing security is thusly: > > salt = SomeSuperSlowAlgorithm (password) > encpass = md5sum (salt + password) > > But you'd achieve as much by saying encpass=SuperSlowAlgo(password). > > No matter how you obfuscate it, unless you can somehow turn it into a > O(x^n) problem, you're prone to dictionary attacks. > > This is why most modern password-prompting algorithms do a "dictionary > attack" on your password and worn you. Witness: > > Changing password for user postgres. > New UNIX password: (I enter "greatone") > BAD PASSWORD: it is based on a dictionary word > > So basically, your only hope is to either obfuscate the argument you pass > to md5sum (or whatever hash algorithm), somehow protect your md5sum list > of passwords(note that the shadow password file on Unix systems isn't > world readable), or ensure that all passwords entered by all users are not > attackable by a dictionary attack. > > Can anyone explain to me why a salt is really a good idea or if, as I > suspect, it was an idea with good intentions that really doesn't help > anything? > > -- > Tim Ellis > Senior Database Architect > Gamet, Inc. > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073