ispell.
[oweals/openssl.git] / crypto / des / enc_writ.c
index 763765ec39e6d6b49900982495c15813b8f2a3a8..cc2b50fb509291d2bdfd195a82fecfde6eddfe61 100644 (file)
@@ -61,6 +61,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include "des_locl.h"
+#include <openssl/rand.h>
 
 /*
  * WARNINGS:
  */
 
 int des_enc_write(int fd, const void *_buf, int len,
-                 des_key_schedule sched, des_cblock iv)
+                 des_key_schedule sched, des_cblock *iv)
        {
 #ifdef _LIBC
-       extern int srandom();
        extern unsigned long time();
-       extern int random();
        extern int write();
 #endif
        const unsigned char *buf=_buf;
@@ -96,7 +95,7 @@ int des_enc_write(int fd, const void *_buf, int len,
 
        if (outbuf == NULL)
                {
-               outbuf=Malloc(BSIZE+HDRSIZE);
+               outbuf=OPENSSL_malloc(BSIZE+HDRSIZE);
                if (outbuf == NULL) return(-1);
                }
        /* If we are sending less than 8 bytes, the same char will look
@@ -104,7 +103,6 @@ int des_enc_write(int fd, const void *_buf, int len,
        if (start)
                {
                start=0;
-               srandom(time(NULL));
                }
 
        /* lets recurse if we want to send the data in small chunks */
@@ -132,13 +130,12 @@ int des_enc_write(int fd, const void *_buf, int len,
                {
                cp=shortbuf;
                memcpy(shortbuf,buf,len);
-               for (i=len; i<8; i++)
-                       shortbuf[i]=random();
+               RAND_pseudo_bytes(shortbuf+len, 8-len);
                rnum=8;
                }
        else
                {
-               cp=(unsigned char*)buf;
+               cp=buf;
                rnum=((len+7)/8*8); /* round up to nearest eight */
                }
 
@@ -155,13 +152,16 @@ int des_enc_write(int fd, const void *_buf, int len,
        for (j=0; j<outnum; j+=i)
                {
                /* eay 26/08/92 I was not doing writing from where we
-                * got upto. */
-               i=write(fd,&(outbuf[j]),outnum-j);
+                * got up to. */
+               i=write(fd,(void *)&(outbuf[j]),outnum-j);
                if (i == -1)
                        {
+#ifdef EINTR
                        if (errno == EINTR)
                                i=0;
-                       else    /* This is really a bad error - very bad
+                       else
+#endif
+                               /* This is really a bad error - very bad
                                 * It will stuff-up both ends. */
                                return(-1);
                        }