X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fdes%2Fenc_writ.c;h=2353ac1e892fd3310b68450293ad030cfc70147e;hb=5a456140c18597c3219a16a34344a23c6dad95cc;hp=763765ec39e6d6b49900982495c15813b8f2a3a8;hpb=61f5b6f33807306d09bccbc2dcad474d1d04ca40;p=oweals%2Fopenssl.git diff --git a/crypto/des/enc_writ.c b/crypto/des/enc_writ.c index 763765ec39..2353ac1e89 100644 --- a/crypto/des/enc_writ.c +++ b/crypto/des/enc_writ.c @@ -61,13 +61,14 @@ #include #include "cryptlib.h" #include "des_locl.h" +#include /* * WARNINGS: * - * - The data format used by des_enc_write() and des_enc_read() + * - The data format used by DES_enc_write() and DES_enc_read() * has a cryptographic weakness: When asked to write more - * than MAXWRITE bytes, des_enc_write will split the data + * than MAXWRITE bytes, DES_enc_write will split the data * into several chunks that are all encrypted * using the same IV. So don't use these functions unless you * are sure you know what you do (in which case you might @@ -76,13 +77,14 @@ * - This code cannot handle non-blocking sockets. */ -int des_enc_write(int fd, const void *_buf, int len, - des_key_schedule sched, des_cblock iv) +int DES_enc_write(int fd, const void *_buf, int len, + DES_key_schedule *sched, DES_cblock *iv) { +#if defined(OPENSSL_NO_POSIX_IO) + return (-1); +#else #ifdef _LIBC - extern int srandom(); extern unsigned long time(); - extern int random(); extern int write(); #endif const unsigned char *buf=_buf; @@ -96,7 +98,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 +106,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 */ @@ -113,7 +114,7 @@ int des_enc_write(int fd, const void *_buf, int len, j=0; for (i=0; i MAXWRITE)?MAXWRITE:(len-i),sched,iv); if (k < 0) return(k); @@ -132,21 +133,20 @@ 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 */ } - if (des_rw_mode & DES_PCBC_MODE) - des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, + if (DES_rw_mode & DES_PCBC_MODE) + DES_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, DES_ENCRYPT); else - des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, + DES_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, DES_ENCRYPT); /* output */ @@ -155,17 +155,25 @@ int des_enc_write(int fd, const void *_buf, int len, for (j=0; j