pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Matthias Apitz <guru@unixarea.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: calculating the MD5 hash of role passwords in C
Date: Wed, 22 Jan 2020 10:35:49 -0800
Message-ID: <fd454da1-72ad-da91-4349-e7cb5f3572f0@aklaver.com> (raw)
In-Reply-To: <20200122182036.GA2908@c720-r342378>
References: <20200122182036.GA2908@c720-r342378>

On 1/22/20 10:20 AM, Matthias Apitz wrote:
> 
> Hello,
> 
> If I look into the database I see:
> 
> sisis71=# select rolname, rolpassword from pg_authid where rolname = 'sisis';
>   rolname |             rolpassword
> ---------+-------------------------------------
>   sisis   | md52f128a1fbbecc4b16462e8fc8dda5cd5
> 
> 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?

https://www.postgresql.org/docs/12/runtime-config-connection.html

"Because md5 uses the user name as salt on both the client and server, 
md5 cannot be used with db_user_namespace."

~/src/common/md5.c
/*
          * Place salt at the end because it may be known by users 
trying to crack
          * the MD5 output.
          */


So:
select md5('sisis123sisis');
                md5
----------------------------------
  2f128a1fbbecc4b16462e8fc8dda5cd5

> 
> Thanks
> 
> 	matthias
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (14+ messages)  latest in thread

Message-ID: <fd454da1-72ad-da91-4349-e7cb5f3572f0@aklaver.com>
Permalink:  ../fd454da1-72ad-da91-4349-e7cb5f3572f0@aklaver.com/
Also on:    postgresql.org/message-id/fd454da1-72ad-da91-4349-e7cb5f3572f0@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, guru@unixarea.de
  Subject: Re: calculating the MD5 hash of role passwords in C
  In-Reply-To: <fd454da1-72ad-da91-4349-e7cb5f3572f0@aklaver.com>
  References: <20200122182036.GA2908@c720-r342378> <fd454da1-72ad-da91-4349-e7cb5f3572f0@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox