Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 305 #394

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void generateSecPwd() {
TestUtils.openJavaFileInWorkspace(developerProject, Constants.PackageName, encClassUnit);
assertEquals(5, TestUtils.countMethods(encClassUnit));
assertEquals(12, TestUtils.countStatements(encClassUnit, "createPWHash"));
assertEquals(11, TestUtils.countStatements(encClassUnit, "verifyPWHash"));
assertEquals(13, TestUtils.countStatements(encClassUnit, "verifyPWHash"));
}
catch (JavaModelException e) {
Activator.getDefault().logError(e, "Could not create Java class in test project.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static boolean verifyPWHash(char[] pwd, java.lang.String pwdhash) throws
byte[] res = null;
int keysize = 160;

CrySLCodeGenerator.getInstance().includeClass("java.security.PBEKeySpec").addParameter(pwd, "password").addParameter(salt, "salt").addParameter(keysize, "keylength")
CrySLCodeGenerator.getInstance().includeClass("java.security.SecureRandom").addParameter(salt, "next").includeClass("java.security.PBEKeySpec").addParameter(pwd, "password").addParameter(salt, "salt").addParameter(keysize, "keylength")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, though. The verification must not randomize the hash, but take the one that is used for the creation of the hash (as defined in line 35).

.includeClass("javax.crypto.SecretKeyFactory").includeClass("java.security.SecretKey").addReturnObject(res).generate();

Boolean areEqual = slowEquals(res, fromBase64(parts[1]));
Expand Down