pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mathias Mayrhofer <mtmayr@mtmayr.com>
To: pgsql-general@postgresql.org
Subject: escape vs. bytea in config
Date: Tue, 7 Mar 2023 11:53:29 +0100
Message-ID: <ab608b9b-862b-c773-ea6f-298b9da6a898@mtmayr.com> (raw)

Dear Supportlist,

I came across the "bytea_output" configuration variable inside 
postgresql.conf. It seems to be affecting the "digest" function, but in 
a way I cannot understand.

When my postgresql 14 server executes the digest function, it considers 
the "bytea_output" variable, but the output of the function is *NOT* the 
same as the "encode" function. It differs only slightly.

Please have a view of the following two conditions: First with 
"bytea_output = hex", second with "bytea_output = escape". In both ways 
the result differs, which leads to my password-comparison to turn out false.

Regards,
Mathias


-- /etc/postgresql/14/main/postgresql.conf
-- bytea_output = 'hex'

db=> select digest('mtmayr', 'sha256');
┌────────────────────────────────────────────────────────────────────┐
│                               digest                               │
├────────────────────────────────────────────────────────────────────┤
│ \xbf1995dd67c794df2de75983acd41f66c750682ab75ca3a935538b575884fd47 │
└────────────────────────────────────────────────────────────────────┘

db=> select encode(digest('mtmayr', 'sha256'), 'hex');
┌──────────────────────────────────────────────────────────────────┐
│                              encode                              │
├──────────────────────────────────────────────────────────────────┤
│ bf1995dd67c794df2de75983acd41f66c750682ab75ca3a935538b575884fd47 │
└──────────────────────────────────────────────────────────────────┘


-- /etc/postgresql/14/main/postgresql.conf
-- bytea_output = 'escape'

db=> select encode(digest('mtmayr', 'sha256'), 'escape');
┌────────────────────────────────────────────────────────────────────────────────────────────┐
│                                           encode                                           │
├────────────────────────────────────────────────────────────────────────────────────────────┤
│ \277\x19\225\335g\307\224\337-\347Y\203\254\324\x1Ff\307Ph*\267\\\243\2515S\213WX\204\375G │
└────────────────────────────────────────────────────────────────────────────────────────────┘

db=> select digest('mtmayr', 'sha256');
┌────────────────────────────────────────────────────────────────────────────────────────────┐
│                                           digest                                           │
├────────────────────────────────────────────────────────────────────────────────────────────┤
│ \277\031\225\335g\307\224\337-\347Y\203\254\324\037f\307Ph*\267\\\243\2515S\213WX\204\375G │
└────────────────────────────────────────────────────────────────────────────────────────────┘

--    ^^  differences                             ^^^^

-- 
/\/\athias /\/\ayrhofer

view thread (3+ messages)  latest in thread

Message-ID: <ab608b9b-862b-c773-ea6f-298b9da6a898@mtmayr.com>
Permalink:  ../ab608b9b-862b-c773-ea6f-298b9da6a898@mtmayr.com/
Also on:    postgresql.org/message-id/ab608b9b-862b-c773-ea6f-298b9da6a898@mtmayr.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: mtmayr@mtmayr.com
  Subject: Re: escape vs. bytea in config
  In-Reply-To: <ab608b9b-862b-c773-ea6f-298b9da6a898@mtmayr.com>
  References: <ab608b9b-862b-c773-ea6f-298b9da6a898@mtmayr.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