[PATCH] A fix for DES_is_weak_key()

Claudio Freire j4580 at dynamo.com.ar
Thu Jun 17 23:47:29 CDT 2004


First: It's not in diff format. Sorry, but I made other changes that are
actually only useful to me, and a diff would include those.

 The problem arose when I was checking DES_random_key(), since I needed to
do
the same but different (so I had to rewrite it).
The DES_is_weak_key() function in crypto/des/set_key.c compares to a table
of weak keys, but the comparison is done with memcmp() and it should not be
so since parity bits don't count. I mean, since the key schedule in DES
ignores parity bits, weak keys with wrong parity bits are still weak keys.
Now, the code in DES_random_key() was assuming this behavior, since it would
produce a random octet string and ask DES_is_weak_key() before calling
DES_set_odd_parity().

 NOTE: When I saw this, I thought the simplest way to correct it was to do
the DES_set_odd_parity() before DES_is_weak_key() in DES_random_key(), but I
didn't know in how many other places DES_is_weak_key()'s behavior was
expected different, and the safest way was to change DES_is_weak_key(). If
you guys, who've been working with OpenSSL all this time, are sure the other
simpler way (changing DES_random_key) is correct, please go ahead.


 The corrected code is attached as DES_is_weak_key.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DES_is_weak_key.c
Type: application/octet-stream
Size: 909 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20040618/130c7b4f/DES_is_weak_key.obj


More information about the wine-patches mailing list