cleanup.
[openssl.git] / crypto / des / rand_key.c
index 7816a8f..ee1a6c2 100644 (file)
@@ -63,7 +63,11 @@ void des_random_seed(des_cblock *key)
 
 int des_random_key(des_cblock *ret)
        {
-       int r = RAND_bytes((unsigned char *)ret, sizeof(des_cblock));
+       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 r;
+       return (1);
        }