Hi,

Are we interested in that kind of change (see attached diff) or do we
strictly stick to the original source that was bundled in libvarnish?

Dridi
diff --git c/include/vsha256.h i/include/vsha256.h
index 8f20505fce..b7c9872da7 100644
--- c/include/vsha256.h
+++ i/include/vsha256.h
@@ -41,6 +41,7 @@ typedef struct VSHA256Context {
 void	VSHA256_Init(VSHA256_CTX *);
 void	VSHA256_Update(VSHA256_CTX *, const void *, size_t);
 void	VSHA256_Final(unsigned char [VSHA256_LEN], VSHA256_CTX *);
+int	VSHA256_Fd(unsigned char [static VSHA256_LEN], int);
 void	VSHA256_Test(void);
 
 #define SHA256_LEN		VSHA256_LEN
diff --git c/lib/libvarnish/vsha256.c i/lib/libvarnish/vsha256.c
index 73efb0b2bd..dbad4aae95 100644
--- c/lib/libvarnish/vsha256.c
+++ i/lib/libvarnish/vsha256.c
@@ -42,6 +42,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "vdef.h"
 
@@ -49,6 +50,10 @@
 #include "vend.h"
 #include "vsha256.h"
 
+#ifndef VSHA256_BUF_LEN
+#  define VSHA256_BUF_LEN 4096
+#endif
+
 #if defined(VBYTE_ORDER) && VBYTE_ORDER == VBIG_ENDIAN
 
 /* Copy a vector of big-endian uint32_t into a vector of bytes */
@@ -318,6 +323,21 @@ VSHA256_Final(unsigned char digest[static VSHA256_DIGEST_LENGTH],
 	memset((void *)ctx, 0, sizeof(*ctx));
 }
 
+int
+VSHA256_Fd(unsigned char digest[static VSHA256_DIGEST_LENGTH], int fd)
+{
+	struct VSHA256Context c;
+	char buf[VSHA256_BUF_LEN];
+	ssize_t sz;
+
+	VSHA256_Init(&c);
+	while ((sz = read(fd, buf, sizeof buf)) > 0)
+		VSHA256_Update(&c, buf, sz);
+	if (sz == 0)
+		VSHA256_Final(digest, &c);
+	return (sz);
+}
+
 /*
  * A few test-vectors, just in case
  */
_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to