Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tf76R-00HQNk-2e for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Feb 2025 00:47:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tf76O-00016b-7y for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Feb 2025 00:47:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tf76N-00016T-V6 for pgsql-hackers@lists.postgresql.org; Tue, 04 Feb 2025 00:47:43 +0000 Received: from fhigh-a8-smtp.messagingengine.com ([103.168.172.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tf76L-00322g-2I for pgsql-hackers@lists.postgresql.org; Tue, 04 Feb 2025 00:47:43 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3D47911400DB; Mon, 3 Feb 2025 19:47:41 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Mon, 03 Feb 2025 19:47:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1738630061; x=1738716461; bh=MZuOirHNzl gtnqWhBDynU+LGgPG1IpXqh4HKE1wVR1E=; b=dzPV+mil+YUpbWu8rYVuKLCjxK WFhKzNGD5niDNQm4kMEQG26o7WQbVaI0FaNcjzAmy169ef9e1cA4Kz/JvZ84S24I AUTSEx5LhwsgEE6J+fGzMutzlIhzN4WpUsu4Fwx/j7uL8cUNcciMmgB9RJmRzLef 0z+6EI05q3MJsSxCCKEkYMewfp0Yy7Y8pCO6ZExgcuhnkudbZIpuHFz9VAlBLXae pTz1pdj+Mgb6grI5piTCy1lUTAP9/bq8Kj+5XTbGOdX2ehbmlEVVEQ67mIxGixQV OqIO26b0RbZuv6keStAqeT2NMHaaKE3oExp1k/VbDTSepE3sNfPhybuFbvSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1738630061; x=1738716461; bh=MZuOirHNzlgtnqWhBDynU+LGgPG1IpXqh4H KE1wVR1E=; b=TROtjTRVFKVVYDXHF8lgtfJbuNoabMo3KK9K69xeeipsmOLVt7g yYPKLO57eyhjFcwP/KtYVSyEywMwqr7f6ZDu8ASgbUDrIGiRzmkd++a1FrOYqlZ5 rr7VLJfB0bBTMfdRJiUMLYTYmoqX7nzza6bsBhtZCc/rrML1ixKTMeH3gv3xkIR1 WJ4yoVOne4D9ICFMnYh0DDJ9MT1RwHKtysK5KI2DJFsNLYM4BSCNXGP+M0KVFiRT wN5HdAA5sPtcRljKeeV1zQaaqc2G1gy40iCAgKzrhe/JdF8L73TzYQx9nxrIOvV/ I/HW60N48mChR59MGHfaNQOusL4f6JFcX2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduledutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffk fhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrh cuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeet leeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghl sehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopegurghnihgvlheshigvshhqlhdrshgvpdhrtghpthhtoheprhef fehsfehnieesghhmrghilhdrtghomhdprhgtphhtthhopeihrdhsohhkohhlohhvsehpoh hsthhgrhgvshhprhhordhruhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehl ihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 19:47:38 -0500 (EST) Date: Tue, 4 Feb 2025 09:47:25 +0900 From: Michael Paquier To: Daniel Gustafsson Cc: Zixuan Fu , Yura Sokolov , PostgreSQL Hackers Subject: Re: Optimize scram_SaltedPassword performance Message-ID: References: <62fbf768-d2d0-4bb2-840d-a8d2880af82b@postgrespro.ru> <4ABFA50D-9558-4368-8A62-E2B78DE39E0B@yesql.se> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="8LaB8P/eGRVt0q4o" Content-Disposition: inline In-Reply-To: <4ABFA50D-9558-4368-8A62-E2B78DE39E0B@yesql.se> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --8LaB8P/eGRVt0q4o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 03, 2025 at 12:17:27PM +0100, Daniel Gustafsson wrote: > The numbers are quite outdated but the gist of it holds. If we speed it up > serverside we need to counter that with a higher iteration count, and for a > rogue client it's unlikely to matter since it wont use our code anyways. > Speeding up HMAC for other usecases is a different story (but also likely to > have less measurable performance impact). Thanks, I've managed to somewhat forget this point. Note that this has come up as well when adding the GUC scram_iterations in b577743000cd, where a lower count can be used for a faster connection. > Storing any part of a cryptograhic calculation, let alone a key, in a static > variable doesn't seem entirely like a best practice, and it also wont be > threadsafe. Agreed. By the way, something I have forgotten to mention yesterday.. If a fast-path gets implemented in these HMAC APIs (perhaps not), it sounds to me that it would be better to achieve the same for the fallback non-OpenSSL implementation in src/common/hmac.c, as it would reflect things properly in the interface. My 2c. -- Michael --8LaB8P/eGRVt0q4o Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmehY50ACgkQnvQgOdby QH3/pw/7BEXXcGLSLLh6cZKEqj12oQmoU15OpjZ9/3s6CV55bLaSUnxStSfDw5FX 2rqEsDojdIfAVKmaIlwgoj5HKiV5+vhCvvRQP/Wjch5LTvT5/5r6rvs2RcjWr5Z/ kkvafyoeoc6xiVQ9HrU6YSrJY02C6UXgO/oloTBhEMw/BNpZWwAhTqiTKt6Z5lRB 4BkvIpXPL6eBSzeXLUniA12mx2Lyn5BmWW9nvrPqKmpKRX6g8Zj1Eslptotan4d8 UaVBxGeCNs5PAHEGs8h7Zbs+xWd+5UpwHDVEP/63dfnOnxzTMkhPx+3YHA2X7kB+ aV18D75c8c/hxe99K//eTZ/9KTMFoUfR6sjvGZR22+jpVK2s2tlUmeKT3O6ftRgU BRr/AA9nsaR6Id3nPBax99tPCnuOt3eedpdc554w0+hJZGVb0nthDJE0kC3FU+oC Rq2AJ2BXiBJKB/XOZl02My4Mr/thDS3ojXLcXkTykjRcXzIOTePQEVCffNtE+pS2 xbGGb2zyRmZPilNVxONyEnTQP27c3r2NcCWrHfJQ3HqAlR5P9U0v61dQHXrOHg5g HJV0ln06kxzfOAInpuGA5Q4K8TSnklF7OPJ4/q2sxnJI+ijQRlPNemTBjEiu3htv ChxBkDalX1GGx+kBdExn65JgJhljWFBTO7A/bFL5nGpAetLOjzQ= =RqFr -----END PGP SIGNATURE----- --8LaB8P/eGRVt0q4o--