- if (tmpbuf == NULL)
- {
- tmpbuf=(char *)malloc(BSIZE);
- if (tmpbuf == NULL) return(-1);
- }
- if (net == NULL)
- {
- net=(unsigned char *)malloc(BSIZE);
- if (net == NULL) return(-1);
- }
- if (unnet == NULL)
- {
- unnet=(char *)malloc(BSIZE);
- if (unnet == NULL) return(-1);
- }
- /* left over data from last decrypt */
- if (unnet_left != 0)
- {
- if (unnet_left < len)
- {
- /* we still still need more data but will return
- * with the number of bytes we have - should always
- * check the return value */
- memcpy(buf,&(unnet[unnet_start]),
- (unsigned int)unnet_left);
- /* eay 26/08/92 I had the next 2 lines
- * reversed :-( */
- i=unnet_left;
- unnet_start=unnet_left=0;
- }
- else
- {
- memcpy(buf,&(unnet[unnet_start]),(unsigned int)len);
- unnet_start+=len;
- unnet_left-=len;
- i=len;
- }
- return(i);
- }
+/*-
+ * WARNINGS:
+ *
+ * - 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
+ * 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
+ * not want to use them anyway).
+ *
+ * - This code cannot handle non-blocking sockets.
+ *
+ * - This function uses an internal state and thus cannot be
+ * used on multiple files.
+ */
+int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
+ DES_cblock *iv)
+{
+#if defined(OPENSSL_NO_POSIX_IO)
+ return (0);
+#else
+ /* data to be unencrypted */
+ int net_num = 0;
+ static unsigned char *net = NULL;
+ /*
+ * extra unencrypted data for when a block of 100 comes in but is
+ * des_read one byte at a time.
+ */
+ static unsigned char *unnet = NULL;
+ static int unnet_start = 0;
+ static int unnet_left = 0;
+ static unsigned char *tmpbuf = NULL;
+ int i;
+ long num = 0, rnum;
+ unsigned char *p;