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"); } }