Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6e9c4d

Browse files
committed
Misc cleanup of SCRAM code.
* Remove is_scram_verifier() function. It was unused.* Fix sanitize_char() function, used in error messages on protocol violations, to print bytes >= 0x7F correctly.* Change spelling of scram_MockSalt() function to be more consistent with the surroundings.* Change a few more references to "server proof" to "server signature" that I missed in commitd981074.
1 parent344a113 commite6e9c4d

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

‎src/backend/libpq/auth-scram.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void mock_scram_verifier(const char *username, int *iterations,
153153
char**salt,uint8*stored_key,uint8*server_key);
154154
staticboolis_scram_printable(char*p);
155155
staticchar*sanitize_char(charc);
156-
staticchar*scram_MockSalt(constchar*username);
156+
staticchar*scram_mock_salt(constchar*username);
157157

158158
/*
159159
* pg_be_scram_init
@@ -480,28 +480,6 @@ scram_verify_plain_password(const char *username, const char *password,
480480
returnmemcmp(computed_key,server_key,SCRAM_KEY_LEN)==0;
481481
}
482482

483-
/*
484-
* Check if given verifier can be used for SCRAM authentication.
485-
*
486-
* Returns true if it is a SCRAM verifier, and false otherwise.
487-
*/
488-
bool
489-
is_scram_verifier(constchar*verifier)
490-
{
491-
intiterations;
492-
char*salt=NULL;
493-
uint8stored_key[SCRAM_KEY_LEN];
494-
uint8server_key[SCRAM_KEY_LEN];
495-
boolresult;
496-
497-
result=parse_scram_verifier(verifier,&iterations,&salt,
498-
stored_key,server_key);
499-
if (salt)
500-
pfree(salt);
501-
502-
returnresult;
503-
}
504-
505483

506484
/*
507485
* Parse and validate format of given SCRAM verifier.
@@ -592,7 +570,7 @@ mock_scram_verifier(const char *username, int *iterations, char **salt,
592570
intencoded_len;
593571

594572
/* Generate deterministic salt */
595-
raw_salt=scram_MockSalt(username);
573+
raw_salt=scram_mock_salt(username);
596574

597575
encoded_salt= (char*)palloc(pg_b64_enc_len(SCRAM_DEFAULT_SALT_LEN)+1);
598576
encoded_len=pg_b64_encode(raw_salt,SCRAM_DEFAULT_SALT_LEN,encoded_salt);
@@ -679,7 +657,7 @@ sanitize_char(char c)
679657
if (c >=0x21&&c <=0x7E)
680658
snprintf(buf,sizeof(buf),"'%c'",c);
681659
else
682-
snprintf(buf,sizeof(buf),"0x%02x",c);
660+
snprintf(buf,sizeof(buf),"0x%02x",(unsignedchar)c);
683661
returnbuf;
684662
}
685663

@@ -1146,7 +1124,7 @@ build_server_final_message(scram_state *state)
11461124
* pointer to a static buffer of size SCRAM_DEFAULT_SALT_LEN.
11471125
*/
11481126
staticchar*
1149-
scram_MockSalt(constchar*username)
1127+
scram_mock_salt(constchar*username)
11501128
{
11511129
pg_sha256_ctxctx;
11521130
staticuint8sha_digest[PG_SHA256_DIGEST_LENGTH];

‎src/include/libpq/scram.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ extern int pg_be_scram_exchange(void *opaq, char *input, int inputlen,
2828

2929
/* Routines to handle and check SCRAM-SHA-256 verifier */
3030
externchar*pg_be_scram_build_verifier(constchar*password);
31-
externboolis_scram_verifier(constchar*verifier);
3231
externboolscram_verify_plain_password(constchar*username,
3332
constchar*password,constchar*verifier);
3433

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pg_fe_scram_exchange(void *opaq, char *input, int inputlen,
212212
break;
213213

214214
caseFE_SCRAM_PROOF_SENT:
215-
/* Receive serverproof */
215+
/* Receive serversignature */
216216
if (!read_server_final_message(state,input,errorMessage))
217217
gotoerror;
218218

@@ -228,7 +228,7 @@ pg_fe_scram_exchange(void *opaq, char *input, int inputlen,
228228
{
229229
*success= false;
230230
printfPQExpBuffer(errorMessage,
231-
libpq_gettext("invalid serverproof\n"));
231+
libpq_gettext("invalid serversignature\n"));
232232
}
233233
*done= true;
234234
state->state=FE_SCRAM_FINISHED;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp