secure-preferences icon indicating copy to clipboard operation
secure-preferences copied to clipboard

Wrong parameters order in one constructor

Open alaegin opened this issue 7 years ago • 6 comments

Hello!

I noted wrong parameters order in one of the constructors.

We have main one (line 130) - private SecurePreferences(Context context, final AesCbcWithIntegrity.SecretKeys secretKey, final String password, final String salt, final String sharedPrefFilename, int iterationCount) Params:

  1. context
  2. secretKey
  3. password
  4. salt
  5. sharedPrefFilename
  6. iterationCount

Also, we have another one (line 126) - public SecurePreferences(Context context, final String password, final String salt, final String sharedPrefFilename, int iterationCount) { this(context, null, password, sharedPrefFilename, salt, iterationCount); }

If we see to "this()" call to main one we can note that we have this order:

  1. context
  2. secretKey
  3. password
  4. sharedPrefFilename
  5. salt
  6. iterationCount

Good. But, if we consider in detail, in main constructor we have 4. salt (instead of sharedPrefFilename in second one) 5. sharedPrefFilename (instead of salt in second one)

Screenshot

Maybe i'm wrong, but my xml files have are named with my password string and only after fixing order I got right file names.

Hope it helps. Regards, Alexey.

alaegin avatar Jan 02 '18 23:01 alaegin

Hey @DominuS-RU nice spot thanks. This will be fixed in 0.1.6

scottyab avatar Jan 04 '18 14:01 scottyab

One more mistake. Screenshot

We pass null salt as password and password as salt.

alaegin avatar Jan 05 '18 13:01 alaegin

to confirm this is the switch you meant @DominuS-RU?.

secure-preferences__git_

scottyab avatar Jan 05 '18 14:01 scottyab

@scottyab Yes, this is the swith for the first one. (The second screenshot is about another mistake)

alaegin avatar Jan 05 '18 14:01 alaegin

Hi, is there a release date for this fix? In 0.1.6 it's still present:

     /**
     * @param context        should be ApplicationContext not Activity
     * @param iterationCount The iteration count for the keys generation
     */
    public SecurePreferences(Context context, final String password, final String salt, final String sharedPrefFilename, int iterationCount) {
        this(context, null, password, sharedPrefFilename, salt, iterationCount);
    }

    private SecurePreferences(Context context, final AesCbcWithIntegrity.SecretKeys secretKey, final String password, final String salt, final String sharedPrefFilename, int iterationCount) {
        if (sharedPreferences == null) {
            sharedPreferences = getSharedPreferenceFile(context, sharedPrefFilename);
        }
        ...

Plinzen avatar Jun 21 '18 11:06 Plinzen

@scottyab Any progress on that?

LosDanieloss avatar Oct 24 '18 13:10 LosDanieloss