Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iuLsP-0005x5-Ew for pgsql-general@arkaria.postgresql.org; Wed, 22 Jan 2020 19:41:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iuLsN-00018n-Ne for pgsql-general@arkaria.postgresql.org; Wed, 22 Jan 2020 19:41:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iuLsN-00018g-DM for pgsql-general@lists.postgresql.org; Wed, 22 Jan 2020 19:41:19 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iuLsK-0002Dl-Gl for pgsql-general@lists.postgresql.org; Wed, 22 Jan 2020 19:41:19 +0000 Received: from [87.152.181.22] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1iuLsI-0004vG-N1 for pgsql-general@lists.postgresql.org; Wed, 22 Jan 2020 20:41:14 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id 00MJfEF1002464 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Wed, 22 Jan 2020 20:41:14 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id 00MJfDr4002463 for pgsql-general@lists.postgresql.org; Wed, 22 Jan 2020 20:41:13 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Wed, 22 Jan 2020 20:41:13 +0100 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: Re: calculating the MD5 hash of role passwords in C Message-ID: <20200122194113.GA2410@c720-r342378> Reply-To: Matthias Apitz References: <20200122182036.GA2908@c720-r342378> <20200122185847.GA90048@elch.exwg.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200122185847.GA90048@elch.exwg.net> X-Operating-System: FreeBSD 13.0-CURRENT r342378 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.11.1 (2018-12-01) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 87.152.181.22 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk El d=C3=ADa mi=C3=A9rcoles, enero 22, 2020 a las 07:58:47p. m. +0100, Chris= toph Moench-Tegeder escribi=C3=B3: > ## Matthias Apitz (guru@unixarea.de): >=20 > > sisis71=3D# select rolname, rolpassword from pg_authid where rolname = =3D 'sisis'; > > rolname | rolpassword > > ---------+------------------------------------- > > sisis | md52f128a1fbbecc4b16462e8fc8dda5cd5 > >=20 > > I know the clear text password of the role, it is simple 'sisis123', how > > could I calculate the above MD5 hash from the clear text password, for > > example in C? Which salt is used for the crypt(3) function? >=20 > The documentation on pg_authid has the details: > "The MD5 hash will be of the user's password concatenated to their user n= ame." > https://www.postgresql.org/docs/12/catalog-pg-authid.html Thanks to all who replied. This is still not exactly what I was looking for. But has an interesting detail (salting the role password by adding the role name to it). An implementation with UNIX crypt(3) for MD5 would need an additional salt like '$1$salt' to encrypt 'sisis123sisis'. For sure the next place to look is the implementation of the PostgreSQL's md5() function. Thanks again matthias --=20 Matthias Apitz, =E2=9C=89 guru@unixarea.de, http://www.unixarea.de/ +49-176= -38902045 Public GnuPG key: http://www.unixarea.de/key.pub Deutschland raus aus der NATO! NATO raus aus Deutschland! Frieden mit Russl= and! Germany out of NATO! NATO out of Germany! Peace with Russia! =C2=A1Alemania fuera de OTAN! =C2=A1OTAN fuera de Alemania! =C2=A1Paz con R= usia!