memset(key, 0, 8);
length = strlen(str);
-#ifdef OLD_STR_TO_KEY
- for (i = 0; i < length; i++)
- (*key)[i % 8] ^= (str[i] << 1);
-#else /* MIT COMPATIBLE */
for (i = 0; i < length; i++) {
register unsigned char j = str[i];
(*key)[7 - (i % 8)] ^= j;
}
}
-#endif
DES_set_odd_parity(key);
DES_set_key_unchecked(key, &ks);
DES_cbc_cksum((const unsigned char *)str, key, length, &ks, key);
memset(key1, 0, 8);
memset(key2, 0, 8);
length = strlen(str);
-#ifdef OLD_STR_TO_KEY
- if (length <= 8) {
- for (i = 0; i < length; i++) {
- (*key2)[i] = (*key1)[i] = (str[i] << 1);
- }
- } else {
- for (i = 0; i < length; i++) {
- if ((i / 8) & 1)
- (*key2)[i % 8] ^= (str[i] << 1);
- else
- (*key1)[i % 8] ^= (str[i] << 1);
- }
- }
-#else /* MIT COMPATIBLE */
for (i = 0; i < length; i++) {
register unsigned char j = str[i];
}
if (length <= 8)
memcpy(key2, key1, 8);
-#endif
DES_set_odd_parity(key1);
DES_set_odd_parity(key2);
DES_set_key_unchecked(key1, &ks);