Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZVOw-0005Hp-DD for pgsql-general@arkaria.postgresql.org; Tue, 07 Mar 2023 11:22:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZVOv-00075f-B9 for pgsql-general@arkaria.postgresql.org; Tue, 07 Mar 2023 11:22:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZUwr-0001jb-DQ for pgsql-general@lists.postgresql.org; Tue, 07 Mar 2023 10:53:37 +0000 Received: from mtmayr.com ([94.130.205.61]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZUwn-0003TV-BT for pgsql-general@postgresql.org; Tue, 07 Mar 2023 10:53:35 +0000 Received: from [192.168.1.3] (80-109-214-216.cable.dynamic.surfer.at [80.109.214.216]) by mtmayr.com (Postfix) with ESMTPSA id 637EE1F541 for ; Tue, 7 Mar 2023 11:53:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mtmayr.com; s=2020-05-04; t=1678186410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=bZIuUZ17gnurbfjvLn0qiDyVCZ43kjfZ9ex1TK8Oydg=; b=3YEFNyXcyoVZEHhm33nPOox77J6RSW84kKPniXc/UywevI028kWp9v0NNRTabmAYnAKU3r qOHFiDPLxmpO+sk/X6GGryRE9lgt87zQkGNGDClumZ4zjTsMyLqgpzIHmbSGMGSIfFsHVL afM4cguNLpp/OkNTw0w00csX/wbZULo= Content-Type: multipart/alternative; boundary="------------0YdKJteV0T1hfp5mqtCpXev8" Message-ID: Date: Tue, 7 Mar 2023 11:53:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: de-AT, en-US To: pgsql-general@postgresql.org From: Mathias Mayrhofer Subject: escape vs. bytea in config ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mtmayr.com; s=2020-05-04; t=1678186410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=bZIuUZ17gnurbfjvLn0qiDyVCZ43kjfZ9ex1TK8Oydg=; b=Be7hROu6wHumpV5f8lhdlps6/u49mOR2Pwv0gzaMy1rwqH9jvOM0e7S7BW7P4k5gzifZah DEQrxlelIbamdgIE/b9JzVFYFspwGmv52/k/z4T6u43FGwaZxE6aUGJ82/rNJt7lzIqu+i uxHlqhHK7ZbvXeyJAdj/3aq7MxXR1v4= ARC-Seal: i=1; s=2020-05-04; d=mtmayr.com; t=1678186410; a=rsa-sha256; cv=none; b=UN7TW6fjSkG0qqFFTWA4AEdZvEcV285G5PURA99u1ZjL4CKKhiBCL+xZupNl6EKFuWSuY7j91kTwVMer/7MdNrqhvfmHuBx+7hkS8sYducdHNVp2aMTCeRieLOI5bHH4IpWi2JaCTP5vQJ4M1tICSICYgB42emgP+r0ThY78lNE= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=mtmayr@mtmayr.com smtp.mailfrom=mtmayr@mtmayr.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------0YdKJteV0T1hfp5mqtCpXev8 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 --------------0YdKJteV0T1hfp5mqtCpXev8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

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
--------------0YdKJteV0T1hfp5mqtCpXev8--