Skip to content

Commit

Permalink
Fixed #2, cleared the bug in sequence of encryption and hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil committed Apr 7, 2018
1 parent d87bf21 commit 8931a03
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 105 deletions.
138 changes: 44 additions & 94 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified out/artifacts/minAR_jar/minAR.jar
Binary file not shown.
19 changes: 8 additions & 11 deletions src/io/minAR/core/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ public void analyze(boolean compressed, boolean ENCRYPTED, boolean HASH, SecretK
byte[] serialized_data = null;
byte[] apparent_data = Files.readAllBytes(ar_file);
if(HASH){
Analyzer.PairOfDisjointBytes bytes = Analyzer.split(64, apparent_data);
byte[] dec_apparent_data = Crypt.decrypt(apparent_data, secretKey);
Analyzer.PairOfDisjointBytes bytes = Analyzer.split(64, dec_apparent_data);
if(Hash.checkHash(bytes.bytes1, bytes.bytes2)){
if(ENCRYPTED){
serialized_data = Crypt.decrypt(bytes.bytes2, secretKey);
} else {
serialized_data = bytes.bytes2;
}
serialized_data = bytes.bytes2;
} else {
throw new MalformedDataException("The file" + ar_file.toString() + "is damaged; identical data absent.... [ERR: Hashes do not match]");
throw new MalformedDataException(ar_file);
}
} else {
if(ENCRYPTED){ // When apparent data is encrypted
Expand Down Expand Up @@ -125,14 +122,14 @@ private File mkfile(String path){
}

private class MalformedDataException extends RuntimeException {
String string;
public MalformedDataException(String s) {
string = s;
String ar_file;
public MalformedDataException(Path path) {
ar_file = path.toString();
}

@Override
public String getMessage() {
return string;
return "The file " + ar_file + " is damaged; identical data absent.... [ERR: Hashes do not match]";
}
}
}

0 comments on commit 8931a03

Please sign in to comment.