From c3042042c1fc2a9d86bf05caa54e6695040a332d Mon Sep 17 00:00:00 2001 From: lvaccaro Date: Mon, 27 Feb 2017 11:11:46 +0100 Subject: [PATCH] Fix Verify --- src/OpCrypto.java | 2 +- src/OpenTimestamps.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpCrypto.java b/src/OpCrypto.java index cd91626..13cb231 100644 --- a/src/OpCrypto.java +++ b/src/OpCrypto.java @@ -65,7 +65,7 @@ public byte[] hashFd(StreamDeserializationContext ctx) { try { MessageDigest digest = MessageDigest.getInstance(this._HASHLIB_NAME()); byte[] chunk = ctx.read(1048576); - while (chunk.length>0){ + while (chunk!=null && chunk.length>0){ digest.update(chunk); chunk = ctx.read(1048576); } diff --git a/src/OpenTimestamps.java b/src/OpenTimestamps.java index 0336e5e..80d97e9 100644 --- a/src/OpenTimestamps.java +++ b/src/OpenTimestamps.java @@ -130,7 +130,7 @@ public static String verify(byte[]ots, byte[]plain, Boolean isHash) { StreamDeserializationContext ctx = new StreamDeserializationContext(ots); detachedTimestamp = DetachedTimestampFile.deserialize(ctx); } catch (Exception e) { - + System.err.print("StreamDeserializationContext error"); } byte[] actualFileDigest = new byte[0]; @@ -140,14 +140,14 @@ public static String verify(byte[]ots, byte[]plain, Boolean isHash) { StreamDeserializationContext ctxHashfd = new StreamDeserializationContext(plain); actualFileDigest = ((OpCrypto)(detachedTimestamp.fileHashOp)).hashFd(ctxHashfd); } catch (Exception e) { - + System.err.print("StreamDeserializationContext : file stream error"); } } else { // Read Hash try { actualFileDigest = plain.clone(); } catch (Exception e) { - + System.err.print("StreamDeserializationContext : file hash error"); } }