RAND_bytes updates
[openssl.git] / crypto / bio / bf_nbio.c
index da88a8a1bfbdbb1eb12fda451aede4699bab02a5..0ba6055e07d55ee86eed617b6661a5f458cd6252 100644 (file)
@@ -127,10 +127,8 @@ static int nbiof_free(BIO *a)
 static int nbiof_read(BIO *b, char *out, int outl)
 {
     int ret = 0;
-#if 1
     int num;
     unsigned char n;
-#endif
 
     if (out == NULL)
         return (0);
@@ -138,8 +136,8 @@ static int nbiof_read(BIO *b, char *out, int outl)
         return (0);
 
     BIO_clear_retry_flags(b);
-#if 1
-    RAND_pseudo_bytes(&n, 1);
+    if (RAND_bytes(&n, 1) <= 0)
+        return -1;
     num = (n & 0x07);
 
     if (outl > num)
@@ -148,9 +146,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
     if (num == 0) {
         ret = -1;
         BIO_set_retry_read(b);
-    } else
-#endif
-    {
+    } else {
         ret = BIO_read(b->next_bio, out, outl);
         if (ret < 0)
             BIO_copy_next_retry(b);
@@ -173,12 +169,12 @@ static int nbiof_write(BIO *b, const char *in, int inl)
 
     BIO_clear_retry_flags(b);
 
-#if 1
     if (nt->lwn > 0) {
         num = nt->lwn;
         nt->lwn = 0;
     } else {
-        RAND_pseudo_bytes(&n, 1);
+        if (RAND_bytes(&n, 1) <= 0)
+            return -1;
         num = (n & 7);
     }
 
@@ -188,9 +184,7 @@ static int nbiof_write(BIO *b, const char *in, int inl)
     if (num == 0) {
         ret = -1;
         BIO_set_retry_write(b);
-    } else
-#endif
-    {
+    } else {
         ret = BIO_write(b->next_bio, in, inl);
         if (ret < 0) {
             BIO_copy_next_retry(b);