Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/687#discussion_r32218356
--- Diff:
usage/rest-server/src/main/java/brooklyn/rest/security/PasswordHasher.java ---
@@ -24,8 +24,9 @@
public class PasswordHasher {
public static String sha256(String salt, String password) {
- byte[] salted = Charsets.UTF_8.encode((salt == null ? "" : salt) +
password).array();
- HashCode hash = Hashing.sha256().hashBytes(salted);
+ if (salt == null) salt = "";
+ byte[] bytes = (salt + password).getBytes(Charsets.UTF_8);
--- End diff --
Appreciate this is existing behaviour but calling `sha256(null, null)` will
mean we hash "null" (so always
`74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b`). I think
this is a bit surprising and potentially revealing. Should we throw if
`password` is null?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---