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 1pSIO9-0002Go-Ou for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Feb 2023 14:04:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSIO7-0001tn-T7 for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Feb 2023 14:03:59 +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 1pSIO7-0001te-Ea for pgsql-bugs@lists.postgresql.org; Wed, 15 Feb 2023 14:03:59 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSIO0-0002pj-Px for pgsql-bugs@lists.postgresql.org; Wed, 15 Feb 2023 14:03:58 +0000 Received: by mail-ej1-x62c.google.com with SMTP id ky6so1732632ejc.0 for ; Wed, 15 Feb 2023 06:03:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:disposition-notification-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=oCYYO8J0r5E1hxuCOG0Rm6AlVayTfbHq+R8uS1i92ko=; b=i6yMi/9bFVIvz0jJHvUc6lE3xyDiWhRVLMLdKxdTY11BfnVx7kb2B0fBOQiDCUHnYL RKlxgxIAwdfUIuH4JFVljquV1AsQQ4IWEJLGizX5ZyrAAgbM6CZ3Te9D3qMJbt+Zj7Ol UQQ5OvQErr56weD7ZQBJ+cyIcW7il5oq6WOxuppcn1ic2fyKEMPwz2FlWCoivwixcojC xex2GiuzwLEoGO7VllZqSA6yE9aQe5dqZOmUEYWWDtJaag7lq1EH3Wt3vltVUUV/64zC Y58+re48FCkKnWQwHUQlunbTZjLp7QE3Q8SyNkAYeSMzOeJXe5UJtouib5H10jqoT2x2 H4eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:disposition-notification-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oCYYO8J0r5E1hxuCOG0Rm6AlVayTfbHq+R8uS1i92ko=; b=Fjil+R/kSGgWrx/GHsLnPDFBJ0kRmxEtD3hZexkQ0DyQ9FzPdTgl+y4Ou5eiy0Jt0W RQpempIRJQHW027uCVny+FTKSwoXhaap704aIUQCbjJZe83sXeDr24s+TROb54iX/Pjw 6gvUOltjlSZGdEKUYgJDNxKxsDOrHaC3dn8j79K5FXLnuQssq+0x3eW1IrAps1tH6rtn Qs8PYU4JIcZi253FuCryiwoxCWooHXwkAf/NxuP9AoWcxQZyRI+/KK2VAiFZFjVoUXIQ AlGUit2iRFDcms1dt7ttgDB0svvQTIq9DQj4YP/niZpjCSMCEGxsx97ZMxzQMuvEZBwJ fWtg== X-Gm-Message-State: AO0yUKWiOIMbE1TX1z8U6E4+haUikTcmmiPa9x56lvFUpJdsDFW7OEir t7edy/Xtstma9BEAtvJ+Fw== X-Google-Smtp-Source: AK7set9RoTSGXk08O/G0mIWYrpgUmV8RiBE7e+FBhoEppbEtaid8F//roNDr5ftFtM5089PfWxsLEw== X-Received: by 2002:a17:906:4a47:b0:88a:292d:be8c with SMTP id a7-20020a1709064a4700b0088a292dbe8cmr2502157ejv.22.1676469831136; Wed, 15 Feb 2023 06:03:51 -0800 (PST) Received: from [192.168.1.80] ([2.229.48.88]) by smtp.gmail.com with ESMTPSA id c18-20020a17090618b200b0088452ca0666sm9616506ejf.196.2023.02.15.06.03.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Feb 2023 06:03:50 -0800 (PST) Content-Type: multipart/alternative; boundary="------------4Pzl9smxAqt05qkxLtzQmKAi" Message-ID: Date: Wed, 15 Feb 2023 15:03:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: BUG #17796: pgcrypto undecryptable blowfish data previous stored with openssl 1.1.1 with builtin decrypter one To: Daniel Gustafsson , pgsql-bugs@lists.postgresql.org References: <17796-a35e6387be088a9b@postgresql.org> Content-Language: it From: "agharta82@gmail.com" Disposition-Notification-To: "agharta82@gmail.com" In-Reply-To: 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. --------------4Pzl9smxAqt05qkxLtzQmKAi Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Daniel, Thanks for quick reply. I've found the rapid way to get hash type: htpasswd. Correct me if I am wrong. #openssl version OpenSSL 1.1.1k  FIPS 25 Mar 2021 #htpasswd -nbBC 10 USER PASSWORD USER:$2y$10$YZNMKHWMye0yY3vvWUK8bOTrJjSRdD.sS2kXythshRkr2l1Qrcfha So, in my Rocky Linux 8 is $2y$ Now -as you writed- it's clear: hashes are incompatibles. For me, actually, the better way is to move to aes256 instead of bf, due to openssl bf deprecation. This should make me sleep well for a long time (i hope). Meanwhile, to solve the case: * in Linux is quite simple  (but insecure), enable legacy ciphers. * in Windows....uh....i've not found how to solve it because (if i am not wrong) PG  15  is built with openssl 3 internally and i don't known how to enable legacy mode in it. Actually in Windows (i disagree but my customer wants to use it) the only solution i've found is: * decrypt data * backup db * update PG to a version with openssl 3 * restore db * re-encrypt data Many thanks for your clarification, it has been illuminating! My best regards, Agharta Il 15/02/23 14:25, Daniel Gustafsson ha scritto: >> On 15 Feb 2023, at 13:15, PG Bug reporting form wrote: >> So, the problem seems that the builtin bf cipher implementation cannot >> decode the openssl one. > The internal implementation only support $2a$ hashes, are the OpenSSL hashes > $2b$ by any chance? The prefix of the hash includes this version number. > > There is a patch floating around for improving blowfish support in pgcrypto but > it hasn't made its way in. > >> Side note: if I enable legacy mode in openssl3 all works fine and pgcrypto >> use the openssl chiper, oblivious. >> >> Can it be solved? > If you relied on Blowfish in OpenSSL 1.1.1 then enabling the legacy provider in > OpenSSL 3.x, or downgrading to OpenSSL 1.1.1 is a solution. > > -- > Daniel Gustafsson > --------------4Pzl9smxAqt05qkxLtzQmKAi Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi Daniel,

