Skip to content

Commit

Permalink
Merge branch 'develop' into feat/inform_user_about_degraded_conversat…
Browse files Browse the repository at this point in the history
…ion_verification_status
  • Loading branch information
borichellow committed Jul 19, 2023
2 parents c6dff50 + abc276b commit 8d2b3b9
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ actual class MLSClientImpl actual constructor(
}

override fun encryptMessage(groupId: MLSGroupId, message: PlainMessage): ApplicationMessage {
val applicationMessage = coreCrypto.encryptMessage(toUByteList(groupId.decodeBase64Bytes()), toUByteList(message))
val applicationMessage =
coreCrypto.encryptMessage(toUByteList(groupId.decodeBase64Bytes()), toUByteList(message))
return toByteArray(applicationMessage)
}

Expand Down Expand Up @@ -231,7 +232,19 @@ actual class MLSClientImpl actual constructor(
TODO("Not yet implemented")
}

override fun initMLSWithE2EI(e2eiClient: E2EIClient, certificate: CertificateChain) {
override fun e2eiNewActivationEnrollment(displayName: String, handle: String): E2EIClient {
TODO("Not yet implemented")
}

override fun e2eiNewRotateEnrollment(displayName: String?, handle: String?): E2EIClient {
TODO("Not yet implemented")
}

override fun e2eiMlsInitOnly(enrollment: E2EIClient, certificateChain: CertificateChain) {
TODO("Not yet implemented")
}

override fun e2eiRotateAll(enrollment: E2EIClient, certificateChain: CertificateChain, newMLSKeyPackageCount: UInt) {
TODO("Not yet implemented")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ actual class MLSClientImpl actual constructor(
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

init {
coreCrypto = CoreCrypto(rootDir, databaseKey.value, toUByteList(clientId.toString()), listOf(defaultCiphersuite))
Expand All @@ -105,11 +106,12 @@ actual class MLSClientImpl actual constructor(
}

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

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

override fun updateKeyingMaterial(groupId: MLSGroupId): CommitBundle {
Expand Down Expand Up @@ -255,8 +257,48 @@ actual class MLSClientImpl actual constructor(
)
}

override fun initMLSWithE2EI(e2eiClient: E2EIClient, certificate: CertificateChain) {
coreCrypto.e2eiMlsInit((e2eiClient as E2EIClientImpl).wireE2eIdentity, certificate)
override fun e2eiNewActivationEnrollment(
displayName: String,
handle: String
): E2EIClient {
return E2EIClientImpl(
coreCrypto.e2eiNewActivationEnrollment(
displayName,
handle,
defaultE2EIExpiry,
defaultCiphersuite
)
)
}

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

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

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

override fun isGroupVerified(groupId: MLSGroupId): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ interface MLSClient {
fun deriveSecret(groupId: MLSGroupId, keyLength: UInt): ByteArray

/**
* Enroll Wire E2EIdentity ACME Client for E2
* Enroll Wire E2EIdentity Client for E2EI before MLSClient Initialization
*
* @return wire end to end identity client
*/
Expand All @@ -280,8 +280,41 @@ interface MLSClient {
handle: String
): E2EIClient

fun initMLSWithE2EI(e2eiClient: E2EIClient, certificate: CertificateChain)
/**
* Enroll Wire E2EIdentity Client for E2EI when MLSClient already initialized
*
* @return wire end to end identity client
*/
fun e2eiNewActivationEnrollment(
displayName: String,
handle: String
): E2EIClient

/**
* Enroll Wire E2EI Enrollment Client for renewing certificate
*
* @return wire end to end identity client
*/
fun e2eiNewRotateEnrollment(
displayName: String?,
handle: String?
): E2EIClient

/**
* Init MLSClient after enrollment
*/
fun e2eiMlsInitOnly(enrollment: E2EIClient, certificateChain: CertificateChain)

/**
* Generate new keypackages after E2EI certificate issued
*/
fun e2eiRotateAll(enrollment: E2EIClient, certificateChain: CertificateChain, newMLSKeyPackageCount: UInt)

/**
* Conversation E2EI Verification Status
*
* @return the conversation verification status
*/
fun isGroupVerified(groupId: MLSGroupId): Boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,23 @@ actual class MLSClientImpl actual constructor(
TODO("Not yet implemented")
}

override fun initMLSWithE2EI(e2eiClient: E2EIClient, certificate: CertificateChain) {
override fun e2eiNewActivationEnrollment(displayName: String, handle: String): E2EIClient {
TODO("Not yet implemented")
}

override fun e2eiNewRotateEnrollment(displayName: String?, handle: String?): E2EIClient {
TODO("Not yet implemented")
}

override fun e2eiMlsInitOnly(enrollment: E2EIClient, certificateChain: CertificateChain) {
TODO("Not yet implemented")
}

override fun e2eiRotateAll(
enrollment: E2EIClient,
certificateChain: CertificateChain,
newMLSKeyPackageCount: UInt
) {
TODO("Not yet implemented")
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pbandk = "0.14.2"
turbine = "1.0.0"
avs = "9.2.22"
jna = "5.6.0"
core-crypto = "1.0.0-pre.5"
core-crypto = "1.0.0-pre.6"
core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1"
completeKotlin = "1.1.0"
desugar-jdk = "1.1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class E2EIRepositoryImpl(
override suspend fun initMLSClientWithCertificate(certificateChain: String) {
e2EClientProvider.getE2EIClient().flatMap { e2eiClient ->
mlsClientProvider.getMLSClient().map {
it.initMLSWithE2EI(e2eiClient, certificateChain)
it.e2eiMlsInitOnly(e2eiClient, certificateChain)
}
}
}
Expand Down

0 comments on commit 8d2b3b9

Please sign in to comment.