Re: Optimize scram_SaltedPassword performance

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Zixuan Fu <r33s3n6(at)gmail(dot)com>, Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Optimize scram_SaltedPassword performance
Date: 2025-02-04 00:47:25
Message-ID: Z6FjnXFf69RKsLV9@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Sabino Mullane 2025-02-04 00:47:39 Re: Better title output for psql \dt \di etc. commands
Previous Message Michael Paquier 2025-02-04 00:35:51 Re: [PATCH] Fix incorrect range in pg_regress comment