Skip to content

Commit

Permalink
Remove dependency on libolm - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Sep 11, 2024
1 parent 6a8e978 commit 5908cd5
Show file tree
Hide file tree
Showing 64 changed files with 51 additions and 3,290 deletions.
3 changes: 0 additions & 3 deletions matrix-sdk-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ dependencies {
// Work
implementation libs.androidx.work

// olm lib is now hosted in MavenCentral
implementation 'org.matrix.android:olm-sdk:3.2.12'

// DI
implementation libs.dagger.dagger
kapt libs.dagger.daggerCompiler
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import org.matrix.android.sdk.internal.network.ApiInterceptor
import org.matrix.android.sdk.internal.network.UserAgentHolder
import org.matrix.android.sdk.internal.util.BackgroundDetectionObserver
import org.matrix.android.sdk.internal.worker.MatrixWorkerFactory
import org.matrix.olm.OlmManager
import java.util.concurrent.Executors
import javax.inject.Inject

Expand All @@ -49,7 +48,6 @@ internal class TestMatrix(context: Context, matrixConfiguration: MatrixConfigura
@Inject internal lateinit var rawService: RawService
@Inject internal lateinit var userAgentHolder: UserAgentHolder
@Inject internal lateinit var backgroundDetectionObserver: BackgroundDetectionObserver
@Inject internal lateinit var olmManager: OlmManager
@Inject internal lateinit var sessionManager: SessionManager
@Inject internal lateinit var homeServerHistoryService: HomeServerHistoryService
@Inject internal lateinit var apiInterceptor: ApiInterceptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
Expand All @@ -29,19 +28,12 @@ import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.listeners.ProgressListener
import org.matrix.android.sdk.common.assertByteArrayNotEqual
import org.matrix.olm.OlmManager
import org.matrix.olm.OlmPkDecryption

@Ignore("Ignored in order to speed up test run time")
@RunWith(AndroidJUnit4::class)
@FixMethodOrder(MethodSorters.JVM)
class KeysBackupPasswordTest : InstrumentedTest {

@Before
fun ensureLibLoaded() {
OlmManager()
}

/**
* Check KeysBackupPassword utilities
*/
Expand All @@ -51,7 +43,7 @@ class KeysBackupPasswordTest : InstrumentedTest {

assertEquals(32, generatePrivateKeyResult.salt.length)
assertEquals(500_000, generatePrivateKeyResult.iterations)
assertEquals(OlmPkDecryption.privateKeyLength(), generatePrivateKeyResult.privateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, generatePrivateKeyResult.privateKey.size)

// Reverse operation
val retrievedPrivateKey = retrievePrivateKeyWithPassword(
Expand All @@ -60,7 +52,7 @@ class KeysBackupPasswordTest : InstrumentedTest {
generatePrivateKeyResult.iterations
)

assertEquals(OlmPkDecryption.privateKeyLength(), retrievedPrivateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, retrievedPrivateKey.size)
assertArrayEquals(generatePrivateKeyResult.privateKey, retrievedPrivateKey)
}

Expand Down Expand Up @@ -101,7 +93,7 @@ class KeysBackupPasswordTest : InstrumentedTest {

assertEquals(32, generatePrivateKeyResult.salt.length)
assertEquals(500_000, generatePrivateKeyResult.iterations)
assertEquals(OlmPkDecryption.privateKeyLength(), generatePrivateKeyResult.privateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, generatePrivateKeyResult.privateKey.size)

// Reverse operation, with bad password
val retrievedPrivateKey = retrievePrivateKeyWithPassword(
Expand All @@ -110,7 +102,7 @@ class KeysBackupPasswordTest : InstrumentedTest {
generatePrivateKeyResult.iterations
)

assertEquals(OlmPkDecryption.privateKeyLength(), retrievedPrivateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, retrievedPrivateKey.size)
assertByteArrayNotEqual(generatePrivateKeyResult.privateKey, retrievedPrivateKey)
}

Expand All @@ -123,7 +115,7 @@ class KeysBackupPasswordTest : InstrumentedTest {

assertEquals(32, generatePrivateKeyResult.salt.length)
assertEquals(500_000, generatePrivateKeyResult.iterations)
assertEquals(OlmPkDecryption.privateKeyLength(), generatePrivateKeyResult.privateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, generatePrivateKeyResult.privateKey.size)

// Reverse operation, with bad iteration
val retrievedPrivateKey = retrievePrivateKeyWithPassword(
Expand All @@ -132,7 +124,7 @@ class KeysBackupPasswordTest : InstrumentedTest {
500_001
)

assertEquals(OlmPkDecryption.privateKeyLength(), retrievedPrivateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, retrievedPrivateKey.size)
assertByteArrayNotEqual(generatePrivateKeyResult.privateKey, retrievedPrivateKey)
}

Expand All @@ -145,7 +137,7 @@ class KeysBackupPasswordTest : InstrumentedTest {

assertEquals(32, generatePrivateKeyResult.salt.length)
assertEquals(500_000, generatePrivateKeyResult.iterations)
assertEquals(OlmPkDecryption.privateKeyLength(), generatePrivateKeyResult.privateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, generatePrivateKeyResult.privateKey.size)

// Reverse operation, with bad iteration
val retrievedPrivateKey = retrievePrivateKeyWithPassword(
Expand All @@ -154,7 +146,7 @@ class KeysBackupPasswordTest : InstrumentedTest {
generatePrivateKeyResult.iterations
)

assertEquals(OlmPkDecryption.privateKeyLength(), retrievedPrivateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, retrievedPrivateKey.size)
assertByteArrayNotEqual(generatePrivateKeyResult.privateKey, retrievedPrivateKey)
}

Expand All @@ -169,7 +161,7 @@ class KeysBackupPasswordTest : InstrumentedTest {

val retrievedPrivateKey = retrievePrivateKeyWithPassword(password, salt, iteration)

assertEquals(OlmPkDecryption.privateKeyLength(), retrievedPrivateKey.size)
assertEquals(EXPECTED_PRIVATE_KEY_LENGTH, retrievedPrivateKey.size)

// Data from RiotWeb
val privateKeyBytes = byteArrayOf(
Expand All @@ -187,5 +179,7 @@ class KeysBackupPasswordTest : InstrumentedTest {
private const val BAD_PASSWORD = "passw0rd"

private const val BAD_SALT = "AA0lxhQ9aYgGfMsclVWPIAublg8h9Nlu"

private const val EXPECTED_PRIVATE_KEY_LENGTH = 32
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5908cd5

Please sign in to comment.