Skip to content

Commit

Permalink
Fix Verify
Browse files Browse the repository at this point in the history
  • Loading branch information
lvaccaro committed Feb 27, 2017
1 parent 591119d commit c304204
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/OpCrypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/OpenTimestamps.java
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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");
}
}

Expand Down

0 comments on commit c304204

Please sign in to comment.