Skip to content

Commit

Permalink
Merge pull request #8901 from element-hq/feature/bma/removeLibolm
Browse files Browse the repository at this point in the history
Remove dependency on libolm
  • Loading branch information
bmarty authored Sep 23, 2024
2 parents 1ac5090 + e89bec4 commit ac01523
Show file tree
Hide file tree
Showing 94 changed files with 159 additions and 4,645 deletions.
6 changes: 2 additions & 4 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 All @@ -224,7 +221,7 @@ dependencies {

implementation libs.google.phonenumber

implementation("org.matrix.rustcomponents:crypto-android:0.4.1")
implementation("org.matrix.rustcomponents:crypto-android:0.4.3")
// api project(":library:rustCrypto")

testImplementation libs.tests.junit
Expand All @@ -236,6 +233,7 @@ dependencies {
testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
// Transitively required for mocking realm as monarchy doesn't expose Rx
testImplementation libs.rx.rxKotlin
testImplementation libs.tests.robolectric

kaptAndroidTest libs.dagger.daggerCompiler
androidTestImplementation libs.androidx.testCore
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.

Loading

0 comments on commit ac01523

Please sign in to comment.