Thanks for quick reply.

I've found the rapid way to get hash type: htpasswd. Correct me if I am wrong.

#openssl version
OpenSSL 1.1.1k  FIPS 25 Mar 2021

#htpasswd -nbBC 10 USER PASSWORD
USER:$2y$10$YZNMKHWMye0yY3vvWUK8bOTrJjSRdD.sS2kXythshRkr2l1Qrcfha


So, in my Rocky Linux 8 is $2y$

Now -as you writed- it's clear: hashes are incompatibles.

For me, actually, the better way is to move to aes256 instead of bf, due to openssl bf deprecation. This should make me sleep well for a long time (i hope).

Meanwhile, to solve the case:

  • in Linux is quite simple  (but insecure), enable legacy ciphers.
  • in Windows....uh....i've not found how to solve it because (if i am not wrong) PG  15  is built with openssl 3 internally and i don't known how to enable legacy mode in it.


Actually in Windows (i disagree but my customer wants to use it) the only solution i've found is:

  • decrypt data
  • backup db
  • update PG to a version with openssl 3
  • restore db
  • re-encrypt data


Many thanks for your clarification, it has been illuminating!

My best regards,

Agharta




Il 15/02/23 14:25, Daniel Gustafsson ha scritto:
On 15 Feb 2023, at 13:15, PG Bug reporting form <noreply@postgresql.org> wrote:

      
So, the problem seems that the builtin bf cipher implementation cannot
decode the openssl one.
The internal implementation only support $2a$ hashes, are the OpenSSL hashes
$2b$ by any chance? The prefix of the hash includes this version number.

There is a patch floating around for improving blowfish support in pgcrypto but
it hasn't made its way in.

Side note: if I enable legacy mode in openssl3 all works fine and pgcrypto
use the openssl chiper, oblivious.

Can it be solved? 
If you relied on Blowfish in OpenSSL 1.1.1 then enabling the legacy provider in
OpenSSL 3.x, or downgrading to OpenSSL 1.1.1 is a solution.

--
Daniel Gustafsson

--------------4Pzl9smxAqt05qkxLtzQmKAi--