Skip to content

Commit b5cda34

Browse files
committed
More review comments addressed
1 parent 4769c62 commit b5cda34

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

auth0/src/main/java/com/auth0/android/authentication/storage/CryptoUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class CryptoUtil {
6868

6969
private static final int GCM_TAG_LENGTH = 16;
7070
private static final int MIN_DATA_LENGTH = 1;
71+
private static final int FORMAT_HEADER_LENGTH = 2;
7172

7273
private final String OLD_KEY_ALIAS;
7374
private final String OLD_KEY_IV_ALIAS;
@@ -469,7 +470,7 @@ public byte[] decrypt(byte[] encryptedInput) throws CryptoException, Incompatibl
469470
* @return true if new format, false if legacy format
470471
*/
471472
@VisibleForTesting
472-
boolean isNewFormat(byte[] encryptedInput) {
473+
private boolean isNewFormat(byte[] encryptedInput) {
473474

474475
// Boundary check
475476
if (encryptedInput == null || encryptedInput.length < 2) {
@@ -493,7 +494,7 @@ boolean isNewFormat(byte[] encryptedInput) {
493494

494495
// Verify minimum total length
495496
// Need: marker(1) + length(1) + IV(12-16) + GCM tag(16) + data(1+)
496-
int minLength = 2 + ivLength + GCM_TAG_LENGTH + MIN_DATA_LENGTH;
497+
int minLength = FORMAT_HEADER_LENGTH + ivLength + GCM_TAG_LENGTH + MIN_DATA_LENGTH;
497498
return encryptedInput.length >= minLength;
498499
}
499500

auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,9 +969,9 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
969969
//Check if existing api credentials are present and valid
970970

971971
encryptedEncodedJson?.let { encryptedEncoded ->
972-
val decoded = Base64.decode(encryptedEncoded, Base64.DEFAULT)
972+
val encrypted = Base64.decode(encryptedEncoded, Base64.DEFAULT)
973973
val json: String = try {
974-
String(crypto.decrypt(decoded))
974+
String(crypto.decrypt(encrypted))
975975
} catch (e: IncompatibleDeviceException) {
976976
callback.onFailure(
977977
CredentialsManagerException(

0 commit comments

Comments
 (0)