- RAND_seed(key, sizeof(des_cblock));
- }
-
-void des_random_key(des_cblock *ret)
- {
- RAND_bytes((unsigned char *)ret, sizeof(des_cblock));
- des_set_odd_parity(ret);
+ do
+ {
+ if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
+ return (0);
+ } while (DES_is_weak_key(ret));
+ DES_set_odd_parity(ret);
+ return (1);