Skip to content
Open
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 @@ -87,7 +87,7 @@ public class Sha2Crypt {

/** The pattern to match valid salt values. */
private static final Pattern SALT_PATTERN = Pattern
.compile("^\\$([56])\\$(rounds=(\\d+)\\$)?([\\.\\/a-zA-Z0-9]{1,16}).*");
.compile("^\\$([56])\\$(rounds=(\\d+)\\$)?([\\.\\/a-zA-Z0-9]{1,16})[\\.\\/a-zA-Z0-9]*(?:\\$.*)?$");

/**
* Finds the first non-zero digit, retaining one zero for an all-zero value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ void testSha2CryptRounds() {
@Test
void testSha2CryptWrongSalt() {
assertThrows(IllegalArgumentException.class, () -> Sha2Crypt.sha512Crypt("secret".getBytes(StandardCharsets.UTF_8), "xx"));
assertThrows(IllegalArgumentException.class,
() -> Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8), "$5$notrounds=1000$asdfasdf"));
assertThrows(IllegalArgumentException.class,
() -> Sha2Crypt.sha512Crypt("secret".getBytes(StandardCharsets.UTF_8), "$6$rounds=1000$äöüäöü"));
}

@Test
Expand Down
Loading