Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 2E4EAB5DC40 for ; Thu, 27 Oct 2011 18:20:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 21146-04 for ; Thu, 27 Oct 2011 21:20:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from momjian.us (momjian.us [72.94.173.45]) by mail.postgresql.org (Postfix) with ESMTP id A73AAB5DC25 for ; Thu, 27 Oct 2011 18:20:22 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p9RKsKs18362; Thu, 27 Oct 2011 16:54:20 -0400 (EDT) From: Bruce Momjian Message-Id: <201110272054.p9RKsKs18362@momjian.us> Subject: Re: Algorithm for generating md5 encrypted password not found in documentation In-Reply-To: To: Derrick Rice Date: Thu, 27 Oct 2011 16:54:20 -0400 (EDT) CC: Fred Cox , "pgsql-docs@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/65 X-Sequence-Number: 7065 Derrick Rice wrote: > On Thu, Oct 20, 2011 at 9:56 AM, Derrick Rice wrote: > > If I recall correctly, it's the username and the password concatenated > > and md5'd, then "md5" prepended. > > > > USER=... > > PASS=... > > MD5=`echo $USER$PASS | md5sum | cut -d' ' -f1` > > echo "md5$MD5" > > Figures I send the email then discover a small mistake. > > It's password first. So change $USER$PASS to $PASS$USER We did document this for 9.2: http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#AEN92524 AuthenticationMD5Password The frontend must now send a PasswordMessage containing the password (with username) encrypted via MD5, then encrypted again using the 4-byte random salt specified in the AuthenticationMD5Password message. If this is the correct password, the server responds with an AuthenticationOk, otherwise it responds with an ErrorResponse. The actual PasswordMessage can be computed in SQL as concat('md5', md5(concat(md5(concat(password, username)), random-salt))). (Keep in mind the md5() function returns its result as a hex string.) -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +