- des_set_odd_parity(key1);
- des_set_odd_parity(key2);
- des_set_key_unchecked(key1,&ks);
- des_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1);
- des_set_key_unchecked(key2,&ks);
- des_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2);
- memset(&ks,0,sizeof(ks));
- des_set_odd_parity(key1);
- des_set_odd_parity(key2);
+ DES_set_odd_parity(key1);
+ DES_set_odd_parity(key2);
+#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
+ if(DES_is_weak_key(key1))
+ (*key1)[7] ^= 0xF0;
+ DES_set_key(key1,&ks);
+#else
+ DES_set_key_unchecked(key1,&ks);
+#endif
+ DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1);
+#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
+ if(DES_is_weak_key(key2))
+ (*key2)[7] ^= 0xF0;
+ DES_set_key(key2,&ks);
+#else
+ DES_set_key_unchecked(key2,&ks);
+#endif
+ DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2);
+ OPENSSL_cleanse(&ks,sizeof(ks));
+ DES_set_odd_parity(key1);
+ DES_set_odd_parity(key2);