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 1tXMxR-005u5Z-Tu for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jan 2025 16:06:30 +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 1tXMxQ-00BDGz-KO for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jan 2025 16:06:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tXMxP-00BDGp-S3 for pgsql-hackers@lists.postgresql.org; Mon, 13 Jan 2025 16:06:28 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tXMxM-000CLJ-1o for pgsql-hackers@postgresql.org; Mon, 13 Jan 2025 16:06:27 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 80EFE25400C9; Mon, 13 Jan 2025 11:06:20 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Mon, 13 Jan 2025 11:06:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1736784380; x=1736870780; bh=S mqb31F/g7UehTsK5GrfZYDhdeNdgKrrkZ/Fh8jOS9E=; b=j7sWhBuHBIsv3EFwH D+622wngRLHgZ7w4zC70gs8E0yXlL8KTODUouugA9QBp+/KCJ0YQr4XJ4YHTjra4 lpZYFvv5M3mut1+xpxM1CANt1YQIcx3LubORdKoqHo5LkMAhG3uwSrFfuRj7btHU 9lhxqhBjNGHuuVcJShy1CUtxyNK4FOO+47452MdrfPhufqzYkWqZYYjCNpenpUVO juwit+mfT4mYUOYKLwM+MU3gLupDe9EZ19K0wFixSKDFwBoBMe3NVu1mfuTwlMmP QQE/cW9BhTmHsxyeW7mL3YY4JPXOXgkbfYtfSlJKgMSalQCks5XIHfWI0dvtFj1g zHrsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudehgedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeen ucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffh jeejhffgieeuueekjeekfffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrph hrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprh gtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjrghpihhnlhhi sehhohhtmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrihhlihhnghhssehoohhpshifrg hrvgdruggvpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghs qhhlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Jan 2025 11:06:19 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1736784376; bh=2h30FAkKBs4It680esrhmfOUaRvqegNm5hhro5xQDpU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=qfMWUj2k/Ld0pjYMNUhRg0FoPRGruiPvdboG37jBBREOES3lt1yu0vi+53v8bjxdS /LmQXNoi58eNCWgNC8EpwrKG1IyyY1MttYbzfKBAFIwhZI3msb/FQBCLtYQa0W9aZK uq7kVGgTaoebS7Fztx3FhdGC7kBS7nm6W3NuVJCtYYLunw9a3jfQvwj2ffJGYVIyP2 jycQf9jhQ0QzqaRh91hGwEPhAFlnwcJJxKQ5TADpHqqYCoe/UHLmT2H/C85aSDwx9A GH88c5ABOFRl0nhDGEBmy7GZLiAQaQD/2TtznJVKQgy0uAPhpi94vme74k1dN79/Da qjndiq8+TucPQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id DFED8307; Mon, 13 Jan 2025 17:06:16 +0100 (CET) Date: Mon, 13 Jan 2025 17:06:16 +0100 From: Alvaro Herrera To: Bernd Helmle Cc: Japin Li , PostgreSQL Development Subject: Re: Modern SHA2- based password hashes for pgcrypto Message-ID: <202501131606.h6ctz533qhy6@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7bde94157f8357a59a9d6de1f74a1b6d7705c5b0.camel@oopsware.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello I was passing by and I noticed that this needs badly pgindent, and some comments are enumerations that would lose formatting once through it. For example, this would happen which is not good: /* - * 1. Start digest A - * 2. Add the password string to digest A - * 3. Add the salt to digest A + * 1. Start digest A 2. Add the password string to digest A 3. Add the + * salt to digest A */ I suggest you can fix this by adding a "-" sign to the opening "/*" line so that pgindent doesn't mangle it (so it becomes /*- ). This appears in several places. It's been said in my presence that pgcrypto is obsolete and shouldn't be used anymore. I'm not sure I believe that, but even if that's true, it's clear that there's plenty of people who has an interest on it, so I don't see that as an objection to reject this work. So let's move on. Your test data (crypt-shacrypt.sql) looks a bit short. I noticed that Drepper's SHA-crypt.txt file has a bunch of test lines (starting with the "Test vectors from FIPS 180-2: appendix B.1." comment line, as well as "appendix C.1" at the bottom) which perhaps could be incorporated into the .sql script, to ensure correctness (or at least, bug-compatibility with the reference implementation). I'd also add a note that Drepper's implementation is public domain in crypt-sha.c's license block. I think the "ascii_dollar" variable is a bit useless. Why not just use the literal $ sign where needed (or a DOLLAR_CHR if we feel like avoiding a magic value there)? Also, I wonder if it would be better to use a StringInfo instead of a fixed-size buffer, which would probably make some string manipulations easier ... Or maybe not, but let's not mix strlcat calls with strncat calls with no comments about why. Some of your elog(ERROR)s should probably be ereport(), and I'm not sure we want all the elog(DEBUG1)s. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El que vive para el futuro es un iluso, y el que vive para el pasado, un imbécil" (Luis Adler, "Los tripulantes de la noche")