-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/sdk 4214/Encryption v2 #719
Merged
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
a195d02
task(SDK-4206) - Adds AES-GCM crypt class
Anush-Shand 4b494d4
feat(SDK-4214): fixes conflict in cherry pick
Anush-Shand 0b233b6
chore(SDK-4214): adds arg names and when instead of if else
CTLalit f7583df
feat(SDK-4214): sanitises code
CTLalit 2207291
feat(SDK-4214): replaces trim with substring
CTLalit aff0d53
chore(SDK-4214): code readability.
CTLalit 38ae018
feat(SDK-4214): Simplifies encryption logic
CTLalit c049136
task(SDK-4214) - Adds logic for encryption migration based on new app…
Anush-Shand 991d27c
task(SDK-4214) - Fixes migrationStep
Anush-Shand a6d26eb
task(SDK-4214) - Fixes migrationStep for InApp data
Anush-Shand 2d0628b
task(SDK-4214) - Cleanup and readability
Anush-Shand 6e3f12f
task(SDK-4214) - Cleanup and formatting
Anush-Shand ac38ef2
task(SDK-4214) - Improves readability
Anush-Shand d8a9f6f
task(SDK-4214) - More syntactic sugar
Anush-Shand 1a91c44
task(SDK-4214) - Makes prefix and postfix more complex to make it les…
Anush-Shand 18ca5e3
task(SDK-4214) - Adds logic for saving data if AES -> plaintext passe…
Anush-Shand bab4cbb
task(SDK-4214) - Addresses comments
Anush-Shand cd76103
task(SDK-4214) - Adds support for API 21 and 22
Anush-Shand d58f5a8
task(SDK-4206) - Adds AES-GCM crypt class
Anush-Shand 1a5ba2c
feat(SDK-4214): fixes conflict in cherry pick
Anush-Shand c39e449
chore(SDK-4214): adds arg names and when instead of if else
CTLalit 1ef433a
feat(SDK-4214): sanitises code
CTLalit 301c7d1
feat(SDK-4214): replaces trim with substring
CTLalit ef8961c
chore(SDK-4214): code readability.
CTLalit b967d51
feat(SDK-4214): Simplifies encryption logic
CTLalit e6ebd3f
task(SDK-4214) - Adds logic for encryption migration based on new app…
Anush-Shand 931265c
task(SDK-4214) - Fixes migrationStep
Anush-Shand 16ff5dc
task(SDK-4214) - Fixes migrationStep for InApp data
Anush-Shand 2e7235d
task(SDK-4214) - Cleanup and readability
Anush-Shand ccf969e
task(SDK-4214) - Cleanup and formatting
Anush-Shand 4927e76
task(SDK-4214) - Improves readability
Anush-Shand 3478caf
task(SDK-4214) - More syntactic sugar
Anush-Shand 51b5331
task(SDK-4214) - Makes prefix and postfix more complex to make it les…
Anush-Shand e716536
task(SDK-4214) - Adds logic for saving data if AES -> plaintext passe…
Anush-Shand be361df
task(SDK-4214) - Addresses comments
Anush-Shand 2573cd8
task(SDK-4214) - Adds support for API 21 and 22
Anush-Shand e16ea55
Merge remote-tracking branch 'origin/feat/SDK-4214/trunk' into feat/S…
Anush-Shand e862c45
feat(SDK-4214): Fixes compilation error
CTLalit b7b0a78
Merge remote-tracking branch 'origin/feat/SDK-4214/trunk' into feat/S…
Anush-Shand 6cc98c7
task(SDK-4214) - Migrates to new format for cgk
Anush-Shand ecfbea0
task(SDK-4214) - Injects cryptHandler as necessary
Anush-Shand 4bf92db
task(SDK-4214) - Prevents unnecessary calls to store cachedGUIDSKey i…
Anush-Shand b41446e
task(SDK-4214) - Prevents passing null to .decrypt()
Anush-Shand be91902
task(SDK-4214) - Adds algo to .decrypt()
Anush-Shand b3deee2
task(SDK-4214) - Adds algo to .decrypt()
Anush-Shand 7477c44
task(SDK-4214) - Adds algo to .encrypt()
Anush-Shand 9ba9df9
task(SDK-4214) - Reduces number of calls to .decrypt
Anush-Shand 543b345
feat/SDK-4215/Refactoring to make Crypt feature testable
CTLalit 3009ed6
task(SDK-4214) - Removes logic from enum class and adds to a function
Anush-Shand eaf271a
task(SDK-4214) - Adds todo
Anush-Shand 9a5998f
task(SDK-4214) - Refactors LoginInfoProvider round1
Anush-Shand e6e870e
task(SDK-4214) - Adds a common check for isTextEncrypted()
Anush-Shand 7a5c859
task(SDK-4214) - Adds comments
Anush-Shand 708aa82
task(SDK-4214) - Makes migrationresult internal
Anush-Shand ddfff07
task(SDK-4214) - Improves comments
Anush-Shand ffe0de7
task(SDK-4214) - Improves comments
Anush-Shand ea5c228
task(SDK-4214) - Fixes migration logic, firstUpgrade should always run
Anush-Shand ceb5fcc
task(SDK-4214) - Adds a log to indicate no migration needed
Anush-Shand a30ca08
feat(SDK-4214): bubbles up crypt factory
CTLalit 33ac099
feat(SDK-4214): makes classes internal
CTLalit 57e0897
test(SDK-4215): fixes compilation errors in tests
CTLalit 6ce7d10
test(SDK-4215): fixes login controller test
CTLalit 75abc45
Merge branch 'develop' into feat/SDK-4214/trunk
Anush-Shand 95b5b0f
task(SDK-4214) - Fixes an issue where migration was shortcircuited be…
Anush-Shand 8855892
test(SDK-4215): fixes crypthandler test
CTLalit 8c78871
task(SDK-4214) - Fixes an issue where migration from AES failed but o…
Anush-Shand 9e1b7d4
Merge remote-tracking branch 'origin/feat/SDK-4214/trunk' into feat/S…
Anush-Shand e7653f9
feat(SDK-4215): moves pref code to repo layer
CTLalit 3ebe726
feat(SDK-4215): moves repo out of main thread + cleanup
CTLalit 227caa2
feat(SDK-4215): removes try catch from migration steps
CTLalit 8b90180
feat(SDK-4215): removes try catch from migration steps 2
CTLalit cebf9fc
chore(SDK-4215): adds space
CTLalit 2125890
task(SDK-4214) - Fixes an issue where IV was 16 bytes instead of 12 f…
Anush-Shand 21f295b
task(SDK-4214) - Deletes the data if it can't be decrypted from AES
Anush-Shand 59d7f61
test(SDK-4215): fixes test clevertapapitest
CTLalit 7b0c461
task(SDK-4214) - Fixes logs
Anush-Shand b899f6f
tests(SDK-4214) - Fixes LoginInfoProviderTest
Anush-Shand 502b3f9
tests(SDK-4214) - Fixes LoginInfoProviderTest and ignores other
Anush-Shand 3d45ab4
task(SDK-4214) - Fixes log
Anush-Shand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,28 @@ class AESGCMCrypt(private val context: Context) : Crypt() { | |
} | ||
} | ||
|
||
private data class AESGCMCryptResult(val iv: ByteArray, val encryptedBytes: ByteArray) | ||
private data class AESGCMCryptResult( | ||
val iv: ByteArray, | ||
val encryptedBytes: ByteArray | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already auto generated by data class. Is there any difference? |
||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as AESGCMCryptResult | ||
|
||
if (!iv.contentEquals(other.iv)) return false | ||
if (!encryptedBytes.contentEquals(other.encryptedBytes)) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = iv.contentHashCode() | ||
result = 31 * result + encryptedBytes.contentHashCode() | ||
return result | ||
} | ||
} | ||
|
||
// Utility extension functions for Base64 encoding/decoding | ||
private fun ByteArray.toBase64(): String = Base64.encodeToString(this, Base64.NO_WRAP) | ||
|
26 changes: 22 additions & 4 deletions
26
clevertap-core/src/main/java/com/clevertap/android/sdk/cryption/CryptFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
package com.clevertap.android.sdk.cryption | ||
|
||
import android.content.Context | ||
import com.clevertap.android.sdk.cryption.CryptHandler.EncryptionAlgorithm | ||
|
||
/** | ||
* This class is a factory class to generate a Crypt object based on the EncryptionAlgorithm | ||
*/ | ||
class CryptFactory { | ||
internal class CryptFactory( | ||
private val context: Context, | ||
private val accountId: String | ||
) { | ||
|
||
// Cache to hold instances of Crypt for different encryption algorithms. | ||
private val cryptInstances: MutableMap<EncryptionAlgorithm, Crypt> = mutableMapOf() | ||
|
||
companion object { | ||
@JvmStatic | ||
fun getCrypt(type: CryptHandler.EncryptionAlgorithm, accountID: String, context: Context): Crypt { | ||
fun getCrypt(type: EncryptionAlgorithm, accountID: String, context: Context): Crypt { | ||
return when (type) { | ||
CryptHandler.EncryptionAlgorithm.AES -> AESCrypt(accountID) | ||
CryptHandler.EncryptionAlgorithm.AES_GCM -> AESGCMCrypt(context) | ||
EncryptionAlgorithm.AES -> AESCrypt(accountID) | ||
EncryptionAlgorithm.AES_GCM -> AESGCMCrypt(context) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves or creates a Crypt instance for the specified algorithm. | ||
* | ||
* @param algorithm - The encryption algorithm to use. | ||
* @return The Crypt instance for the specified algorithm. | ||
*/ | ||
fun getCryptInstance(algorithm: EncryptionAlgorithm): Crypt { | ||
return cryptInstances.getOrPut(algorithm) { getCrypt(algorithm, accountId, context) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these ever used?