Skip to content

Commit

Permalink
XOR the last byte of weak keys with 0xf0, according to spec.
Browse files Browse the repository at this point in the history
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7156 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information
probe committed Dec 2, 1995
1 parent 730dd4a commit fda4d92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/crypto/des/d3_str2ky.c
Expand Up @@ -103,7 +103,7 @@ const krb5_data FAR * salt;
for (j = 0; j < keyblock->length/sizeof(mit_des_cblock); j++) {
mit_des_fixup_key_parity(key[j]);
if (mit_des_is_weak_key(key[j]))
*((krb5_octet *)(key[j])) ^= 0xf0;
((krb5_octet *)(key[j]))[7] ^= 0xf0;
}

/* Now, CBC encrypt with itself */
Expand All @@ -127,7 +127,7 @@ const krb5_data FAR * salt;
for (j = 0; j < keyblock->length/sizeof(mit_des_cblock); j++) {
mit_des_fixup_key_parity(key[j]);
if (mit_des_is_weak_key(key[j]))
*((krb5_octet *)(key[j])) ^= 0xf0;
((krb5_octet *)(key[j]))[7] ^= 0xf0;
}

return 0;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/crypto/des/string2key.c
Expand Up @@ -144,6 +144,8 @@ const krb5_data FAR * salt;

/* fix key parity */
mit_des_fixup_key_parity(key);
if (mit_des_is_weak_key(key))
((krb5_octet *)key)[7] ^= 0xf0;

/* Now one-way encrypt it with the folded key */
(void) mit_des_key_sched(key, key_sked);
Expand All @@ -157,6 +159,8 @@ const krb5_data FAR * salt;

/* now fix up key parity again */
mit_des_fixup_key_parity(key);
if (mit_des_is_weak_key(key))
((krb5_octet *)key)[7] ^= 0xf0;

#if 0
if (mit_des_debug)
Expand Down

0 comments on commit fda4d92

Please sign in to comment.