Skip to content
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

chore(revert): revert fix: downgrade CC to 0.8.2 and bump to 1.0.0-pre.6+v1-schemafix #2112

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class E2EIClientImpl(
toNewAcmeAuthz(wireE2eIdentity.newAuthzResponse(toUByteList(authz)))

override fun createDpopToken(backendNonce: String) =
TODO("Not implemented")
wireE2eIdentity.createDpopToken(expirySecs = defaultDPoPTokenExpiry, backendNonce)

override fun getNewDpopChallengeRequest(accessToken: String, previousNonce: String) =
toByteArray(wireE2eIdentity.newDpopChallengeRequest(accessToken, previousNonce))
Expand All @@ -66,13 +66,13 @@ class E2EIClientImpl(
toByteArray(wireE2eIdentity.checkOrderRequest(orderUrl, previousNonce))

override fun checkOrderResponse(order: JsonRawData) =
TODO("Not implemented")
wireE2eIdentity.checkOrderResponse(toUByteList(order))

override fun finalizeRequest(previousNonce: String) =
toByteArray(wireE2eIdentity.finalizeRequest(previousNonce))

override fun finalizeResponse(finalize: JsonRawData) =
TODO("Not implemented")
wireE2eIdentity.finalizeResponse(toUByteList(finalize))

override fun certificateRequest(previousNonce: String) =
toByteArray(wireE2eIdentity.certificateRequest(previousNonce))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import com.wire.crypto.CoreCryptoCallbacks
import com.wire.crypto.CustomConfiguration
import com.wire.crypto.DecryptedMessage
import com.wire.crypto.Invitee
import com.wire.crypto.MlsPublicGroupStateEncryptionType
import com.wire.crypto.MlsCredentialType
import com.wire.crypto.MlsGroupInfoEncryptionType
import com.wire.crypto.MlsRatchetTreeType
import com.wire.crypto.MlsWirePolicy
import com.wire.crypto.client.CoreCryptoCentral.Companion.lower
import io.ktor.util.decodeBase64Bytes
import io.ktor.util.encodeBase64
import java.io.File
Expand Down Expand Up @@ -86,11 +88,12 @@ actual class MLSClientImpl actual constructor(
private val coreCrypto: CoreCrypto
private val keyRotationDuration: Duration = 30.toDuration(DurationUnit.DAYS)
private val defaultGroupConfiguration = CustomConfiguration(keyRotationDuration.toJavaDuration(), MlsWirePolicy.PLAINTEXT)
private val defaultCiphersuite = CiphersuiteName.MLS_128_DHKEMX25519_AES128GCM_SHA256_ED25519.lower()
private val defaultE2EIExpiry: UInt = 90U
// private val defaultMLSCredentialType: MlsCredentialType = MlsCredentialType.BASIC
private val defaultMLSCredentialType: MlsCredentialType = MlsCredentialType.BASIC

init {
coreCrypto = CoreCrypto(rootDir, databaseKey.value, toUByteList(clientId.toString()), null)
coreCrypto = CoreCrypto(rootDir, databaseKey.value, toUByteList(clientId.toString()), listOf(defaultCiphersuite))
coreCrypto.setCallbacks(Callbacks())
}

Expand All @@ -99,16 +102,16 @@ actual class MLSClientImpl actual constructor(
}

override fun getPublicKey(): ByteArray {
return coreCrypto.clientPublicKey().toUByteArray().asByteArray()
return coreCrypto.clientPublicKey(defaultCiphersuite).toUByteArray().asByteArray()
}

override fun generateKeyPackages(amount: Int): List<ByteArray> {
return coreCrypto.clientKeypackages(amount.toUInt())
return coreCrypto.clientKeypackages(defaultCiphersuite, defaultMLSCredentialType, amount.toUInt())
.map { it.toUByteArray().asByteArray() }
}

override fun validKeyPackageCount(): ULong {
return coreCrypto.clientValidKeypackagesCount()
return coreCrypto.clientValidKeypackagesCount(defaultCiphersuite, defaultMLSCredentialType)
}

override fun updateKeyingMaterial(groupId: MLSGroupId): CommitBundle {
Expand All @@ -127,16 +130,19 @@ actual class MLSClientImpl actual constructor(
return toByteArray(
coreCrypto.newExternalAddProposal(
conversationId = toUByteList(groupId.decodeBase64Bytes()),
epoch = epoch
epoch = epoch,
ciphersuite = defaultCiphersuite,
credentialType = MlsCredentialType.BASIC
)
)
}

override fun joinByExternalCommit(publicGroupState: ByteArray): CommitBundle {
return toCommitBundle(coreCrypto.joinByExternalCommit(
toUByteList(publicGroupState),
defaultGroupConfiguration
))
defaultGroupConfiguration,
MlsCredentialType.BASIC)
)
}

override fun mergePendingGroupFromExternalCommit(groupId: MLSGroupId) {
Expand All @@ -153,13 +159,13 @@ actual class MLSClientImpl actual constructor(
externalSenders: List<Ed22519Key>
) {
val conf = ConversationConfiguration(
CiphersuiteName.MLS_128_DHKEMX25519_AES128GCM_SHA256_ED25519,
defaultCiphersuite,
externalSenders.map { toUByteList(it.value) },
defaultGroupConfiguration
)

val groupIdAsBytes = toUByteList(groupId.decodeBase64Bytes())
coreCrypto.createConversation(groupIdAsBytes, conf)
coreCrypto.createConversation(groupIdAsBytes, MlsCredentialType.BASIC, conf)
}

override fun wipeConversation(groupId: MLSGroupId) {
Expand Down Expand Up @@ -240,37 +246,63 @@ actual class MLSClientImpl actual constructor(
}

override fun newAcmeEnrollment(clientId: E2EIQualifiedClientId, displayName: String, handle: String): E2EIClient {
TODO("not implemented")
return E2EIClientImpl(
coreCrypto.e2eiNewEnrollment(
clientId.toString(),
displayName,
handle,
defaultE2EIExpiry,
defaultCiphersuite
)
)
}

override fun e2eiNewActivationEnrollment(
displayName: String,
handle: String
): E2EIClient {
TODO("not implemented")
return E2EIClientImpl(
coreCrypto.e2eiNewActivationEnrollment(
displayName,
handle,
defaultE2EIExpiry,
defaultCiphersuite
)
)
}

override fun e2eiNewRotateEnrollment(
displayName: String?,
handle: String?
): E2EIClient {
TODO("not implemented")
return E2EIClientImpl(
coreCrypto.e2eiNewRotateEnrollment(
displayName,
handle,
defaultE2EIExpiry,
defaultCiphersuite
)
)
}

override fun e2eiMlsInitOnly(enrollment: E2EIClient, certificateChain: CertificateChain) {
TODO("not implemented")
coreCrypto.e2eiMlsInitOnly((enrollment as E2EIClientImpl).wireE2eIdentity, certificateChain)
}

override fun e2eiRotateAll(
enrollment: E2EIClient,
certificateChain: CertificateChain,
newMLSKeyPackageCount: UInt
) {
TODO("not implemented")
coreCrypto.e2eiRotateAll(
(enrollment as E2EIClientImpl).wireE2eIdentity,
certificateChain,
newMLSKeyPackageCount
)
}

override fun isGroupVerified(groupId: MLSGroupId): Boolean =
TODO("not implemented")
!coreCrypto.e2eiIsDegraded(toUByteList(groupId.decodeBase64Bytes()))

companion object {
fun toUByteList(value: ByteArray): List<UByte> = value.asUByteArray().asList()
Expand All @@ -280,30 +312,30 @@ actual class MLSClientImpl actual constructor(
fun toCommitBundle(value: com.wire.crypto.MemberAddedMessages) = CommitBundle(
toByteArray(value.commit),
toByteArray(value.welcome),
toGroupInfoBundle(value.publicGroupState)
toGroupInfoBundle(value.groupInfo)
)

fun toCommitBundle(value: com.wire.crypto.CommitBundle) = CommitBundle(
toByteArray(value.commit),
value.welcome?.let { toByteArray(it) },
toGroupInfoBundle(value.publicGroupState)
toGroupInfoBundle(value.groupInfo)
)

fun toCommitBundle(value: com.wire.crypto.ConversationInitBundle) = CommitBundle(
toByteArray(value.commit),
null,
toGroupInfoBundle(value.publicGroupState)
toGroupInfoBundle(value.groupInfo)
)

fun toGroupInfoBundle(value: com.wire.crypto.PublicGroupStateBundle) = GroupInfoBundle(
fun toGroupInfoBundle(value: com.wire.crypto.GroupInfoBundle) = GroupInfoBundle(
toEncryptionType(value.encryptionType),
toRatchetTreeType(value.ratchetTreeType),
toByteArray(value.payload)
)

fun toEncryptionType(value: MlsPublicGroupStateEncryptionType) = when (value) {
MlsPublicGroupStateEncryptionType.PLAINTEXT -> GroupInfoEncryptionType.PLAINTEXT
MlsPublicGroupStateEncryptionType.JWE_ENCRYPTED -> GroupInfoEncryptionType.JWE_ENCRYPTED
fun toEncryptionType(value: MlsGroupInfoEncryptionType) = when (value) {
MlsGroupInfoEncryptionType.PLAINTEXT -> GroupInfoEncryptionType.PLAINTEXT
MlsGroupInfoEncryptionType.JWE_ENCRYPTED -> GroupInfoEncryptionType.JWE_ENCRYPTED
}

fun toRatchetTreeType(value: MlsRatchetTreeType) = when (value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

package com.wire.kalium.cryptography

import com.wire.crypto.CiphersuiteName
import com.wire.crypto.CoreCrypto
import com.wire.crypto.CryptoException
import com.wire.crypto.client.CoreCryptoCentral.Companion.lower
import com.wire.kalium.cryptography.exceptions.ProteusException
import io.ktor.util.decodeBase64Bytes
import io.ktor.util.encodeBase64
Expand All @@ -32,6 +34,7 @@ class ProteusClientCoreCryptoImpl internal constructor(
private val databaseKey: ProteusDBSecret
) : ProteusClient {

private val defaultCiphersuite = CiphersuiteName.MLS_128_DHKEMX25519_AES128GCM_SHA256_ED25519.lower()
private val path: String = "$rootDir/$KEYSTORE_NAME"
private lateinit var coreCrypto: CoreCrypto

Expand All @@ -52,7 +55,7 @@ class ProteusClientCoreCryptoImpl internal constructor(
coreCrypto = CoreCrypto.deferredInit(
path,
databaseKey.value,
null
listOf(defaultCiphersuite)
)
migrateFromCryptoBoxIfNecessary(coreCrypto)
coreCrypto.proteusInit()
Expand All @@ -67,7 +70,7 @@ class ProteusClientCoreCryptoImpl internal constructor(
coreCrypto = CoreCrypto.deferredInit(
path,
databaseKey.value,
null
listOf(defaultCiphersuite)
)
migrateFromCryptoBoxIfNecessary(coreCrypto)
coreCrypto.proteusInit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import kotlin.test.assertTrue

@IgnoreJS
@IgnoreIOS
@IgnoreJvm
@IgnoreAndroidInstrumented
class E2EIClientTest : BaseMLSClientTest() {
data class SampleUser(
val id: CryptoQualifiedID, val clientId: CryptoClientId, val name: String, val handle: String
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pbandk = "0.14.2"
turbine = "1.0.0"
avs = "9.2.22"
jna = "5.6.0"
core-crypto = "0.8.2"
core-crypto = "1.0.0-pre.6+v1-schemafix-002"
core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1"
completeKotlin = "1.1.0"
desugar-jdk = "1.1.5"
Expand Down
Loading