keith-turner commented on code in PR #2707:
URL: https://github.com/apache/accumulo/pull/2707#discussion_r873873046
##########
server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKSecurityTool.java:
##########
@@ -114,16 +120,27 @@ public static byte[] createPass(byte[] password) throws
AccumuloException {
return cryptHash.getBytes(UTF_8);
}
+ private static final Map<List<Byte>,String> CHECKED_CRYPT_PASSWORDS =
+ Collections.synchronizedMap(new LRUMap<>(16));
+
public static boolean checkCryptPass(byte[] password, byte[] zkData) {
+ List<Byte> key = Bytes.asList(password);
String zkDataString = new String(zkData, UTF_8);
+ if (CHECKED_CRYPT_PASSWORDS.getOrDefault(key, "").equals(zkDataString)) {
+ return true;
+ }
String cryptHash;
try {
cryptHash = Crypt.crypt(password, zkDataString);
Review Comment:
Was just thinking very literally and trying to avoid shortcuts since its
security related. The function takes two inputs and gives a single output, so
was thinking of caching that functions input and output exactly rather than
caching a partial was more secure. Caching only a single input parameter (the
password) felt kind dicey. Like what if two account have the same password
with different salts, then what will happen with the cache?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]