summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/HashFunction.cc31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/HashFunction.cc b/lib/HashFunction.cc
index 1904f49..9f165e4 100644
--- a/lib/HashFunction.cc
+++ b/lib/HashFunction.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: HashFunction.cc,v 1.1 2007-09-05 14:11:54 pixel Exp $ */
+/* $Id: HashFunction.cc,v 1.2 2007-09-17 16:04:40 pixel Exp $ */
#include <sha1.h>
#include <sha256.h>
@@ -40,6 +40,35 @@ void HashFunction::Update(const unsigned char * data, size_t len) {
update(data, len);
}
+#define BLKSIZE 1024
+void HashFunction::Update(Handle * h, ssize_t size) {
+ static Uint8 blk[BLKSIZE];
+ long r;
+
+ if (size < 0)
+ size = h->GetSize();
+
+ LOCK;
+
+ while (size) {
+ if ((size > BLKSIZE) || (size < 0)) {
+ r = h->read(blk, BLKSIZE);
+ if (r)
+ Update(blk, r);
+ } else {
+ r = h->read(blk, size);
+ if (r)
+ Update(blk, r);
+ }
+ if (!r)
+ break;
+ if (size > 0)
+ size -= r;
+ }
+
+ UNLOCK;
+}
+
String HashFunction::Finish() {
char digest_r[513];
int i;