Mostly copied from openwall source, leaving out the unsupported 2x tests and special bug-related tests for passwords containing 0xFF bytes.