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

feat: set the correct cipher suite when claiming key packages [WPB-8592] 🍒 #2746

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f9a5f75
Commit with unresolved merge conflicts
MohamadJaara May 2, 2024
d03ac5a
Commit with unresolved merge conflicts
MohamadJaara May 6, 2024
0e5bc02
Commit with unresolved merge conflicts
MohamadJaara May 7, 2024
745ecac
Commit with unresolved merge conflicts
MohamadJaara May 7, 2024
54948e8
Commit with unresolved merge conflicts
MohamadJaara May 7, 2024
5da1fd7
Merge remote-tracking branch 'refs/remotes/origin/release/candidate' …
MohamadJaara May 16, 2024
53357a8
fix tests
MohamadJaara May 17, 2024
14e8e1c
detekt
MohamadJaara May 17, 2024
ec66056
Trigger CI
MohamadJaara May 18, 2024
07b76b2
Merge branch 'release/candidate' into feat/pass-signature-algorithm-w…
MohamadJaara May 18, 2024
a4b4b9d
Merge remote-tracking branch 'refs/remotes/origin/chore/update-CC-to-…
MohamadJaara May 18, 2024
614244e
Merge branch 'refs/heads/feat/pass-signature-algorithm-when-registrin…
MohamadJaara May 18, 2024
0b9ddb8
Merge remote-tracking branch 'refs/remotes/origin/chore/update-CC-to-…
MohamadJaara May 18, 2024
50e9359
Trigger CI
MohamadJaara May 18, 2024
b7ce200
Merge branch 'chore/update-CC-to-RC-59-cherry-pick' into fix/fetch-ML…
MohamadJaara May 18, 2024
802560e
detekt
MohamadJaara May 18, 2024
ba40ef2
test
MohamadJaara May 19, 2024
995d0e8
test
MohamadJaara May 19, 2024
473df21
BaseProteusClientTest
MohamadJaara May 19, 2024
a0b1fbd
fix merge issues
MohamadJaara May 21, 2024
6f4110e
Merge branch 'release/candidate' into chore/update-CC-to-RC-59-cherry…
MohamadJaara May 21, 2024
753914e
Merge branch 'chore/update-CC-to-RC-59-cherry-pick' into fix/fetch-ML…
MohamadJaara May 21, 2024
0164522
Merge branch 'refs/heads/fix/fetch-MLS-config-when-not-avilable-local…
MohamadJaara May 21, 2024
8b05199
Merge branch 'release/candidate' into feat/set-the-correct-public-key…
MohamadJaara May 21, 2024
1202c3f
fix merge issues
MohamadJaara May 21, 2024
d6a3bfd
Merge branch 'refs/heads/feat/set-the-correct-public-key-when-creatin…
MohamadJaara May 21, 2024
7b9d7ac
Merge remote-tracking branch 'refs/remotes/origin/release/candidate' …
MohamadJaara May 21, 2024
89dd9fe
fix merge issues
MohamadJaara May 21, 2024
f8607a5
fix merge issues
MohamadJaara May 21, 2024
cbcd570
fix merge issues
MohamadJaara May 22, 2024
8a02fd7
fix test
MohamadJaara May 22, 2024
37a582b
detekt
MohamadJaara May 22, 2024
b8dac7f
fix tests
MohamadJaara May 22, 2024
915fb30
fix tests
MohamadJaara May 22, 2024
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 @@ -44,6 +44,9 @@ class MLSClientImpl(

private val keyRotationDuration: Duration = 30.toDuration(DurationUnit.DAYS)
private val defaultGroupConfiguration = CustomConfiguration(keyRotationDuration, MlsWirePolicy.PLAINTEXT)
override fun getDefaultCipherSuite(): UShort {
return defaultCipherSuite
}

@Suppress("EmptyFunctionBlock")
override suspend fun close() {
Expand Down Expand Up @@ -97,11 +100,11 @@ class MLSClientImpl(

override suspend fun createConversation(
groupId: MLSGroupId,
externalSenders: List<Ed22519Key>
externalSenders: ByteArray
) {
val conf = ConversationConfiguration(
CiphersuiteName.MLS_128_DHKEMX25519_AES128GCM_SHA256_ED25519,
externalSenders.map { toUByteList(it.value) },
listOf(toUByteList(externalSenders)),
defaultGroupConfiguration
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class MLSClientImpl(
private val keyRotationDuration: Duration = 30.toDuration(DurationUnit.DAYS)
private val defaultGroupConfiguration = CustomConfiguration(keyRotationDuration.toJavaDuration(), MlsWirePolicy.PLAINTEXT)

override fun getDefaultCipherSuite(): UShort {
return defaultCipherSuite
}

override suspend fun close() {
coreCrypto.close()
}
Expand Down Expand Up @@ -104,11 +108,12 @@ class MLSClientImpl(

override suspend fun createConversation(
groupId: MLSGroupId,
externalSenders: List<Ed22519Key>
externalSenders: ByteArray
) {
kaliumLogger.d("createConversation: using defaultCipherSuite=$defaultCipherSuite")
val conf = ConversationConfiguration(
defaultCipherSuite,
externalSenders.map { it.value },
listOf(externalSenders),
defaultGroupConfiguration
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ data class DecryptedMessageBundle(
}
}

@JvmInline
value class Ed22519Key(
val value: ByteArray
)

@JvmInline
value class ExternalSenderKey(
val value: ByteArray
Expand All @@ -153,6 +148,11 @@ data class CrlRegistration(

@Suppress("TooManyFunctions")
interface MLSClient {
/**
* Get the default ciphersuite for the client.
* the Default ciphersuite is set when creating the mls client.
*/
fun getDefaultCipherSuite(): UShort

/**
* Free up any resources and shutdown the client.
Expand Down Expand Up @@ -253,7 +253,7 @@ interface MLSClient {
*/
suspend fun createConversation(
groupId: MLSGroupId,
externalSenders: List<Ed22519Key> = emptyList()
externalSenders: ByteArray
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ class MLSClientTest : BaseMLSClientTest() {
}

private suspend fun createClient(user: SampleUser): MLSClient {
return createMLSClient(user.qualifiedClientId, ALLOWED_CIPHER_SUITES, DEFAULT_CIPHER_SUITES)
return createMLSClient(user.qualifiedClientId)
}

@Test
fun givemMlsClient_whenCallingGetDefaultCipherSuite_ReturnExpectedValue() = runTest {
val mlsClient = createClient(ALICE1)
assertEquals(DEFAULT_CIPHER_SUITES, mlsClient.getDefaultCipherSuite())
}

@Test
fun givenClient_whenCallingGetPublicKey_ReturnNonEmptyResult() = runTest {
val mlsClient = createClient(ALICE1)
assertTrue(mlsClient.getPublicKey().first.isNotEmpty())
assertTrue(mlsClient.getPublicKey().isNotEmpty())
}

@Test
Expand All @@ -51,7 +57,7 @@ class MLSClientTest : BaseMLSClientTest() {
@Test
fun givenNewConversation_whenCallingConversationEpoch_ReturnZeroEpoch() = runTest {
val mlsClient = createClient(ALICE1)
mlsClient.createConversation(MLS_CONVERSATION_ID)
mlsClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
assertEquals(0UL, mlsClient.conversationEpoch(MLS_CONVERSATION_ID))
}

Expand All @@ -64,7 +70,7 @@ class MLSClientTest : BaseMLSClientTest() {

val aliceKeyPackage = aliceClient.generateKeyPackages(1).first()
val clientKeyPackageList = listOf(aliceKeyPackage)
bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
val welcome = bobClient.addMember(MLS_CONVERSATION_ID, clientKeyPackageList)?.welcome!!
bobClient.commitAccepted(MLS_CONVERSATION_ID)
val welcomeBundle = aliceClient.processWelcomeMessage(welcome)
Expand All @@ -82,7 +88,7 @@ class MLSClientTest : BaseMLSClientTest() {

val aliceKeyPackage = aliceClient.generateKeyPackages(1).first()
val clientKeyPackageList = listOf(aliceKeyPackage)
bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
val welcome = bobClient.addMember(MLS_CONVERSATION_ID, clientKeyPackageList)!!.welcome!!
val welcomeBundle = aliceClient.processWelcomeMessage(welcome)

Expand All @@ -98,7 +104,7 @@ class MLSClientTest : BaseMLSClientTest() {
val alice1KeyPackage = alice1Client.generateKeyPackages(1).first()
val clientKeyPackageList = listOf(alice1KeyPackage)

bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
bobClient.addMember(MLS_CONVERSATION_ID, clientKeyPackageList)
bobClient.commitAccepted(MLS_CONVERSATION_ID)
val proposal = alice2Client.joinConversation(MLS_CONVERSATION_ID, 1UL)
Expand All @@ -117,7 +123,7 @@ class MLSClientTest : BaseMLSClientTest() {

val clientKeyPackageList = listOf(aliceClient.generateKeyPackages(1).first())

bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
val welcome = bobClient.addMember(MLS_CONVERSATION_ID, clientKeyPackageList)?.welcome!!
bobClient.commitAccepted(MLS_CONVERSATION_ID)
val welcomeBundle = aliceClient.processWelcomeMessage(welcome)
Expand All @@ -135,7 +141,7 @@ class MLSClientTest : BaseMLSClientTest() {

val clientKeyPackageList = listOf(aliceClient.generateKeyPackages(1).first())

bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
val welcome = bobClient.addMember(MLS_CONVERSATION_ID, clientKeyPackageList)?.welcome!!
bobClient.commitAccepted((MLS_CONVERSATION_ID))
val welcomeBundle = aliceClient.processWelcomeMessage(welcome)
Expand All @@ -149,7 +155,7 @@ class MLSClientTest : BaseMLSClientTest() {
val bobClient = createClient(BOB1)
val carolClient = createClient(CAROL1)

bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
val welcome = bobClient.addMember(
MLS_CONVERSATION_ID,
listOf(aliceClient.generateKeyPackages(1).first())
Expand All @@ -176,7 +182,7 @@ class MLSClientTest : BaseMLSClientTest() {
aliceClient.generateKeyPackages(1).first(),
carolClient.generateKeyPackages(1).first()
)
bobClient.createConversation(MLS_CONVERSATION_ID)
bobClient.createConversation(MLS_CONVERSATION_ID, externalSenderKey)
val welcome = bobClient.addMember(MLS_CONVERSATION_ID, clientKeyPackageList)?.welcome!!
bobClient.commitAccepted(MLS_CONVERSATION_ID)
val welcomeBundle = aliceClient.processWelcomeMessage(welcome)
Expand All @@ -188,7 +194,7 @@ class MLSClientTest : BaseMLSClientTest() {
}

companion object {
val ALLOWED_CIPHER_SUITES = listOf(1.toUShort())
val externalSenderKey = ByteArray(32)
val DEFAULT_CIPHER_SUITES = 1.toUShort()
const val MLS_CONVERSATION_ID = "JfflcPtUivbg+1U3Iyrzsh5D2ui/OGS5Rvf52ipH5KY="
const val PLAIN_TEXT = "Hello World"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import kotlin.time.Duration

@Suppress("TooManyFunctions")
class MLSClientImpl : MLSClient {
override fun getDefaultCipherSuite(): UShort {
TODO("Not yet implemented")
}

override suspend fun close() {
TODO("Not yet implemented")
}
Expand Down Expand Up @@ -66,7 +70,7 @@ class MLSClientImpl : MLSClient {
TODO("Not yet implemented")
}

override suspend fun createConversation(groupId: MLSGroupId, externalSenders: List<Ed22519Key>) {
override suspend fun createConversation(groupId: MLSGroupId, externalSenders: ByteArray) {
TODO("Not yet implemented")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ interface MLSFailure : CoreFailure {
data object StaleProposal : MLSFailure
data object StaleCommit : MLSFailure

class Generic(internal val exception: Exception) : MLSFailure {
data class Generic(internal val exception: Exception) : MLSFailure {
val rootCause: Throwable get() = exception
}
}
Expand Down
Loading
Loading