You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/05/16 15:03:58 UTC

[GitHub] [accumulo] dlmarion commented on a diff in pull request #2707: Cached last 16 successful ZKSecurityTool.checkCryptPass password checks

dlmarion commented on code in PR #2707:
URL: https://github.com/apache/accumulo/pull/2707#discussion_r873839467


##########
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:
   I was thinking that we would not want to store the output of any crypt function. Instead, I was just capturing the fact that two pieces of information had returned a true result in the recent past, and using it to short circuit the method. Is there any benefit to recalculating whether the two hashes are equal?



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org