Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Wrong parameters order in one constructor #73

Open
alaegin opened this issue Jan 2, 2018 · 6 comments
Open

Wrong parameters order in one constructor #73

alaegin opened this issue Jan 2, 2018 · 6 comments
Assignees

Comments

@alaegin
Copy link

alaegin commented Jan 2, 2018

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.

@scottyab
Copy link
Owner

scottyab commented Jan 4, 2018

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

@scottyab scottyab self-assigned this Jan 4, 2018
@alaegin
Copy link
Author

alaegin commented Jan 5, 2018

One more mistake.
Screenshot

We pass null salt as password and password as salt.

@scottyab
Copy link
Owner

scottyab commented Jan 5, 2018

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

secure-preferences__git_

@alaegin
Copy link
Author

alaegin commented Jan 5, 2018

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

@Plinzen
Copy link

Plinzen commented Jun 21, 2018

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);
        }
        ...

@LosDanieloss
Copy link

@scottyab Any progress on that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants