Skip to content

Commit

Permalink
[android] Use tutasdk for argon2id; ~() all C++ code
Browse files Browse the repository at this point in the history
Remove dependency on phc-winner-argon2 and all C++ code.

Add NDK installation to kotlin-test.yml. Before, this was held together
with duct tape, and removing the CMakeLists.txt also removed the duct
tape, causing CI to complain about no NDK installed even though it was
somehow fine before...

Co-authored-by: wec43 <[email protected]>
  • Loading branch information
paw-hub and wec43 committed Aug 15, 2024
1 parent cbcf99c commit b959e15
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 688 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/kotlin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
distribution: ${{ env.java-distribution }}
- name: Setup Android SDK
uses: android-actions/setup-android@07976c6290703d34c16d382cb36445f98bb43b1f #3.2.0
- name: Setup Android NDK
run: sdkmanager "ndk;26.1.10909125"
- name: Setup Rust targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
- name: Lint
Expand Down
11 changes: 0 additions & 11 deletions app-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ android {
arg("room.schemaLocation", "$projectDir/schemas".toString())
arg("room.generateKotlin", "true")
}
externalNativeBuild {
cmake {
cppFlags ''
}
}
}
signingConfigs {
release {
Expand Down Expand Up @@ -114,12 +109,6 @@ android {
}

namespace 'de.tutao.tutanota'
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version "3.18.0+"
}
}
}

tasks.withType(Test).configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ class CompatibilityTest {
}

@Test
fun argon2idTest() {
fun argon2idTest() = runBlocking {
for (td in testData.argon2idTests) {
val key = hexToBytes(td.keyHex)
val salt = hexToBytes(td.saltHex)
val password = td.password.toByteArray()
assertArrayEquals(key, crypto.argon2idHashRawImpl(password, salt, ARGON2ID_TIME_COST, ARGON2ID_MEMORY_COST, ARGON2ID_PARALLELISM, ARGON2ID_HASH_LENGTH))
val password = td.password
assertArrayEquals(key, crypto.argon2idGeneratePassphraseKey(password, salt.wrap()).data)
}
}

Expand Down
31 changes: 0 additions & 31 deletions app-android/app/src/main/cpp/CMakeLists.txt

This file was deleted.

44 changes: 0 additions & 44 deletions app-android/app/src/main/cpp/argon2.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions app-android/app/src/main/cpp/helpers/byte_array_accessor.cpp

This file was deleted.

51 changes: 0 additions & 51 deletions app-android/app/src/main/cpp/helpers/byte_array_accessor.hpp

This file was deleted.

19 changes: 0 additions & 19 deletions app-android/app/src/main/cpp/helpers/java_exception.hpp

This file was deleted.

24 changes: 0 additions & 24 deletions app-android/app/src/main/cpp/helpers/non_copyable.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -151,36 +151,13 @@ class AndroidNativeCryptoFacade(
}

@Throws(CryptoError::class)
override suspend fun argon2idHashRaw(
password: DataWrapper,
override suspend fun argon2idGeneratePassphraseKey(
passphrase: String,
salt: DataWrapper,
timeCost: Int,
memoryCost: Int,
parallelism: Int,
hashLength: Int
): DataWrapper {
return DataWrapper(
this.argon2idHashRawImpl(
password.data,
salt.data,
timeCost,
memoryCost,
parallelism,
hashLength
)
)
return de.tutao.tutasdk.argon2idGenerateKeyFromPassphrase(passphrase, salt.data).wrap()
}

@Throws(CryptoError::class)
external fun argon2idHashRawImpl(
password: ByteArray,
salt: ByteArray,
timeCost: Int,
memoryCost: Int,
parallelism: Int,
hashLength: Int
): ByteArray

@Throws(CryptoError::class)
override suspend fun rsaEncrypt(
publicKey: RsaPublicKey,
Expand Down
13 changes: 0 additions & 13 deletions app-android/calendar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ android {
this.arguments["room.schemaLocation"] = "$projectDir/schemas"
}
}

externalNativeBuild {
cmake {
this.cppFlags("")
}
}
}

signingConfigs {
Expand Down Expand Up @@ -131,13 +125,6 @@ android {
sourceSets {
this.getByName("androidTest") {
assets.srcDirs(files("$projectDir/schemas"))
};
}

externalNativeBuild {
cmake {
this.path(file("src/main/cpp/CMakeLists.txt"))
this.version = "3.18.0+"
}
}
}
Expand Down
65 changes: 0 additions & 65 deletions app-android/calendar/src/main/cpp/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit b959e15

Please sign in to comment.