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

Commit457c2d9

Browse files
committed
Apply upstream fix for blowfish signed-character bug (CVE-2011-2483).
A password containing a character with the high bit set was misprocessedon machines where char is signed (which is most). This could cause thepreceding one to three characters to fail to affect the hashed result,thus weakening the password. The result was also unportable, and failedto match some other blowfish implementations such as OpenBSD's.Since the fix changes the output for such passwords, upstream choseto provide a compatibility hack: password salts beginning with $2x$(instead of the usual $2a$ for blowfish) are intentionally processed"wrong" to give the same hash as before. Stored password hashes canthus be modified if necessary to still match, though it'd be betterto change any affected passwords.In passing, sync a couple other upstream changes that marginally improveperformance and/or tighten error checking.Back-patch to all supported branches. Since this issue is alreadypublic, no reason not to commit the fix ASAP.
1 parent66cab2b commit457c2d9

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

‎contrib/pgcrypto/crypt-blowfish.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* and crypt(3) interfaces added, but optimizations specific to password
66
* cracking removed.
77
*
8-
* Written by Solar Designer <solar@openwall.com> in 1998-2001, and placed
9-
* in the public domain.
8+
* Written by Solar Designer <solar atopenwall.com> in 1998-2002 and
9+
*placedin the public domain.
1010
*
1111
* There's absolutely no warranty.
1212
*
@@ -19,9 +19,9 @@
1919
* of your choice.
2020
*
2121
* This implementation is compatible with OpenBSD bcrypt.c (version 2a)
22-
* by Niels Provos <provos@physnet.uni-hamburg.de>, and uses some of his
23-
* ideas. The password hashing algorithm was designed by David Mazieres
24-
* <dm@lcs.mit.edu>.
22+
* by Niels Provos <provos at citi.umich.edu>, and uses some of his
23+
* ideas.The password hashing algorithm was designed by David Mazieres
24+
* <dm atlcs.mit.edu>.
2525
*
2626
* There's a paper on the algorithm that explains its design decisions:
2727
*
@@ -40,7 +40,7 @@
4040
#ifdef__i386__
4141
#defineBF_ASM0/* 1 */
4242
#defineBF_SCALE1
43-
#elif defined(__alpha__)
43+
#elif defined(__x86_64__)|| defined(__alpha__)|| defined(__hppa__)
4444
#defineBF_ASM0
4545
#defineBF_SCALE1
4646
#else
@@ -49,6 +49,7 @@
4949
#endif
5050

5151
typedefunsignedintBF_word;
52+
typedefsignedintBF_word_signed;
5253

5354
/* Number of Blowfish rounds, this is also hardcoded into a few places */
5455
#defineBF_N16
@@ -544,7 +545,8 @@ extern void _BF_body_r(BF_ctx * ctx);
544545
#endif
545546

546547
staticvoid
547-
BF_set_key(constchar*key,BF_keyexpanded,BF_keyinitial)
548+
BF_set_key(constchar*key,BF_keyexpanded,BF_keyinitial,
549+
intsign_extension_bug)
548550
{
549551
constchar*ptr=key;
550552
inti,
@@ -557,7 +559,10 @@ BF_set_key(const char *key, BF_key expanded, BF_key initial)
557559
for (j=0;j<4;j++)
558560
{
559561
tmp <<=8;
560-
tmp |=*ptr;
562+
if (sign_extension_bug)
563+
tmp |= (BF_word_signed) (signedchar)*ptr;
564+
else
565+
tmp |= (unsignedchar)*ptr;
561566

562567
if (!*ptr)
563568
ptr=key;
@@ -599,10 +604,11 @@ _crypt_blowfish_rn(const char *key, const char *setting,
599604

600605
if (setting[0]!='$'||
601606
setting[1]!='2'||
602-
setting[2]!='a'||
607+
(setting[2]!='a'&&setting[2]!='x')||
603608
setting[3]!='$'||
604609
setting[4]<'0'||setting[4]>'3'||
605610
setting[5]<'0'||setting[5]>'9'||
611+
(setting[4]=='3'&&setting[5]>'1')||
606612
setting[6]!='$')
607613
{
608614
returnNULL;
@@ -616,7 +622,7 @@ _crypt_blowfish_rn(const char *key, const char *setting,
616622
}
617623
BF_swap(data.binary.salt,4);
618624

619-
BF_set_key(key,data.expanded_key,data.ctx.P);
625+
BF_set_key(key,data.expanded_key,data.ctx.P,setting[2]=='x');
620626

621627
memcpy(data.ctx.S,BF_init_state.S,sizeof(data.ctx.S));
622628

‎contrib/pgcrypto/px-crypt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct px_crypt_algo
7979
staticconststructpx_crypt_algo
8080
px_crypt_list[]= {
8181
{"$2a$",4,run_crypt_bf},
82+
{"$2x$",4,run_crypt_bf},
8283
{"$2$",3,NULL},/* N/A */
8384
{"$1$",3,run_crypt_md5},
8485
{"_",1,run_crypt_des},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp