]> nmode's Git Repositories - signal-cli/commitdiff
Only send plain text pin if locked with registration lock v1
authorAsamK <asamk@gmx.de>
Thu, 13 May 2021 08:35:01 +0000 (10:35 +0200)
committerAsamK <asamk@gmx.de>
Thu, 13 May 2021 08:35:01 +0000 (10:35 +0200)
lib/src/main/java/org/asamk/signal/manager/RegistrationManager.java

index 9dae3f41376fc043c8c906962f2b4ce761983c0d..88cba97bc475436306a2362b26ee5f0c829fbaed 100644 (file)
@@ -129,9 +129,10 @@ public class RegistrationManager implements Closeable {
         VerifyAccountResponse response;
         MasterKey masterKey;
         try {
         VerifyAccountResponse response;
         MasterKey masterKey;
         try {
-            response = verifyAccountWithCode(verificationCode, pin, null);
+            response = verifyAccountWithCode(verificationCode, null, null);
 
             masterKey = null;
 
             masterKey = null;
+            pin = null;
         } catch (LockedException e) {
             if (pin == null) {
                 throw e;
         } catch (LockedException e) {
             if (pin == null) {
                 throw e;
@@ -139,16 +140,17 @@ public class RegistrationManager implements Closeable {
 
             var registrationLockData = pinHelper.getRegistrationLockData(pin, e);
             if (registrationLockData == null) {
 
             var registrationLockData = pinHelper.getRegistrationLockData(pin, e);
             if (registrationLockData == null) {
-                throw e;
-            }
-
-            var registrationLock = registrationLockData.getMasterKey().deriveRegistrationLock();
-            try {
-                response = verifyAccountWithCode(verificationCode, null, registrationLock);
-            } catch (LockedException _e) {
-                throw new AssertionError("KBS Pin appeared to matched but reg lock still failed!");
+                response = verifyAccountWithCode(verificationCode, pin, null);
+                masterKey = null;
+            } else {
+                var registrationLock = registrationLockData.getMasterKey().deriveRegistrationLock();
+                try {
+                    response = verifyAccountWithCode(verificationCode, null, registrationLock);
+                } catch (LockedException _e) {
+                    throw new AssertionError("KBS Pin appeared to matched but reg lock still failed!");
+                }
+                masterKey = registrationLockData.getMasterKey();
             }
             }
-            masterKey = registrationLockData.getMasterKey();
         }
 
         // TODO response.isStorageCapable()
         }
 
         // TODO response.isStorageCapable()