Skip to content

Commit 38d485f

Browse files
committed
Fix up references to scram-sha-256
pg_hba_file_rules erroneously reported this as scram-sha256. Fix that. To avoid future errors and confusion, also adjust documentation links and internal symbols to have a separator between "sha" and "256". Reported-by: Christophe Courtois <christophe.courtois@dalibo.com> Author: Michael Paquier <michael.paquier@gmail.com>
1 parent 99f6a17 commit 38d485f

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

doc/src/sgml/protocol.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ On error, the server can abort the authentication at any stage, and send an
15401540
ErrorMessage.
15411541
</para>
15421542

1543-
<sect2 id="sasl-scram-sha256">
1543+
<sect2 id="sasl-scram-sha-256">
15441544
<title>SCRAM-SHA-256 authentication</title>
15451545

15461546
<para>

src/backend/libpq/auth.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -894,18 +894,18 @@ CheckSCRAMAuth(Port *port, char *shadow_pass, char **logdetail)
894894
* channel-binding variants go first, if they are supported. Channel
895895
* binding is only supported in SSL builds.
896896
*/
897-
sasl_mechs = palloc(strlen(SCRAM_SHA256_PLUS_NAME) +
898-
strlen(SCRAM_SHA256_NAME) + 3);
897+
sasl_mechs = palloc(strlen(SCRAM_SHA_256_PLUS_NAME) +
898+
strlen(SCRAM_SHA_256_NAME) + 3);
899899
p = sasl_mechs;
900900

901901
if (port->ssl_in_use)
902902
{
903-
strcpy(p, SCRAM_SHA256_PLUS_NAME);
904-
p += strlen(SCRAM_SHA256_PLUS_NAME) + 1;
903+
strcpy(p, SCRAM_SHA_256_PLUS_NAME);
904+
p += strlen(SCRAM_SHA_256_PLUS_NAME) + 1;
905905
}
906906

907-
strcpy(p, SCRAM_SHA256_NAME);
908-
p += strlen(SCRAM_SHA256_NAME) + 1;
907+
strcpy(p, SCRAM_SHA_256_NAME);
908+
p += strlen(SCRAM_SHA_256_NAME) + 1;
909909

910910
/* Put another '\0' to mark that list is finished. */
911911
p[0] = '\0';
@@ -973,8 +973,8 @@ CheckSCRAMAuth(Port *port, char *shadow_pass, char **logdetail)
973973
const char *selected_mech;
974974

975975
selected_mech = pq_getmsgrawstring(&buf);
976-
if (strcmp(selected_mech, SCRAM_SHA256_NAME) != 0 &&
977-
strcmp(selected_mech, SCRAM_SHA256_PLUS_NAME) != 0)
976+
if (strcmp(selected_mech, SCRAM_SHA_256_NAME) != 0 &&
977+
strcmp(selected_mech, SCRAM_SHA_256_PLUS_NAME) != 0)
978978
{
979979
ereport(ERROR,
980980
(errcode(ERRCODE_PROTOCOL_VIOLATION),

src/backend/libpq/hba.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static const char *const UserAuthName[] =
126126
"ident",
127127
"password",
128128
"md5",
129-
"scram-sha256",
129+
"scram-sha-256",
130130
"gss",
131131
"sspi",
132132
"pam",

src/include/common/scram-common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "common/sha2.h"
1717

1818
/* Name of SCRAM mechanisms per IANA */
19-
#define SCRAM_SHA256_NAME "SCRAM-SHA-256"
20-
#define SCRAM_SHA256_PLUS_NAME "SCRAM-SHA-256-PLUS" /* with channel binding */
19+
#define SCRAM_SHA_256_NAME "SCRAM-SHA-256"
20+
#define SCRAM_SHA_256_PLUS_NAME "SCRAM-SHA-256-PLUS" /* with channel binding */
2121

2222
/* Channel binding types */
2323
#define SCRAM_CHANNEL_BINDING_TLS_UNIQUE "tls-unique"

src/interfaces/libpq/fe-auth-scram.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ build_client_first_message(fe_scram_state *state)
349349
/*
350350
* First build the gs2-header with channel binding information.
351351
*/
352-
if (strcmp(state->sasl_mechanism, SCRAM_SHA256_PLUS_NAME) == 0)
352+
if (strcmp(state->sasl_mechanism, SCRAM_SHA_256_PLUS_NAME) == 0)
353353
{
354354
Assert(conn->ssl_in_use);
355355
appendPQExpBuffer(&buf, "p=%s", conn->scram_channel_binding);
@@ -430,7 +430,7 @@ build_client_final_message(fe_scram_state *state)
430430
* build_client_first_message(), because the server will check that it's
431431
* the same flag both times.
432432
*/
433-
if (strcmp(state->sasl_mechanism, SCRAM_SHA256_PLUS_NAME) == 0)
433+
if (strcmp(state->sasl_mechanism, SCRAM_SHA_256_PLUS_NAME) == 0)
434434
{
435435
char *cbind_data = NULL;
436436
size_t cbind_data_len = 0;

src/interfaces/libpq/fe-auth.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,11 @@ pg_SASL_init(PGconn *conn, int payloadlen)
533533
if (conn->ssl_in_use &&
534534
conn->scram_channel_binding &&
535535
strlen(conn->scram_channel_binding) > 0 &&
536-
strcmp(mechanism_buf.data, SCRAM_SHA256_PLUS_NAME) == 0)
537-
selected_mechanism = SCRAM_SHA256_PLUS_NAME;
538-
else if (strcmp(mechanism_buf.data, SCRAM_SHA256_NAME) == 0 &&
536+
strcmp(mechanism_buf.data, SCRAM_SHA_256_PLUS_NAME) == 0)
537+
selected_mechanism = SCRAM_SHA_256_PLUS_NAME;
538+
else if (strcmp(mechanism_buf.data, SCRAM_SHA_256_NAME) == 0 &&
539539
!selected_mechanism)
540-
selected_mechanism = SCRAM_SHA256_NAME;
540+
selected_mechanism = SCRAM_SHA_256_NAME;
541541
}
542542

543543
if (!selected_mechanism)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy