]> WPIA git - gigi.git/blobdiff - lib/scrypt/com/lambdaworks/crypto/SCryptUtil.java
Guard division by zero in SCrypt verification.
[gigi.git] / lib / scrypt / com / lambdaworks / crypto / SCryptUtil.java
index 6d794000d44bdb682a7a9fedc7dee918ceaf3632..808d69f472a95c4ff779b7912a3b1888b7ed59d5 100644 (file)
@@ -89,6 +89,9 @@ public class SCryptUtil {
             int N = (int) Math.pow(2, params >> 16 & 0xffff);
             int r = (int) params >> 8 & 0xff;
             int p = (int) params & 0xff;
+            if (r == 0 || p == 0) {
+                return false;
+            }
 
             byte[] derived1 = SCrypt.scrypt(passwd.getBytes("UTF-8"), salt, N, r, p, 32);